PxTransform Sq::getGlobalPose(const NpShape& shape, const PxRigidActor& actor) { const Scb::Actor& scbActor = NpActor::getScbFromPxActor(actor); const Scb::Shape& scbShape = shape.getScbShape(); return getGlobalPose(scbShape, scbActor); }
void NpShapeManager::setupSceneQuery(SceneQueryManager& sqManager, const PxRigidActor& actor, const NpShape& shape) { PX_ASSERT(shape.getFlags() & PxShapeFlag::eSCENE_QUERY_SHAPE); const PxU32 index = mShapes.find(&shape); PX_ASSERT(index!=0xffffffff); setupSceneQuery(sqManager, actor, index); }
// PT: this is really the same as Sq::getGlobalPose() specialized for dynamic shapes static PX_INLINE void getGlobalPose(PxTransform& transform, const NpShape& shape, const NpRigidDynamic& npRigidDynamic) { // Same as: // transform = npRigidDynamic.getGlobalPoseFast() * shape.getLocalPose(); // Same as: // transform = npRigidDynamic.getGlobalPoseFast() * npRigidDynamic.getCMassLocalPoseFast() * shape.getScbShape().getShape2Body(); // Same as: transform = npRigidDynamic.getScbBodyFast().getBody2World() * shape.getScbShape().getShape2Body(); }
void NpShapeManager::attachShape(NpShape& shape, PxRigidActor& actor) { PX_ASSERT(!mPruningStructure); Cm::PtrTableStorageManager& sm = NpFactory::getInstance().getPtrTableStorageManager(); const PxU32 index = getNbShapes(); mShapes.add(&shape, sm); mSceneQueryData.add(reinterpret_cast<void*>(size_t(SQ_INVALID_PRUNER_DATA)), sm); NpScene* scene = NpActor::getAPIScene(actor); if(scene && isSceneQuery(shape)) setupSceneQuery(scene->getSceneQueryManagerFast(), actor, index); Scb::RigidObject& ro = static_cast<Scb::RigidObject&>(NpActor::getScbFromPxActor(actor)); ro.onShapeAttach(shape.getScbShape()); PX_ASSERT(!shape.isExclusive() || shape.getActor()==NULL); shape.onActorAttach(actor); }
// PT: this is really the same as Sq::getGlobalPose() specialized for static shapes static PX_INLINE void getGlobalPose(PxTransform& transform, const NpShape& shape, const NpRigidStatic& npRigidStatic) { // Same as: // transform = npRigidStatic.getGlobalPoseFast() * shape.getLocalPose(); // Same as: // const PxTransform& globalPose = npRigidStatic.getGlobalPoseFast(); // const PxTransform localPose = globalPose.transformInv(shape.getScbShape().getShape2Body()); // transform = globalPose * localPose; // Same as: transform = shape.getScbShape().getShape2Body(); }
void NpShapeManager::detachShape(NpShape& s, PxRigidActor& actor, bool wakeOnLostTouch) { PX_ASSERT(!mPruningStructure); Cm::PtrTableStorageManager& sm = NpFactory::getInstance().getPtrTableStorageManager(); const PxU32 index = mShapes.find(&s); PX_ASSERT(index!=0xffffffff); Scb::RigidObject& ro = static_cast<Scb::RigidObject&>(NpActor::getScbFromPxActor(actor)); NpScene* scene = NpActor::getAPIScene(actor); if(scene && isSceneQuery(s)) scene->getSceneQueryManagerFast().removePrunerShape(getPrunerData(index)); Scb::Shape& scbShape = s.getScbShape(); ro.onShapeDetach(scbShape, wakeOnLostTouch, (s.getRefCount() == 1)); mShapes.replaceWithLast(index, sm); mSceneQueryData.replaceWithLast(index, sm); s.onActorDetach(); }
PrunerData SceneQueryManager::addPrunerShape(const NpShape& shape, const PxRigidActor& actor, bool dynamic, const PxBounds3* bounds, bool hasPrunerStructure) { PrunerPayload pp; const Scb::Shape& scbShape = shape.getScbShape(); const Scb::Actor& scbActor = gOffsetTable.convertPxActor2Scb(actor); pp.data[0] = size_t(&scbShape); pp.data[1] = size_t(&scbActor); PxBounds3 b; if(bounds) inflateBounds(b, *bounds); else (gComputeBoundsTable[dynamic])(b, scbShape, scbActor); const PxU32 index = PxU32(dynamic); PrunerHandle handle; PX_ASSERT(mPrunerExt[index].pruner()); mPrunerExt[index].pruner()->addObjects(&handle, &b, &pp, 1, hasPrunerStructure); mPrunerExt[index].invalidateTimestamp(); mPrunerExt[index].growDirtyList(handle); return createPrunerData(index, handle); }
static PX_FORCE_INLINE bool isSceneQuery(const NpShape& shape) { return shape.getFlagsFast() & PxShapeFlag::eSCENE_QUERY_SHAPE; }