View Full Version : Accuracy at large translations
12-18-2011, 08:55 PM
I don't understand why when I translate something very far (like to an X of 100,000) the object being drawn snaps around while moving instead of being smooth. I figured it was because I was using floats (only had a couple decimal points of precision at that distance), but when I started using glTranslated the result was the same.
The object being drawn has vertices defined by floats, but I figure that shouldn't matter because the object itself is very small. Does gltranslate add an offset to all of the vertices or something? If that's true, then making the object use double precision vertices should fix the problem right?
12-18-2011, 10:54 PM
I figured it was because I was using floats (only had a couple decimal points of precision at that distance), but when I started using glTranslated the result was the same.
I wouldn't expect the "double` versions of the matrix functions to actually use doubles internally. They probably just cast them to floats.
You need to use doubles to generate your ModelView matrix manually (ie: not with OpenGL functions), then convert that matrix back to floats when you hand it to OpenGL (via glLoadMatrix). That way, your large translation from model-to-world will cancel out with your equally large but negative world-to-camera translation.
12-18-2011, 11:01 PM
read the "Floating point precision and accuracy" section here:
As well as this detailed blog post:
12-18-2011, 11:21 PM
@Alfonse: Thanks, that did the trick!
@Overaly: Also thanks, I'll check those out.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.