You didn't copy/paste an important part of the code...
Code: Select all
560 const core::vector3df cameraRotation = core::line3d<f32>(cameraPosition, SceneManager->getActiveCamera()->getTarget()).getVector().getHorizontalAngle();
The Z part of cameraRotation is always 0. So checking this wouldn't be very useful.
If I'm reading the code in
core::vector3d<>::getHorizontalAngle() correctly, it isn't really giving the horizontal angle, but the rotation around the X and Y axes (i.e., the camera yaw and pitch).
The reason that the Z rotation (the roll) isn't taken into account is that the algorithm thinks that a rotation on Z won't affect which patches are visible. Unfortunately, I don't believe that this actually correct. When the camera is rotated on the Z axis, the frustum is rotated. If the frustum is rotated, the corners of the frustum might expose areas of terrain that were culled previously.
I think that this code was written to work with the FPS camera, and AFAICT the FPS camera doesn't handle roll rotations well, so this scenerio wasn't tested.
If it is indeed a bug, it would be trivial to write a testcase.
- add a terrain scene node.
- add a camera scene node.
- put the camera at the top-center of the terrain bounding box.
- set the camera target to the center of the bounding box.
- set the up vector to core::vector3df(0.f, 0.f, 1.f).
- in the render loop, rotate the up vector (only the X and Z components, Y will always be 0.f).
If the terrain is chopped off when the camera is rotated, then this is a bug. If you don't write a testcase, I'll submit one later this morning...
Travis