RaySceneQuery issues

Problems building or running the engine, queries about how to use features etc.
Post Reply
Srekel
Halfling
Posts: 89
Joined: Tue Jun 08, 2004 8:33 pm
Contact:

RaySceneQuery issues

Post by Srekel »

First off, I'm using PyOgre but I'm posting here because I believe that the bugs may actually be in OGRE itself.

We use a lot of ray querying in our game, and most of the time it works great. However, we've stumbled onto a few cases where it seems that it doesn't work correctly.

1) Casting rays against terrain sometimes returns (among other things) a queryResult where the fragment type is 6. Looking at the docs, it doesn't make any sense:

Code: Select all

Enumeration values: 
WFT_NONE  Return no world geometry hits at all.  
WFT_PLANE_BOUNDED_REGION  Return pointers to convex plane-bounded regions.  
WFT_SINGLE_INTERSECTION  Return a single intersection point (typically RaySceneQuery only).  
WFT_CUSTOM_GEOMETRY  Custom geometry as defined by the SceneManager.  
WFT_RENDER_OPERATION  General RenderOperation structure.  
(There are only five values, 0-4)

2) Query returns [] (empty list of results) when the ray begins over the terrain AND the scene nodes in its path are over the rays position.

This really makes me go "WTF!" ;). What I'm experiencing:
When I'm under the terrain max height limit, the ray casting works perfect. I can shoot a ray (using Camera::getCameraToViewportRay) at anything and it will be in the list.

However, when I'm above the max height value of the terrain, it seems only scene nodes that are below me is in the list that gets returned.

I use the basic Terrain Scene Manager, and I call getCameraToViewportRay with screenx = screeny = 0.5 (the middle of the screen).



Does anyone recognize this? It seems really strange. For more info, me and Clay have been discussing (1) here: http://www.ogre3d.org/phpBB2addons/view ... sc&start=0
User avatar
DrPain
Gnome
Posts: 349
Joined: Tue Jul 05, 2005 2:51 pm
Location: Connecticut, USA

Re: RaySceneQuery issues

Post by DrPain »

Srekel wrote: Casting rays against terrain sometimes returns (among other things) a queryResult where the fragment type is 6.
The return values are OR'ed together, so that:

6 = 2 | 4 = WFT_SINGLE_INTERSECTION | WFT_CUSTOM_GEOMETRY

Don't know about the second problem.
Srekel
Halfling
Posts: 89
Joined: Tue Jun 08, 2004 8:33 pm
Contact:

Post by Srekel »

Ah, of course. That makes sense. Don't know if it explains the weird values though, where this:

Code: Select all

           print queryResult.worldFragment.singleIntersection 
           print queryResult.worldFragment.fragmentType 
prints this:

Code: Select all

Vector3(69991461078022444000000000000000000.000000, 0.000000, 0.000000) 
6 
mfdesigner
Gnoblar
Posts: 19
Joined: Sun Aug 03, 2008 9:56 pm
x 1

Re: RaySceneQuery issues

Post by mfdesigner »

I am seeing this exact problem in Ogre 1.4.9. What was the solution to this issue?
it seems to have problem picking the part of entity that is above the maxHeight of the terrain.

Thanks,
mfdesigner
Gnoblar
Posts: 19
Joined: Sun Aug 03, 2008 9:56 pm
x 1

Re: RaySceneQuery issues

Post by mfdesigner »

Hi,

After some reverse enginerring of the Ogre code, I have found the problem and a solution.

The problem is the SceneManager::setWorldGeometry() would reduce the scene bounding box
to that of the terrain. And any Ray query originated outside that box will not get any result
even if an entity lies in its path.

The solution is the following code right after setWorldGeometry to re-extends the scene bounding box.

AxisAlignedBox box;
Vector3 max(100000, 100000, 100000);
box.setExtents(-max, max);
sceneManager->setOption("Size", &box);
Post Reply