Raycasting results inverted

ebol

05-10-2007 12:15:09

Hi, I hope maybe someone can help me with this. When raycasting against bodies 1, 2, 3 (ray goes through them in that order), the result is inverted - getClosestActor() returns body num. 3, and RayCastReport container has 3, 2, 1 order.

Maybe I'm doing something wrong here, here's my code.


Ogre::Ray ray=mPlayer->mCamera->getCameraToViewportRay(0.5,0.5);

NxOgre::RayCaster* rayCast= new NxOgre::RayCaster(ray.getOrigin(), ray.getDirection().normalisedCopy(), 50, NxOgre::RayCaster::RCT_ALL, mPlayer->getGameWorld()->getPhysXScene());

bool b=rayCast->castShape(NxOgre::RayCaster::AF_NONE);


What could be the reason of this?

Caphalor

05-10-2007 13:41:24

I have exactly the same problem. I used a quick and dirty solution by changing the following in NxOgre:

RayCastHit RayCaster::getClosestRaycastHit() {
if (mReport.count() == 0) {
return RayCastHit();
}

RayCastReport::Iterator mIterator = mReport.items.end();
mIterator--;
return (*mIterator).second.t;
}


I think the real bug must be in the container class, the insert method seems to push the value in front of the list.

ebol

05-10-2007 13:46:57

Ah, so its not just me then... For now, like you, I just call the last element in the container, but I wonder what's causing it.

Thanks, at least I know I'm not alone ;)