void NpRigidDynamic::setGlobalPose(const PxTransform& pose, bool autowake) { NpScene* scene = NpActor::getAPIScene(*this); #ifdef PX_CHECKED if(scene) scene->checkPositionSanity(*this, pose, "PxRigidDynamic::setGlobalPose"); #endif PX_CHECK_AND_RETURN(pose.isSane(), "NpRigidDynamic::setGlobalPose: pose is not valid."); NP_WRITE_CHECK(NpActor::getOwnerScene(*this)); PxTransform p = pose.getNormalized(); if(scene) { updateDynamicSceneQueryShapes(mShapeManager, scene->getSceneQueryManagerFast()); } PxTransform newPose = p; newPose.q.normalize(); //AM: added to fix 1461 where users read and write orientations for no reason. Scb::Body& b = getScbBodyFast(); PxTransform body2World = newPose * b.getBody2Actor(); b.setBody2World(body2World, false); if(scene && autowake && !(b.getActorFlags() & PxActorFlag::eDISABLE_SIMULATION)) wakeUpInternal(); }
PX_FORCE_INLINE void NpRigidDynamic::setKinematicTargetInternal(const PxTransform& targetPose) { // The target is actor related. Transform to body related target PxTransform bodyTarget = targetPose * getScbBodyFast().getBody2Actor(); Scb::Body& b = getScbBodyFast(); b.setKinematicTarget(bodyTarget); NpScene* scene = NpActor::getAPIScene(*this); if ((b.getFlags() & PxRigidBodyFlag::eUSE_KINEMATIC_TARGET_FOR_SCENE_QUERIES) && scene) { updateDynamicSceneQueryShapes(mShapeManager, scene->getSceneQueryManagerFast()); } }
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); }
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(); }