What is the best mechanism for handling large scale structures and scenes?
Examples being a continent with scale cities and geography, or infinity universe style planetary transitions.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The biggest problem with working with floating point representations of positions in large scale is that you rapidly lose precision as you get further and further away from the origin.
To remedy this you need to express all positions as relative to something else than the origin. The easiest way to do this is to partition the world into a grid and store the positions of all entities something like this:
The position of the camera is also stored like this, and when it’s time to render you do something like this:
(For simplicity I ignored the orientation of camera and objects in this example, since there are no special problems associated with this).
If you’re working with a continuous world on a galactic scale you can replace the
kilometersparameter with along long(64 bits) giving you an effective range of 1.8 million lightyears.EDIT: To use this for continuous geometry such as terrain etc, you have to split the terrain into chunks of size one square kilometers, the coordinates of the vertices in the terrain chunk should be in the range [0, 1000].
Also in the function
getRelativePositionabove you could change it so it returns abooland returnfalseif the difference in kilometers is larger than some threshold (say the distance to your far clip plane).