void SweepTest::FindTouchedCCTs( NxU32 nb_boxes, const NxExtendedBounds3* boxes, const void** box_user_data, NxU32 nb_capsules, const NxExtendedCapsule* capsules, const void** capsule_user_data, const NxExtendedBounds3& world_box) { NxExtendedVec3 Origin; // Will be TouchedGeom::mOffset world_box.getCenter(Origin); // Find touched boxes, i.e. other box controllers for(NxU32 i=0;i<nb_boxes;i++) { if(!world_box.intersect(boxes[i])) continue; TouchedUserBox* UserBox = (TouchedUserBox*)reserve(mGeomStream, sizeof(TouchedUserBox)/sizeof(NxU32)); UserBox->mType = TOUCHED_USER_BOX; UserBox->mUserData = box_user_data[i]; UserBox->mOffset = Origin; UserBox->mBox = boxes[i]; } // Find touched capsules, i.e. other capsule controllers NxExtendedVec3 Center; NxVec3 Extents; world_box.getCenter(Center); world_box.getExtents(Extents); NxMat33 Idt; Idt.id(); for(NxU32 i=0;i<nb_capsules;i++) { // Do a quick AABB check first, to avoid calling the SDK too much const NxF32 r = capsules[i].radius; if((capsules[i].p0.x - r > world_box.max.x) || (world_box.min.x > capsules[i].p1.x + r)) continue; if((capsules[i].p0.y - r > world_box.max.y) || (world_box.min.y > capsules[i].p1.y + r)) continue; if((capsules[i].p0.z - r > world_box.max.z) || (world_box.min.z > capsules[i].p1.z + r)) continue; // Do a box-capsule intersect, or skip it? => better to skip it, not really useful now /* NxCapsule tmp; tmp.radius = capsules[i].radius; tmp.p0.x = float(capsules[i].p0.x); tmp.p0.y = float(capsules[i].p0.y); tmp.p0.z = float(capsules[i].p0.z); tmp.p1.x = float(capsules[i].p1.x); tmp.p1.y = float(capsules[i].p1.y); tmp.p1.z = float(capsules[i].p1.z); float d2 = gUtilLib->NxSegmentOBBSqrDist(tmp, NxVec3(float(Center.x), float(Center.y), float(Center.z)), Extents, Idt, NULL, NULL); if(d2<capsules[i].radius*capsules[i].radius)*/ { TouchedUserCapsule* UserCapsule = (TouchedUserCapsule*)reserve(mGeomStream, sizeof(TouchedUserCapsule)/sizeof(NxU32)); UserCapsule->mType = TOUCHED_USER_CAPSULE; UserCapsule->mUserData = capsule_user_data[i]; UserCapsule->mOffset = Origin; UserCapsule->mCapsule = capsules[i]; } } }
void CCTDebugData::addAABB(const NxExtendedBounds3& bounds, NxU32 color) { NxExtendedVec3 center; NxVec3 extents; bounds.getCenter(center); bounds.getExtents(extents); NxBounds3 tmp; tmp.setCenterExtents(NxVec3((float)center.x, (float)center.y, (float)center.z), extents); addAABB(tmp, color, false); }