-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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
10 changed files
with
600 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.