I have a problem with my raycasting. I have 8 cubes, that define the first level of an octree (Eg. they create bigger cube).

I need to raycast them and "render" each cube. If I have only one cube, the raycasting works fine. If I use 8 cubes, I have a problem. If I move my camera, gaps between cubes start to appear. Cubes are moving apart.

The whole octree bounding box min is (0,0,0), max is (64, 64, 64). Each box has size 32x32x32 and all boxes are set in [0,0,0] and move to their right position with transform matrix tmp

The space between boxes is changing its size with respect to the camera. There should be no space between boxes: it should be one single square (if I rotate this, there are other 4 boxes from octree behind those)

1 Answer
1

I cannot sure how your math library is working exactly, but a function named TransformCoordinate is usually used to transform a position vector including translation. A directional vector should use another transform usually named TransformNormal.

In the CastRays function, you used TransformCoordinate to transform a directional vector, ray.dir. It might cause wrong results.