/** Applies torques - Assumes caller has obtained writer lock */ void FPhysSubstepTask::ApplyTorques(const FPhysTarget & PhysTarget, FBodyInstance * BodyInstance) { #if WITH_PHYSX /** Apply Torques */ PxRigidDynamic * PRigidDynamic = BodyInstance->GetPxRigidDynamic(); for (int32 i = 0; i < PhysTarget.Torques.Num(); ++i) { const FTorqueTarget & TorqueTarget = PhysTarget.Torques[i]; PRigidDynamic->addTorque(U2PVector(TorqueTarget.Torque), PxForceMode::eFORCE, true); } #endif }
void PhysX::AddLocalTorque(PintObjectHandle handle, const Point& local_torque) { PxRigidActor* RigidActor = GetActorFromHandle(handle); if(!RigidActor) { PxShape* Shape = GetShapeFromHandle(handle); ASSERT(Shape); RigidActor = &Shape->getActor(); } if(RigidActor->getConcreteType()==PxConcreteType::eRIGID_DYNAMIC) { PxRigidDynamic* RigidDynamic = static_cast<PxRigidDynamic*>(RigidActor); const PxVec3 GlobalTorque = RigidDynamic->getGlobalPose().rotate(ToPxVec3(local_torque)); RigidDynamic->addTorque(GlobalTorque, PxForceMode::eACCELERATION, true); } }