Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Actor is a box with 2 shapes:
- // A Box Geometry that has Simulation turned on
- // A Box Geometry twice the size that has Simulation turned off and Triggers turned on
- // Other is Capsule PxController with only the default shape
- i8 OPphysXOverlapping(OPphysXRigidActor* actor, OPphysXRigidActor* other) {
- OPuint actorShapeCount = actor->getNbShapes();
- OPuint otherShapeCount = other->getNbShapes();
- if(actorShapeCount <= 0 || otherShapeCount <= 0) return 0;
- PxShape** actorShapes = new PxShape*[actorShapeCount];
- PxShape** otherShapes = new PxShape*[otherShapeCount];
- actor->getShapes(actorShapes, actorShapeCount);
- other->getShapes(otherShapes, otherShapeCount);
- i8 collisionFound = 0;
- for(OPuint i = 0; i < actorShapeCount; i++) {
- PxGeometry actorGeometry = actorShapes[i]->getGeometry().any();
- PxTransform actorTransform = PxShapeExt::getGlobalPose(*actorShapes[i], *actor);
- for(OPuint j = 0; j < otherShapeCount; j++) {
- PxGeometry otherGeometry = otherShapes[j]->getGeometry().any();
- PxTransform otherTransform = PxShapeExt::getGlobalPose(*otherShapes[j], *other);
- if(PxGeometryQuery::overlap(actorGeometry, actorTransform, otherGeometry, otherTransform)) {
- collisionFound = 1;
- break;
- }
- }
- if(collisionFound) {
- break;
- }
- }
- OPfree(actorShapes);
- OPfree(otherShapes);
- return collisionFound;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement