BasicRaycast problems

si

03-05-2008 11:48:08

I'm trying to use a basic rayCast to detect whether a projectile has hit anything in my scene. This is how i'm using it


OgreNewt::BasicRaycast hitRay(BaseApplication::getSingletonPtr()->GetWorld(), pos, nextPos );
OgreNewt::BasicRaycast::BasicRaycastInfo info = hitRay.getFirstHit();

for(int i =0; i< hitRay.getHitCount(); i++)
{
//Returns all the object we have hit one at a time
info = hitRay.getInfoAt(i);

if(info.mBody)
{
OgreNewt::Body *body = (OgreNewt::Body *)info.mBody->getUserData();
{
CCollisionPacket P;

P.m_Position = pos + ((nextPos - pos) * info.mDistance);
P.m_Normal = info.mNormal;
P.m_Damage = 50.0f;

CEntity *object = (CEntity*) body;
//Tell object we have collided
object->OnCollision(&P);
hit = true;
}
}
}


However when the function returns I get the following error
Run-Time Check Failure #2 - Stack around the variable 'hitRay' was corrupted

I'm currently using Visual C++ V9.0 (2008), Ogre3D V1.4.7, Newton 1.53 and OgreNewt 0.10.
Has anyone else encountered this problem?

Thanks

pra

03-05-2008 14:42:15

never seen that kind of problem, but why don't use a collision callback to determine with what body the projectile did actually collide?

si

03-05-2008 16:54:26

Thanks for that. I've just derived my own version of RayCast which looks very similar to BasicRayCast so I could try and find out what the ray was colliding with. The thing is that it all seems to work now but I'm not sure why.

Will post my solution if it happens again