Manually testing if two bodies are intersecting.

jchmack

29-10-2007 01:57:08

Lets say i have 2 bodies.



a = mScene->createBody("cube.1m.mesh",new NxOgre::CubeShape(1,1 ,1),NxOgre::Pose(Input + Vector3(0,1,0)), Params);

b = mScene->createBody("cube.1m.mesh",new NxOgre::CubeShape(1,1 ,1),NxOgre::Pose(Input + Vector3(0,1,0)), Params);



NxOgre will tell me when they collide automatically. But if they start out intersecting or are teleported (via body::setposition) into an overlapping position NxOgre will not tell me.

How can i manually test if body a+b are colliding without a collision callback.

Edit: For now i am assuming that i will use simple collision Shapes (cube,Sphere,Capsule). And that the more complex objects (like the level) will be static and i can just use a collision callback for those.

betajaen

29-10-2007 08:11:43

You could use an Intersection with Actor A. Seriously that's the name of the class. ;)

bool intersectsWith(Actor* a, Actor* b) {
Intersection* intersection = new Intersection(a->getScene(), new SimpleBox(1, b->getPose()), NX_ALL_SHAPES);
bool intersects = false;
for (Actor* actor = intersection->begin();actor = intersection->next();) {
if (actor == a)
intersects = true;
}
delete intersection;
return intersects;
}


If you want to check if could intersect before Actor B is moved then it gets a little more complicated and you have to use some of the PhysX utility functions directly.

jchmack

29-10-2007 11:48:39

LoL i knew about intersections but i though you took them out... I don't see them in 0.9. I know they are there in 0.6. Ill check again.

Edit: Well at least i don't see an intersection.cpp file like it was in 0.6. I am using 0.9-34.

betajaen

29-10-2007 11:50:32

They should be in 0.9, NxOgreIntersection.h/.cpp

jchmack

29-10-2007 11:52:51

Intellisense doesn't find it
NxOgre::I.....
and i don't see the file in the include/source directory.

betajaen

29-10-2007 12:08:48

It's there, NxOgre 0.9'38

http://latest.nxogre.org/nxogre3/NxOgre ... rsection.h

jchmack

29-10-2007 12:11:26

Ya im downloading 0.9-38 now =).