terrain height queries

gedimaster

18-10-2005 06:28:07

i'm using a separate framelistener to do terrain height queries and other collision detection.

i'm using plsm2 but when i run the program, it crashes with exception at

bool frameStarted(const FrameEvent& evt) //my framelistener
{ Ray pickRay(pSceneMgr->getSceneNode("mynode")->getPosition(), Vector3::UNIT_Y);
mRayQuery->setRay(pickRay); // crash here
//...


i suspect that the terrain wasn't paged in when the code tried to do an intersection test. i've tried sleeping this framelistener for a while when the tiles are being paged in but it's useless since framelisteners are not threaded.

can anyone offer any advice?

tuan kuranes

18-10-2005 07:26:51

nope if no page result is 0 (unless bug)

I suggest you do that


assert (pSceneMgr);
assert (pSceneMgr->getSceneNode("mynode"));
assert (mRayQuery);

Ray pickRay(pSceneMgr->getSceneNode("mynode")->getPosition(), Vector3::UNIT_Y);
mRayQuery->setRay(pickRay); // crash here

gedimaster

18-10-2005 07:29:36

all the assert tests pass.

and the crash line is still at
mRayQuery->setRay(pickRay);

strange?

tuan kuranes

18-10-2005 08:10:43

and when using a mask ?

mRayQuery->setQueryMask(RSQ_Height); //PLSM2 mask

( Vector3::NEGATIVE_UNIT_Y may also be more appropriate )

gedimaster

18-10-2005 08:43:04

i tried using NEGATIVE_UNIT_Y - still crashed.

my code has already got
mRayQuery->setQueryMask(RSQ_Height); //PLSM2 mask

after
mRayQuery->setRay(pickRay);

but the crash point is at mRayQuery...

why does this happen after i've migrated it to a separate framelistener?

:(

tuan kuranes

18-10-2005 09:05:18

can you reproduce it with the plsm2 demo ?

gedimaster

18-10-2005 09:29:57

i found out the problem - i did not somehow initialize mRayQuery before assigning a ray to it. when i've done this, it doesn't crash anymore.

mRayQuery = mScnMgr->createRayQuery(Ray(Vector3::ZERO, Vector3::NEGATIVE_UNIT_Y));

thanks.