Please sign in to comment.
[3d] Handle tilting and rotation of camera better
This will update camera's view center as the camera moves around. Before the view center would be always at the zero elevation, which means that with terrain further away from zero elevation tilting and rotation of camera would feel weird due to the center point being far away. In order to update camera's view center we need to calculate intersection of terrain with a 3D ray coming from the camera's position towards the center of the viewport. This is done by going through the active terrain tiles and checking whether their bounding box intersects the ray - if it does, then we do an exact test of terrain tile's triangle mesh against the ray to find the closest intersection point. When we have the intersection, we update the view center to be at the terrain's surface. Unfortunately raycasting in Qt3D is only available from 5.11 which has been released only very recently. I have therefore ported some code from Qt3D internals and added ray vs axis-aligned box from a different source (Qt3D uses bounding spheres but they are not available in public API either)
- Loading branch information
Showing with 600 additions and 11 deletions.
- +2 −0 src/3d/CMakeLists.txt
- +17 −0 src/3d/qgs3dmapscene.cpp
- +10 −5 src/3d/qgscameracontroller.cpp
- +6 −6 src/3d/qgscameracontroller.h
- +340 −0 src/3d/qgsraycastingutils_p.cpp
- +119 −0 src/3d/qgsraycastingutils_p.h
- +63 −0 src/3d/terrain/qgsdemterraintilegeometry_p.cpp
- +6 −0 src/3d/terrain/qgsdemterraintilegeometry_p.h
- +29 −0 src/3d/terrain/qgsterrainentity_p.cpp
- +8 −0 src/3d/terrain/qgsterrainentity_p.h
Oops, something went wrong.