29#ifndef NP_RIGIDBODY_TEMPLATE_H
30#define NP_RIGIDBODY_TEMPLATE_H
32#include "NpRigidActorTemplate.h"
33#include "ScBodyCore.h"
37#include "CmVisualization.h"
38#include "NpDebugViz.h"
43 #define UPDATE_PVD_PROPERTY_BODY \
45 NpScene* sceneForPVD = RigidActorTemplateClass::getNpScene(); \
47 sceneForPVD->getScenePvdClientInternal().updateBodyPvdProperties(static_cast<NpActor*>(this)); \
50 #define UPDATE_PVD_PROPERTY_BODY
55PX_INLINE PxVec3 invertDiagInertia(
const PxVec3& m)
57 return PxVec3( m.x == 0.0f ? 0.0f : 1.0f/m.x,
58 m.y == 0.0f ? 0.0f : 1.0f/m.y,
59 m.z == 0.0f ? 0.0f : 1.0f/m.z);
62#if PX_ENABLE_DEBUG_VISUALIZATION
67PX_INLINE PxVec3 getDimsFromBodyInertia(
const PxVec3& inertiaMoments, PxReal mass)
69 const PxVec3 inertia = inertiaMoments * (6.0f/mass);
70 return PxVec3(
PxSqrt(
PxAbs(- inertia.x + inertia.y + inertia.z)),
72 PxSqrt(
PxAbs(+ inertia.x + inertia.y - inertia.z)));
75 PX_CATCH_UNDEFINED_ENABLE_DEBUG_VISUALIZATION
78template<
class APIClass>
104 virtual void setLinearDamping(PxReal linDamp)
PX_OVERRIDE;
105 virtual PxReal getLinearDamping()
const PX_OVERRIDE;
106 virtual void setAngularDamping(PxReal angDamp)
PX_OVERRIDE;
107 virtual PxReal getAngularDamping()
const PX_OVERRIDE;
110 virtual void setMaxLinearVelocity(PxReal maxLinVel)
PX_OVERRIDE;
111 virtual PxReal getMaxLinearVelocity()
const PX_OVERRIDE;
112 virtual void setMaxAngularVelocity(PxReal maxAngVel)
PX_OVERRIDE;
113 virtual PxReal getMaxAngularVelocity()
const PX_OVERRIDE;
130 NP_READ_CHECK(RigidActorTemplateClass::getNpScene());
134 virtual void setMinCCDAdvanceCoefficient(PxReal advanceCoefficient)
PX_OVERRIDE;
135 virtual PxReal getMinCCDAdvanceCoefficient()
const PX_OVERRIDE;
136 virtual void setMaxDepenetrationVelocity(PxReal maxDepenVel)
PX_OVERRIDE;
137 virtual PxReal getMaxDepenetrationVelocity()
const PX_OVERRIDE;
138 virtual void setMaxContactImpulse(PxReal maxDepenVel)
PX_OVERRIDE;
139 virtual PxReal getMaxContactImpulse()
const PX_OVERRIDE;
140 virtual void setContactSlopCoefficient(PxReal slopCoefficient)
PX_OVERRIDE;
141 virtual PxReal getContactSlopCoefficient()
const PX_OVERRIDE;
146 void setCMassLocalPoseInternal(
const PxTransform&);
155#if PX_ENABLE_DEBUG_VISUALIZATION
158 PX_CATCH_UNDEFINED_ENABLE_DEBUG_VISUALIZATION
166 PX_INLINE void scSetSolverIterationCounts(PxU16 c)
168 PX_ASSERT(!RigidActorTemplateClass::isAPIWriteForbidden());
169 mCore.setSolverIterationCounts(c);
170 UPDATE_PVD_PROPERTY_BODY
175 PX_ASSERT(!RigidActorTemplateClass::isAPIWriteForbidden());
176 mCore.setRigidDynamicLockFlags(f);
177 UPDATE_PVD_PROPERTY_BODY
182 PX_ASSERT(!RigidActorTemplateClass::isAPIWriteForbidden());
183 mCore.setBody2World(p);
184 UPDATE_PVD_PROPERTY_BODY
189 PX_ASSERT(!RigidActorTemplateClass::isAPIWriteForbiddenExceptSplitSim());
190 mCore.setLinearVelocity(v);
191 UPDATE_PVD_PROPERTY_BODY
196 PX_ASSERT(!RigidActorTemplateClass::isAPIWriteForbiddenExceptSplitSim());
197 mCore.setAngularVelocity(v);
198 UPDATE_PVD_PROPERTY_BODY
201 PX_INLINE void scWakeUpInternal(PxReal wakeCounter)
203 PX_ASSERT(RigidActorTemplateClass::getNpScene());
205 PX_ASSERT(!RigidActorTemplateClass::isAPIWriteForbiddenExceptSplitSim());
206 mCore.wakeUp(wakeCounter);
213 NpScene* scene = RigidActorTemplateClass::getNpScene();
216 scWakeUpInternal(scene->getWakeCounterResetValueInternal());
221 PX_ASSERT(!RigidActorTemplateClass::isAPIWriteForbidden());
229 scPutToSleepInternal();
232 PX_INLINE void scSetWakeCounter(PxReal w)
236 PX_ASSERT(!RigidActorTemplateClass::isAPIWriteForbiddenExceptSplitSim());
237 mCore.setWakeCounter(w);
238 UPDATE_PVD_PROPERTY_BODY
243 PX_ASSERT(!RigidActorTemplateClass::isAPIWriteForbidden());
244 mCore.setFlags(RigidActorTemplateClass::getNpScene() ? RigidActorTemplateClass::getNpScene()->getScScene().getSimStateDataPool() : NULL, f);
245 UPDATE_PVD_PROPERTY_BODY
250 PX_ASSERT(!RigidActorTemplateClass::isAPIWriteForbiddenExceptSplitSim());
252 mCore.addSpatialAcceleration(RigidActorTemplateClass::getNpScene()->getScScene().getSimStateDataPool(), linAcc, angAcc);
258 PX_ASSERT(!RigidActorTemplateClass::isAPIWriteForbiddenExceptSplitSim());
260 mCore.setSpatialAcceleration(RigidActorTemplateClass::getNpScene()->getScScene().getSimStateDataPool(), linAcc, angAcc);
264 PX_INLINE void scClearSpatialAcceleration(
bool force,
bool torque)
266 PX_ASSERT(!RigidActorTemplateClass::isAPIWriteForbiddenExceptSplitSim());
268 mCore.clearSpatialAcceleration(force, torque);
274 PX_ASSERT(!RigidActorTemplateClass::isAPIWriteForbiddenExceptSplitSim());
276 mCore.addSpatialVelocity(RigidActorTemplateClass::getNpScene()->getScScene().getSimStateDataPool(), linVelDelta, angVelDelta);
277 UPDATE_PVD_PROPERTY_BODY
280 PX_INLINE void scClearSpatialVelocity(
bool force,
bool torque)
282 PX_ASSERT(!RigidActorTemplateClass::isAPIWriteForbiddenExceptSplitSim());
284 mCore.clearSpatialVelocity(force, torque);
285 UPDATE_PVD_PROPERTY_BODY
290 NpScene* scene = RigidActorTemplateClass::getNpScene();
292 const PxReal wakeCounterResetValue = scene->getWakeCounterResetValueInternal();
294 PX_ASSERT(!RigidActorTemplateClass::isAPIWriteForbiddenExceptSplitSim());
296 mCore.setKinematicTarget(p, wakeCounterResetValue);
298 UPDATE_PVD_PROPERTY_BODY
301 scene->getScenePvdClientInternal().updateKinematicTarget(
this, p);
307 PxMat33 inverseInertiaWorldSpace;
308 Cm::transformInertiaTensor(mCore.getInverseInertia(),
PxMat33Padded(mCore.getBody2World().q), inverseInertiaWorldSpace);
309 return inverseInertiaWorldSpace;
314 return (getLinearVelocity().isZero() && getAngularVelocity().isZero());
322template<
class APIClass>
324 RigidActorTemplateClass (concreteType, baseFlags, npType),
325 mCore (type, bodyPose)
329template<
class APIClass>
330NpRigidBodyTemplate<APIClass>::~NpRigidBodyTemplate()
339 if (t == PxGeometryType::eTRIANGLEMESH)
341 const PxTriangleMeshGeometry& triGeom =
static_cast<const PxTriangleMeshGeometry&
>(shape.
getGeometry());
342 const Gu::TriangleMesh* mesh =
static_cast<const Gu::TriangleMesh*
>(triGeom.triangleMesh);
343 return mesh->getSdfDataFast().mSdf != NULL && mesh->getMass() < 0.f;
350 const PxTriangleMeshGeometry& triGeom =
static_cast<const PxTriangleMeshGeometry&
>(geom);
351 const Gu::TriangleMesh* mesh =
static_cast<const Gu::TriangleMesh*
>(triGeom.triangleMesh);
352 return mesh->getSdfDataFast().mSdf != NULL && mesh->getMass() > 0.f;
358 return t != PxGeometryType::ePLANE && t != PxGeometryType::eHEIGHTFIELD && t != PxGeometryType::eTETRAHEDRONMESH &&
359 (t != PxGeometryType::eTRIANGLEMESH || isDynamicMesh(shape.
getGeometry()));
363template<
class APIClass>
364bool NpRigidBodyTemplate<APIClass>::attachShape(PxShape& shape)
366 NP_WRITE_CHECK(RigidActorTemplateClass::getNpScene());
368 || !hasNegativeMass(shape)
370 "attachShape: The faces of the mesh are oriented the wrong way round leading to a negative mass. Please invert the orientation of all faces and try again.",
false);
375 "attachShape: non-SDF triangle mesh, tetrahedron mesh, heightfield or plane geometry shapes configured as eSIMULATION_SHAPE are not supported for non-kinematic PxRigidDynamic instances.",
false);
377 return RigidActorTemplateClass::attachShape(shape);
380template<
class APIClass>
381void NpRigidBodyTemplate<APIClass>::setCMassLocalPoseInternal(
const PxTransform& body2Actor)
385 const PxTransform newBody2World = getGlobalPose() * body2Actor;
387 scSetBody2World(newBody2World);
391 PX_ASSERT(!RigidActorTemplateClass::isAPIWriteForbidden());
392 mCore.setBody2Actor(body2Actor);
393 UPDATE_PVD_PROPERTY_BODY
396 RigidActorTemplateClass::updateShaderComs();
398#if PX_SUPPORT_OMNI_PVD
399 PxActor* actor =
static_cast<PxActor*
>(
this);
400 OMNI_PVD_SET(actor, cMassLocalPose, *actor, body2Actor)
404template<
class APIClass>
405PxTransform NpRigidBodyTemplate<APIClass>::getCMassLocalPose()
const
407 NP_READ_CHECK(RigidActorTemplateClass::getNpScene());
409 return mCore.getBody2Actor();
412template<
class APIClass>
413void NpRigidBodyTemplate<APIClass>::setMass(PxReal mass)
415 NpScene* npScene = RigidActorTemplateClass::getNpScene();
416 NP_WRITE_CHECK(npScene);
417 PX_CHECK_AND_RETURN(
PxIsFinite(mass),
"PxRigidBody::setMass(): invalid float");
418 PX_CHECK_AND_RETURN(mass>=0,
"PxRigidBody::setMass(): mass must be non-negative!");
419 PX_CHECK_AND_RETURN(this->getType() !=
PxActorType::eARTICULATION_LINK || mass > 0.0f,
"PxRigidBody::setMass(): components must be > 0 for articulations");
421 PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene,
"PxRigidBody::setMass() not allowed while simulation is running. Call will be ignored.")
423 mCore.setInverseMass(mass > 0.0f ? 1.0f/mass : 0.0f);
425 UPDATE_PVD_PROPERTY_BODY
427#if PX_SUPPORT_OMNI_PVD
428 PxActor* actor =
static_cast<PxActor*
>(
this);
429 OMNI_PVD_SET(actor, mass, *actor, mass)
433template<
class APIClass>
434PxReal NpRigidBodyTemplate<APIClass>::getMass()
const
436 NP_READ_CHECK(RigidActorTemplateClass::getNpScene());
437 const PxReal invMass = mCore.getInverseMass();
439 return invMass > 0.0f ? 1.0f/invMass : 0.0f;
442template<
class APIClass>
443PxReal NpRigidBodyTemplate<APIClass>::getInvMass()
const
445 NP_READ_CHECK(RigidActorTemplateClass::getNpScene());
447 return mCore.getInverseMass();
450template<
class APIClass>
451void NpRigidBodyTemplate<APIClass>::setMassSpaceInertiaTensor(
const PxVec3& m)
453 NpScene* npScene = RigidActorTemplateClass::getNpScene();
454 NP_WRITE_CHECK(npScene);
455 PX_CHECK_AND_RETURN(m.isFinite(),
"PxRigidBody::setMassSpaceInertiaTensor(): invalid inertia");
456 PX_CHECK_AND_RETURN(m.x>=0.0f && m.y>=0.0f && m.z>=0.0f,
"PxRigidBody::setMassSpaceInertiaTensor(): components must be non-negative");
457 PX_CHECK_AND_RETURN(this->getType() !=
PxActorType::eARTICULATION_LINK || (m.x > 0.0f && m.y > 0.0f && m.z > 0.0f),
"PxRigidBody::setMassSpaceInertiaTensor(): components must be > 0 for articulations");
459 PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene,
"PxRigidBody::setMassSpaceInertiaTensor() not allowed while simulation is running. Call will be ignored.")
461 mCore.setInverseInertia(invertDiagInertia(m));
462 UPDATE_PVD_PROPERTY_BODY
464#if PX_SUPPORT_OMNI_PVD
465 PxActor* actor =
static_cast<PxActor*
>(
this);
466 OMNI_PVD_SET(actor, massSpaceInertiaTensor, *actor, m)
470template<
class APIClass>
471PxVec3 NpRigidBodyTemplate<APIClass>::getMassSpaceInertiaTensor()
const
473 NP_READ_CHECK(RigidActorTemplateClass::getNpScene());
475 return invertDiagInertia(mCore.getInverseInertia());
478template<
class APIClass>
479PxVec3 NpRigidBodyTemplate<APIClass>::getMassSpaceInvInertiaTensor()
const
481 NP_READ_CHECK(RigidActorTemplateClass::getNpScene());
483 return mCore.getInverseInertia();
486template<
class APIClass>
487PxVec3 NpRigidBodyTemplate<APIClass>::getLinearVelocity()
const
489 NP_READ_CHECK(RigidActorTemplateClass::getNpScene());
491 PX_CHECK_SCENE_API_READ_FORBIDDEN_EXCEPT_COLLIDE_AND_RETURN_VAL(RigidActorTemplateClass::getNpScene(),
"PxRigidBody::getLinearVelocity() not allowed while simulation is running (except during PxScene::collide()).", PxVec3(PxZero));
493 return mCore.getLinearVelocity();
496template<
class APIClass>
497PxVec3 NpRigidBodyTemplate<APIClass>::getAngularVelocity()
const
499 NP_READ_CHECK(RigidActorTemplateClass::getNpScene());
501 PX_CHECK_SCENE_API_READ_FORBIDDEN_EXCEPT_COLLIDE_AND_RETURN_VAL(RigidActorTemplateClass::getNpScene(),
"PxRigidBody::getAngularVelocity() not allowed while simulation is running (except during PxScene::collide()).", PxVec3(PxZero));
503 return mCore.getAngularVelocity();
506template<
class APIClass>
507void NpRigidBodyTemplate<APIClass>::addSpatialForce(
const PxVec3* force,
const PxVec3* torque,
PxForceMode::Enum mode)
515 PxVec3 linAcc, angAcc;
518 linAcc = (*force) * mCore.getInverseMass();
523 angAcc = scGetGlobalInertiaTensorInverse() * (*torque);
526 scAddSpatialAcceleration(force, torque);
531 scAddSpatialAcceleration(force, torque);
536 PxVec3 linVelDelta, angVelDelta;
539 linVelDelta = ((*force) * mCore.getInverseMass());
540 force = &linVelDelta;
544 angVelDelta = (scGetGlobalInertiaTensorInverse() * (*torque));
545 torque = &angVelDelta;
547 scAddSpatialVelocity(force, torque);
552 scAddSpatialVelocity(force, torque);
557template<
class APIClass>
558void NpRigidBodyTemplate<APIClass>::setSpatialForce(
const PxVec3* force,
const PxVec3* torque,
PxForceMode::Enum mode)
566 PxVec3 linAcc, angAcc;
569 linAcc = (*force) * mCore.getInverseMass();
574 angAcc = scGetGlobalInertiaTensorInverse() * (*torque);
577 scSetSpatialAcceleration(force, torque);
582 scSetSpatialAcceleration(force, torque);
587 PxVec3 linVelDelta, angVelDelta;
590 linVelDelta = ((*force) * mCore.getInverseMass());
591 force = &linVelDelta;
595 angVelDelta = (scGetGlobalInertiaTensorInverse() * (*torque));
596 torque = &angVelDelta;
598 scAddSpatialVelocity(force, torque);
603 scAddSpatialVelocity(force, torque);
608template<
class APIClass>
609void NpRigidBodyTemplate<APIClass>::clearSpatialForce(
PxForceMode::Enum mode,
bool force,
bool torque)
617 scClearSpatialAcceleration(force, torque);
621 scClearSpatialVelocity(force, torque);
626#if PX_ENABLE_DEBUG_VISUALIZATION
627template<
class APIClass>
628void NpRigidBodyTemplate<APIClass>::visualize(PxRenderOutput& out, NpScene& scene,
float scale)
const
630 RigidActorTemplateClass::visualize(out, scene, scale);
632 visualizeRigidBody(out, scene, *
this, mCore, scale);
635 PX_CATCH_UNDEFINED_ENABLE_DEBUG_VISUALIZATION
638template<
class APIClass>
646 "PxRigidBody::setRigidBodyFlag(): kinematic bodies with CCD enabled are not supported! CCD will be ignored.");
650 NpScene* scene = RigidActorTemplateClass::getNpScene();
651 Sc::Scene* scScene = scene ? &scene->getScScene() : NULL;
655 const bool kinematicSwitchingToDynamic = isKinematic && (!willBeKinematic);
656 const bool dynamicSwitchingToKinematic = (!isKinematic) && willBeKinematic;
658 bool mustUpdateSQ =
false;
660 if(kinematicSwitchingToDynamic)
662 NpShapeManager& shapeManager = this->getShapeManager();
663 PxU32 nbShapes = shapeManager.getNbShapes();
664 NpShape*
const* shapes = shapeManager.getShapes();
665 bool hasTriangleMesh =
false;
666 for(PxU32 i=0;i<nbShapes;i++)
668 if((shapes[i]->getFlags() &
PxShapeFlag::eSIMULATION_SHAPE) && (shapes[i]->getGeometryTypeFast()==PxGeometryType::eTRIANGLEMESH || shapes[i]->getGeometryTypeFast()==PxGeometryType::ePLANE || shapes[i]->getGeometryTypeFast()==PxGeometryType::eHEIGHTFIELD))
670 hasTriangleMesh =
true;
680 PxTransform bodyTarget;
686 scScene->decreaseNumKinematicsCounter();
687 scScene->increaseNumDynamicsCounter();
690 else if (dynamicSwitchingToKinematic)
701 scScene->decreaseNumDynamicsCounter();
702 scScene->increaseNumKinematicsCounter();
706 const bool kinematicSwitchingUseTargetForSceneQuery = isKinematic && willBeKinematic &&
708 if (kinematicSwitchingUseTargetForSceneQuery)
710 PxTransform bodyTarget;
711 if (mCore.getKinematicTarget(bodyTarget) && scene)
715 scSetFlags(filteredNewFlags);
716#if PX_SUPPORT_OMNI_PVD
717 PxActor* actor =
static_cast<PxActor*
>(
this);
718 OMNI_PVD_SET(actor, rigidBodyFlags, *actor, filteredNewFlags)
723 this->getShapeManager().markActorForSQUpdate(scene->getSQAPI(), *
this);
726template<
class APIClass>
729 NpScene* npScene = RigidActorTemplateClass::getNpScene();
730 NP_WRITE_CHECK(npScene);
732 PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene,
"PxRigidBody::setRigidBodyFlag() not allowed while simulation is running. Call will be ignored.")
737 setRigidBodyFlagsInternal(currentFlags, newFlags);
740template<class APIClass>
741void NpRigidBodyTemplate<APIClass>::setRigidBodyFlags(
PxRigidBodyFlags inFlags)
743 NpScene* npScene = RigidActorTemplateClass::getNpScene();
744 NP_WRITE_CHECK(npScene);
746 PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene,
"PxRigidBody::setRigidBodyFlags() not allowed while simulation is running. Call will be ignored.")
750 setRigidBodyFlagsInternal(currentFlags, inFlags);
753template<class APIClass>
754void NpRigidBodyTemplate<APIClass>::setMinCCDAdvanceCoefficient(PxReal minCCDAdvanceCoefficient)
756 NpScene* npScene = RigidActorTemplateClass::getNpScene();
757 NP_WRITE_CHECK(npScene);
759 PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene,
"PxRigidBody::setMinCCDAdvanceCoefficient() not allowed while simulation is running. Call will be ignored.")
761 mCore.setCCDAdvanceCoefficient(minCCDAdvanceCoefficient);
762 UPDATE_PVD_PROPERTY_BODY
763#if PX_SUPPORT_OMNI_PVD
764 PxActor* actor =
static_cast<PxActor*
>(
this);
765 OMNI_PVD_SET(actor, minAdvancedCCDCoefficient, *actor, minCCDAdvanceCoefficient)
770template<
class APIClass>
771PxReal NpRigidBodyTemplate<APIClass>::getMinCCDAdvanceCoefficient()
const
773 NP_READ_CHECK(RigidActorTemplateClass::getNpScene());
774 return mCore.getCCDAdvanceCoefficient();
777template<
class APIClass>
778void NpRigidBodyTemplate<APIClass>::setMaxDepenetrationVelocity(PxReal maxDepenVel)
780 NpScene* npScene = RigidActorTemplateClass::getNpScene();
781 NP_WRITE_CHECK(npScene);
782 PX_CHECK_AND_RETURN(maxDepenVel > 0.0f,
"PxRigidBody::setMaxDepenetrationVelocity(): maxDepenVel must be greater than zero.");
784 PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene,
"PxRigidBody::setMaxDepenetrationVelocity() not allowed while simulation is running. Call will be ignored.")
786 mCore.setMaxPenetrationBias(-maxDepenVel);
787 UPDATE_PVD_PROPERTY_BODY
788#if PX_SUPPORT_OMNI_PVD
789 PxActor* actor =
static_cast<PxActor*
>(
this);
790 OMNI_PVD_SET(actor, maxDepenetrationVelocity, *actor, maxDepenVel)
794template<
class APIClass>
795PxReal NpRigidBodyTemplate<APIClass>::getMaxDepenetrationVelocity()
const
797 NP_READ_CHECK(RigidActorTemplateClass::getNpScene());
798 return -mCore.getMaxPenetrationBias();
801template<
class APIClass>
802void NpRigidBodyTemplate<APIClass>::setMaxContactImpulse(
const PxReal maxImpulse)
804 NpScene* npScene = RigidActorTemplateClass::getNpScene();
805 NP_WRITE_CHECK(npScene);
806 PX_CHECK_AND_RETURN(maxImpulse >= 0.f,
"PxRigidBody::setMaxContactImpulse(): impulse limit must be greater than or equal to zero.");
808 PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene,
"PxRigidBody::setMaxContactImpulse() not allowed while simulation is running. Call will be ignored.")
810 mCore.setMaxContactImpulse(maxImpulse);
811 UPDATE_PVD_PROPERTY_BODY
812#if PX_SUPPORT_OMNI_PVD
813 PxActor* actor =
static_cast<PxActor*
>(
this);
814 OMNI_PVD_SET(actor, maxContactImpulse, *actor, maxImpulse)
818template<
class APIClass>
819PxReal NpRigidBodyTemplate<APIClass>::getMaxContactImpulse()
const
821 NP_READ_CHECK(RigidActorTemplateClass::getNpScene());
822 return mCore.getMaxContactImpulse();
825template<
class APIClass>
826void NpRigidBodyTemplate<APIClass>::setContactSlopCoefficient(
const PxReal contactSlopCoefficient)
828 NpScene* npScene = RigidActorTemplateClass::getNpScene();
829 NP_WRITE_CHECK(npScene);
830 PX_CHECK_AND_RETURN(contactSlopCoefficient >= 0.f,
"PxRigidBody::setContactSlopCoefficient(): contact slop coefficientmust be greater than or equal to zero.");
832 PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene,
"PxRigidBody::setContactSlopCoefficient() not allowed while simulation is running. Call will be ignored.")
834 mCore.setOffsetSlop(contactSlopCoefficient);
835 UPDATE_PVD_PROPERTY_BODY
836#if PX_SUPPORT_OMNI_PVD
837 PxActor* actor =
static_cast<PxActor*
>(
this);
838 OMNI_PVD_SET(actor, contactSlopCoefficient, *actor, contactSlopCoefficient)
842template<
class APIClass>
843PxReal NpRigidBodyTemplate<APIClass>::getContactSlopCoefficient()
const
845 NP_READ_CHECK(RigidActorTemplateClass::getNpScene());
846 return mCore.getOffsetSlop();
849template<
class APIClass>
850PxNodeIndex NpRigidBodyTemplate<APIClass>::getInternalIslandNodeIndex()
const
852 NP_READ_CHECK(RigidActorTemplateClass::getNpScene());
853 return mCore.getInternalIslandNodeIndex();
856template<
class APIClass>
857void NpRigidBodyTemplate<APIClass>::setLinearDamping(PxReal linearDamping)
859 NpScene* npScene = RigidActorTemplateClass::getNpScene();
860 NP_WRITE_CHECK(npScene);
861 PX_CHECK_AND_RETURN(
PxIsFinite(linearDamping),
"PxRigidBody::setLinearDamping(): invalid float");
862 PX_CHECK_AND_RETURN(linearDamping >= 0,
"PxRigidBody::setLinearDamping(): The linear damping must be nonnegative!");
864 PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene,
"PxRigidBody::setLinearDamping() not allowed while simulation is running. Call will be ignored.")
866 mCore.setLinearDamping(linearDamping);
867 UPDATE_PVD_PROPERTY_BODY
868#if PX_SUPPORT_OMNI_PVD
869 PxActor* actor =
static_cast<PxActor*
>(
this);
870 OMNI_PVD_SET(actor, linearDamping, *actor, linearDamping)
874template<
class APIClass>
875PxReal NpRigidBodyTemplate<APIClass>::getLinearDamping()
const
877 NP_READ_CHECK(RigidActorTemplateClass::getNpScene());
879 return mCore.getLinearDamping();
882template<
class APIClass>
883void NpRigidBodyTemplate<APIClass>::setAngularDamping(PxReal angularDamping)
885 NpScene* npScene = RigidActorTemplateClass::getNpScene();
886 NP_WRITE_CHECK(npScene);
887 PX_CHECK_AND_RETURN(
PxIsFinite(angularDamping),
"PxRigidBody::setAngularDamping(): invalid float");
888 PX_CHECK_AND_RETURN(angularDamping>=0,
"PxRigidBody::setAngularDamping(): The angular damping must be nonnegative!")
890 PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxRigidBody::setAngularDamping() not allowed while simulation is running. Call will be ignored.")
892 mCore.setAngularDamping(angularDamping);
893 UPDATE_PVD_PROPERTY_BODY
894#if PX_SUPPORT_OMNI_PVD
895 PxActor* actor =
static_cast<PxActor*
>(
this);
896 OMNI_PVD_SET(actor, angularDamping, *actor, angularDamping)
900template<
class APIClass>
901PxReal NpRigidBodyTemplate<APIClass>::getAngularDamping()
const
903 NP_READ_CHECK(RigidActorTemplateClass::getNpScene());
905 return mCore.getAngularDamping();
908template<
class APIClass>
909void NpRigidBodyTemplate<APIClass>::setMaxAngularVelocity(PxReal maxAngularVelocity)
911 NpScene* npScene = RigidActorTemplateClass::getNpScene();
912 NP_WRITE_CHECK(npScene);
913 PX_CHECK_AND_RETURN(
PxIsFinite(maxAngularVelocity),
"PxRigidBody::setMaxAngularVelocity(): invalid float");
914 PX_CHECK_AND_RETURN(maxAngularVelocity>=0.0f,
"PxRigidBody::setMaxAngularVelocity(): threshold must be non-negative!");
916 PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene,
"PxRigidBody::setMaxAngularVelocity() not allowed while simulation is running. Call will be ignored.")
918 mCore.setMaxAngVelSq(maxAngularVelocity * maxAngularVelocity);
919 UPDATE_PVD_PROPERTY_BODY
920#if PX_SUPPORT_OMNI_PVD
921 PxActor* actor =
static_cast<PxActor*
>(
this);
922 OMNI_PVD_SET(actor, maxAngularVelocity, *actor, maxAngularVelocity)
926template<
class APIClass>
927PxReal NpRigidBodyTemplate<APIClass>::getMaxAngularVelocity()
const
929 NP_READ_CHECK(RigidActorTemplateClass::getNpScene());
931 return PxSqrt(mCore.getMaxAngVelSq());
934template<
class APIClass>
935void NpRigidBodyTemplate<APIClass>::setMaxLinearVelocity(PxReal maxLinearVelocity)
937 NpScene* npScene = RigidActorTemplateClass::getNpScene();
938 NP_WRITE_CHECK(npScene);
939 PX_CHECK_AND_RETURN(
PxIsFinite(maxLinearVelocity),
"PxRigidBody::setMaxLinearVelocity(): invalid float");
940 PX_CHECK_AND_RETURN(maxLinearVelocity >= 0.0f,
"PxRigidBody::setMaxLinearVelocity(): threshold must be non-negative!");
942 PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene,
"PxRigidBody::setMaxLinearVelocity() not allowed while simulation is running. Call will be ignored.")
944 mCore.setMaxLinVelSq(maxLinearVelocity * maxLinearVelocity);
945 UPDATE_PVD_PROPERTY_BODY
946#if PX_SUPPORT_OMNI_PVD
947 PxActor* actor =
static_cast<PxActor*
>(
this);
948 OMNI_PVD_SET(actor, maxLinearVelocity, *actor, maxLinearVelocity)
952template<
class APIClass>
953PxReal NpRigidBodyTemplate<APIClass>::getMaxLinearVelocity()
const
955 NP_READ_CHECK(RigidActorTemplateClass::getNpScene());
957 return PxSqrt(mCore.getMaxLinVelSq());
Definition NpRigidActorTemplate.h:47
Definition NpRigidBodyTemplate.h:80
A padded version of PxMat33, to safely load its data using SIMD.
Definition PxSIMDHelpers.h:41
3x3 matrix class
Definition PxMat33.h:91
PxNodeIndex.
Definition PxNodeIndex.h:51
Definition PxRenderOutput.h:50
Abstract class for collision shapes.
Definition PxShape.h:146
virtual const PxGeometry & getGeometry() const =0
Retrieve a reference to the shape's geometry.
PX_DEPRECATED PX_FORCE_INLINE PxGeometryType::Enum getGeometryType() const
Get the geometry type of the shape.
Definition PxShape.h:192
virtual PxShapeFlags getFlags() const =0
Retrieves shape flags.
3 Element vector class.
Definition PxVec3.h:50
Definition ScBodyCore.h:49
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
#define PX_OVERRIDE
Definition PxPreprocessor.h:375
PX_C_EXPORT PX_FOUNDATION_API physx::PxFoundation &PX_CALL_CONV PxGetFoundation()
Retrieves the Foundation SDK after it has been created.
Definition FdFoundation.cpp:279
#define PX_INLINE
Definition PxPreprocessor.h:320
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PX_CUDA_CALLABLE PX_FORCE_INLINE float PxAbs(float a)
abs returns the absolute value of its argument.
Definition PxMath.h:109
PX_CUDA_CALLABLE PX_FORCE_INLINE bool PxIsFinite(float f)
returns true if the passed number is a finite floating point number as opposed to INF,...
Definition PxMath.h:326
PX_CUDA_CALLABLE PX_FORCE_INLINE float PxSqrt(float a)
Square root.
Definition PxMath.h:146
PxFlags< PxRigidBodyFlag::Enum, PxU16 > PxRigidBodyFlags
collection of set bits defined in PxRigidBodyFlag.
Definition PxRigidBody.h:189
Enum
Definition PxActor.h:121
@ eARTICULATION_LINK
An articulation link.
Definition PxActor.h:138
@ eINVALID_PARAMETER
method called with invalid parameter(s)
Definition PxErrors.h:62
Enum
Definition PxForceMode.h:51
@ eFORCE
parameter has unit of mass * length / time^2, i.e., a force
Definition PxForceMode.h:52
@ eVELOCITY_CHANGE
parameter has unit of length / time, i.e., the effect is mass independent: a velocity change.
Definition PxForceMode.h:54
@ eIMPULSE
parameter has unit of mass * length / time, i.e., force * time
Definition PxForceMode.h:53
@ eACCELERATION
parameter has unit of length/ time^2, i.e., an acceleration. It gets treated just like a force except...
Definition PxForceMode.h:55
Enum
Definition PxGeometry.h:52
Collection of flags describing the behavior of a rigid body.
Definition PxRigidBody.h:50
Enum
Definition PxRigidBody.h:52
@ eUSE_KINEMATIC_TARGET_FOR_SCENE_QUERIES
Use the kinematic target transform for scene queries.
Definition PxRigidBody.h:85
@ eKINEMATIC
Enables kinematic mode for the actor.
Definition PxRigidBody.h:74
@ eENABLE_CCD
Enables swept integration for the actor.
Definition PxRigidBody.h:96
@ eSIMULATION_SHAPE
The shape will partake in collision in the physical simulation.
Definition PxShape.h:83