Advertisement
Guest User

Untitled

a guest
Jul 1st, 2015
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.36 KB | None | 0 0
  1.  
  2. // Actor is a box with 2 shapes:
  3. //      A Box Geometry that has Simulation turned on
  4. //      A Box Geometry twice the size that has Simulation turned off and Triggers turned on
  5. // Other is Capsule PxController with only the default shape
  6.  
  7. i8 OPphysXOverlapping(OPphysXRigidActor* actor, OPphysXRigidActor* other) {
  8.     OPuint actorShapeCount = actor->getNbShapes();
  9.     OPuint otherShapeCount = other->getNbShapes();
  10.  
  11.     if(actorShapeCount <= 0 || otherShapeCount <= 0) return 0;
  12.  
  13.     PxShape** actorShapes = new PxShape*[actorShapeCount];
  14.     PxShape** otherShapes = new PxShape*[otherShapeCount];
  15.  
  16.     actor->getShapes(actorShapes, actorShapeCount);
  17.     other->getShapes(otherShapes, otherShapeCount);
  18.  
  19.     i8 collisionFound = 0;
  20.  
  21.     for(OPuint i = 0; i < actorShapeCount; i++) {
  22.         PxGeometry actorGeometry = actorShapes[i]->getGeometry().any();
  23.         PxTransform actorTransform = PxShapeExt::getGlobalPose(*actorShapes[i], *actor);
  24.         for(OPuint j = 0; j < otherShapeCount; j++) {
  25.             PxGeometry otherGeometry = otherShapes[j]->getGeometry().any();
  26.             PxTransform otherTransform = PxShapeExt::getGlobalPose(*otherShapes[j], *other);
  27.  
  28.             if(PxGeometryQuery::overlap(actorGeometry, actorTransform, otherGeometry, otherTransform)) {
  29.                 collisionFound = 1;
  30.                 break;
  31.             }
  32.         }
  33.  
  34.         if(collisionFound) {
  35.             break;
  36.         }
  37.     }
  38.  
  39.     OPfree(actorShapes);
  40.     OPfree(otherShapes);
  41.  
  42.     return collisionFound;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement