[Solution] RaySceneQuery fails when far from root

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
Enhex
Gnoblar
Posts: 13
Joined: Sat Feb 22, 2014 7:56 am

[Solution] RaySceneQuery fails when far from root

Post by Enhex »

Recently I had a similar problem to this one:
http://www.ogre3d.org/forums/viewtopic.php?f=2&t=62468

The problem was that when you get far from the scene's root (0,0,0) RaySceneQuery starts to fail.
The old thread suggests the problem is floating point precision, which is NOT true.

The cause:
=========
ST_GENERIC seems to default to OctreeSceneManager (and maybe some other scene types).
That leads to RaySceneQuery to default to OctreeRaySceneQuery.
OctreeRaySceneQuery uses the following line:

Code: Select all

static_cast<OctreeSceneManager*>( mParentSceneMgr ) -> findNodesIn( mRay, _list, 0 );
which call OctreeSceneManager::findNodesIn which uses the OctreeSceneManager's mOctree.
_findNodes checks with the ray intersects with the Octree and returns false if it doesn't.
Octree seems to default to (-10000, 10000).

And that's the reason why RaySceneQuery fails.
Thank god for open source!

The solution:
===========
static cast the SceneManager to OctreeSceneManager and use resize().
Post Reply