TerrainSceneManager: Bad RAY query results + SOLUTION


18-11-2011 13:59:37

I figured out that ray scene queries with the Terrain Scene Manager are very imprecise.

The resulting distance to the terrain hit point is upto 1 Ogre Unit larger than the real distance.
So the resulting hit points are at the wrong place. (somewhere below the terrain surface)
Here is a picture of my tests:
Click to enlarge
[attachment=0]Ogre problem - wrong RAY results for terrain.png[/attachment]

Only vertical rays returns the correct distance value.

I started a topic about this bug in the main forum. (here)
There I got answers related to the TSM internal calculation algorithm.


Based on this information I wrote a method, which perform a distance correction.
It's very easy to embedd into existing Mogre applications.
Just add my correction method and 2 lines of code to each ray query loop.
Then the distance results for terrain are very precise.

My code I published here:
:arrow: http://www.ogre3d.org/forums/viewtopic. ... 00#p444900

Also I created images which explains how my code calculates the distance correction.

This problem is only related to the Terrain Scene Manager.
The new terrain component gives precise results. (For other terrain managers I don't know.)