Refactor raycasting and add opencheck check