by the Codermind team. |
Question
«In my 3D engine, each frame I modify my mesh to account for its movement, or change the camera point of view. I do it incrementally. That is each frame I multiply previous frame position with a new matrix that represents the delta in position between frames. What I found is that after a few frames my mesh is flatten to a dot, or becomes skewed. Is there something I can do to solve that problem ?»
Answer
It's what floating point does for you, repeated transform makes precision worse and worse.
Rather than what you do, you should keep original instances of all your data in memory : meshes (read only), angles (or quaternions), scaling, translation vector.
If you do anything incremental (like an incremental rotation of an object), then you keep as many parameters separated as possible, for example you compute rotation as a separate matrix that you normalize, orthogonalize every now and then so that it doesn't shrink, expand and skew. If you do it often enough, things won't pop up as the "correction" will be minor each time.




