file_path
stringlengths
20
202
content
stringlengths
9
3.85M
size
int64
9
3.85M
lang
stringclasses
9 values
avg_line_length
float64
3.33
100
max_line_length
int64
8
993
alphanum_fraction
float64
0.26
0.93
NVIDIA-Omniverse/PhysX/physx/include/foundation/windows/PxWindowsAoS.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_WINDOWS_AOS_H #define PX_WINDOWS_AOS_H // no includes here! this file should be included from PxAOS.h only!!! #if !COMPILE_VECTOR_INTRINSICS #error Vector intrinsics should not be included when using scalar implementation. #endif #if !PX_DOXYGEN namespace physx { #endif namespace aos { typedef __m128 FloatV; typedef __m128 Vec3V; typedef __m128 Vec4V; typedef __m128 BoolV; typedef __m128 VecU32V; typedef __m128 VecI32V; typedef __m128 VecU16V; typedef __m128 VecI16V; typedef __m128 QuatV; #define FloatVArg FloatV & #define Vec3VArg Vec3V & #define Vec4VArg Vec4V & #define BoolVArg BoolV & #define VecU32VArg VecU32V & #define VecI32VArg VecI32V & #define VecU16VArg VecU16V & #define VecI16VArg VecI16V & #define QuatVArg QuatV & // Optimization for situations in which you cross product multiple vectors with the same vector. // Avoids 2X shuffles per product struct VecCrossV { Vec3V mL1; Vec3V mR1; }; struct VecShiftV { VecI32V shift; }; #define VecShiftVArg VecShiftV & PX_ALIGN_PREFIX(16) struct Mat33V { Mat33V() { } Mat33V(const Vec3V& c0, const Vec3V& c1, const Vec3V& c2) : col0(c0), col1(c1), col2(c2) { } Vec3V PX_ALIGN(16, col0); Vec3V PX_ALIGN(16, col1); Vec3V PX_ALIGN(16, col2); } PX_ALIGN_SUFFIX(16); PX_ALIGN_PREFIX(16) struct Mat34V { Mat34V() { } Mat34V(const Vec3V& c0, const Vec3V& c1, const Vec3V& c2, const Vec3V& c3) : col0(c0), col1(c1), col2(c2), col3(c3) { } Vec3V PX_ALIGN(16, col0); Vec3V PX_ALIGN(16, col1); Vec3V PX_ALIGN(16, col2); Vec3V PX_ALIGN(16, col3); } PX_ALIGN_SUFFIX(16); PX_ALIGN_PREFIX(16) struct Mat43V { Mat43V() { } Mat43V(const Vec4V& c0, const Vec4V& c1, const Vec4V& c2) : col0(c0), col1(c1), col2(c2) { } Vec4V PX_ALIGN(16, col0); Vec4V PX_ALIGN(16, col1); Vec4V PX_ALIGN(16, col2); } PX_ALIGN_SUFFIX(16); PX_ALIGN_PREFIX(16) struct Mat44V { Mat44V() { } Mat44V(const Vec4V& c0, const Vec4V& c1, const Vec4V& c2, const Vec4V& c3) : col0(c0), col1(c1), col2(c2), col3(c3) { } Vec4V PX_ALIGN(16, col0); Vec4V PX_ALIGN(16, col1); Vec4V PX_ALIGN(16, col2); Vec4V PX_ALIGN(16, col3); } PX_ALIGN_SUFFIX(16); } // namespace aos #if !PX_DOXYGEN } // namespace physx #endif #endif
3,892
C
26.034722
116
0.72739
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxDefaultSimulationFilterShader.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_DEFAULT_SIMULATION_FILTER_SHADER_H #define PX_DEFAULT_SIMULATION_FILTER_SHADER_H /** \addtogroup extensions @{ */ #include "PxPhysXConfig.h" #include "PxFiltering.h" #if !PX_DOXYGEN namespace physx { #endif class PxActor; /** \brief 64-bit mask used for collision filtering. The collision filtering equation for 2 objects o0 and o1 is: <pre> (G0 op0 K0) op2 (G1 op1 K1) == b </pre> with <ul> <li> G0 = PxGroupsMask for object o0. See PxSetGroupsMask </li> <li> G1 = PxGroupsMask for object o1. See PxSetGroupsMask </li> <li> K0 = filtering constant 0. See PxSetFilterConstants </li> <li> K1 = filtering constant 1. See PxSetFilterConstants </li> <li> b = filtering boolean. See PxSetFilterBool </li> <li> op0, op1, op2 = filtering operations. See PxSetFilterOps </li> </ul> If the filtering equation is true, collision detection is enabled. @see PxSetFilterOps() */ class PxGroupsMask { public: PX_INLINE PxGroupsMask():bits0(0),bits1(0),bits2(0),bits3(0) {} PX_INLINE ~PxGroupsMask() {} PxU16 bits0, bits1, bits2, bits3; }; /** \brief Collision filtering operations. @see PxGroupsMask */ struct PxFilterOp { enum Enum { PX_FILTEROP_AND, PX_FILTEROP_OR, PX_FILTEROP_XOR, PX_FILTEROP_NAND, PX_FILTEROP_NOR, PX_FILTEROP_NXOR, PX_FILTEROP_SWAP_AND }; }; /** \brief Implementation of a simple filter shader that emulates PhysX 2.8.x filtering This shader provides the following logic: \li If one of the two filter objects is a trigger, the pair is acccepted and #PxPairFlag::eTRIGGER_DEFAULT will be used for trigger reports \li Else, if the filter mask logic (see further below) discards the pair it will be suppressed (#PxFilterFlag::eSUPPRESS) \li Else, the pair gets accepted and collision response gets enabled (#PxPairFlag::eCONTACT_DEFAULT) Filter mask logic: Given the two #PxFilterData structures fd0 and fd1 of two collision objects, the pair passes the filter if the following conditions are met: 1) Collision groups of the pair are enabled 2) Collision filtering equation is satisfied @see PxSimulationFilterShader */ PxFilterFlags PxDefaultSimulationFilterShader( PxFilterObjectAttributes attributes0, PxFilterData filterData0, PxFilterObjectAttributes attributes1, PxFilterData filterData1, PxPairFlags& pairFlags, const void* constantBlock, PxU32 constantBlockSize); /** \brief Determines if collision detection is performed between a pair of groups \note Collision group is an integer between 0 and 31. \param[in] group1 First Group \param[in] group2 Second Group \return True if the groups could collide @see PxSetGroupCollisionFlag */ bool PxGetGroupCollisionFlag(const PxU16 group1, const PxU16 group2); /** \brief Specifies if collision should be performed by a pair of groups \note Collision group is an integer between 0 and 31. \param[in] group1 First Group \param[in] group2 Second Group \param[in] enable True to enable collision between the groups @see PxGetGroupCollisionFlag */ void PxSetGroupCollisionFlag(const PxU16 group1, const PxU16 group2, const bool enable); /** \brief Retrieves the value set with PxSetGroup() \note Collision group is an integer between 0 and 31. \param[in] actor The actor \return The collision group this actor belongs to @see PxSetGroup */ PxU16 PxGetGroup(const PxActor& actor); /** \brief Sets which collision group this actor is part of \note Collision group is an integer between 0 and 31. \param[in] actor The actor \param[in] collisionGroup Collision group this actor belongs to @see PxGetGroup */ void PxSetGroup(PxActor& actor, const PxU16 collisionGroup); /** \brief Retrieves filtering operation. See comments for PxGroupsMask \param[out] op0 First filter operator. \param[out] op1 Second filter operator. \param[out] op2 Third filter operator. @see PxSetFilterOps PxSetFilterBool PxSetFilterConstants */ void PxGetFilterOps(PxFilterOp::Enum& op0, PxFilterOp::Enum& op1, PxFilterOp::Enum& op2); /** \brief Setups filtering operations. See comments for PxGroupsMask \param[in] op0 Filter op 0. \param[in] op1 Filter op 1. \param[in] op2 Filter op 2. @see PxSetFilterBool PxSetFilterConstants */ void PxSetFilterOps(const PxFilterOp::Enum& op0, const PxFilterOp::Enum& op1, const PxFilterOp::Enum& op2); /** \brief Retrieves filtering's boolean value. See comments for PxGroupsMask \return flag Boolean value for filter. @see PxSetFilterBool PxSetFilterConstants */ bool PxGetFilterBool(); /** \brief Setups filtering's boolean value. See comments for PxGroupsMask \param[in] enable Boolean value for filter. @see PxSetFilterOps PxSsetFilterConstants */ void PxSetFilterBool(const bool enable); /** \brief Gets filtering constant K0 and K1. See comments for PxGroupsMask \param[out] c0 the filtering constants, as a mask. See #PxGroupsMask. \param[out] c1 the filtering constants, as a mask. See #PxGroupsMask. @see PxSetFilterOps PxSetFilterBool PxSetFilterConstants */ void PxGetFilterConstants(PxGroupsMask& c0, PxGroupsMask& c1); /** \brief Setups filtering's K0 and K1 value. See comments for PxGroupsMask \param[in] c0 The new group mask. See #PxGroupsMask. \param[in] c1 The new group mask. See #PxGroupsMask. @see PxSetFilterOps PxSetFilterBool PxGetFilterConstants */ void PxSetFilterConstants(const PxGroupsMask& c0, const PxGroupsMask& c1); /** \brief Gets 64-bit mask used for collision filtering. See comments for PxGroupsMask \param[in] actor The actor \return The group mask for the actor. @see PxSetGroupsMask() */ PxGroupsMask PxGetGroupsMask(const PxActor& actor); /** \brief Sets 64-bit mask used for collision filtering. See comments for PxGroupsMask \param[in] actor The actor \param[in] mask The group mask to set for the actor. @see PxGetGroupsMask() */ void PxSetGroupsMask(PxActor& actor, const PxGroupsMask& mask); #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
7,594
C
27.98855
139
0.764288
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxRackAndPinionJoint.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_RACK_AND_PINION_JOINT_H #define PX_RACK_AND_PINION_JOINT_H /** \addtogroup extensions @{ */ #include "extensions/PxJoint.h" #if !PX_DOXYGEN namespace physx { #endif class PxRackAndPinionJoint; /** \brief Create a rack & pinion Joint. \param[in] physics The physics SDK \param[in] actor0 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame \param[in] localFrame0 The position and orientation of the joint relative to actor0 \param[in] actor1 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame \param[in] localFrame1 The position and orientation of the joint relative to actor1 @see PxRackAndPinionJoint */ PxRackAndPinionJoint* PxRackAndPinionJointCreate(PxPhysics& physics, PxRigidActor* actor0, const PxTransform& localFrame0, PxRigidActor* actor1, const PxTransform& localFrame1); /** \brief A joint that connects an existing revolute joint to an existing prismatic joint, and constrains their relative angular/linear velocity and position with respect to each other. @see PxRackAndPinionJointCreate PxJoint */ class PxRackAndPinionJoint : public PxJoint { public: /** \brief Set the hinge & prismatic joints connected by the rack & pinion joint. The passed hinge joint can be either PxRevoluteJoint, PxD6Joint or PxArticulationJointReducedCoordinate. The passed prismatic joint can be either PxPrismaticJoint or PxD6Joint. Note that these joints are only used to compute the positional error correction term, used to adjust potential drift between jointed actors. The rack & pinion joint can run without calling this function, but in that case some visible overlap may develop over time between the teeth of the rack & pinion meshes. \note Calling this function resets the internal positional error correction term. \param[in] hinge The hinge joint (pinion) \param[in] prismatic The prismatic joint (rack) \return true if success */ virtual bool setJoints(const PxBase* hinge, const PxBase* prismatic) = 0; /** \brief Get the hinge & prismatic joints connected by the rack & pinion joint. \param[out] hinge The hinge joint (pinion) \param[out] prismatic The prismatic joint (rack) */ virtual void getJoints(const PxBase*& hinge, const PxBase*& prismatic) const = 0; /** \brief Set the desired ratio directly. \note You may need to use a negative gear ratio if the joint frames of involved actors are not oriented in the same direction. \note Calling this function resets the internal positional error correction term. \param[in] ratio Desired ratio between the hinge and the prismatic. */ virtual void setRatio(float ratio) = 0; /** \brief Get the ratio. \return Current ratio */ virtual float getRatio() const = 0; /** \brief Set the desired ratio indirectly. This is a simple helper function that computes the ratio from passed data: ratio = (PI*2*nbRackTeeth)/(rackLength*nbPinionTeeth) \note Calling this function resets the internal positional error correction term. \param[in] nbRackTeeth Number of teeth on the rack (cannot be zero) \param[in] nbPinionTeeth Number of teeth on the pinion (cannot be zero) \param[in] rackLength Length of the rack \return true if success */ virtual bool setData(PxU32 nbRackTeeth, PxU32 nbPinionTeeth, float rackLength) = 0; virtual const char* getConcreteTypeName() const { return "PxRackAndPinionJoint"; } protected: PX_INLINE PxRackAndPinionJoint(PxType concreteType, PxBaseFlags baseFlags) : PxJoint(concreteType, baseFlags) {} PX_INLINE PxRackAndPinionJoint(PxBaseFlags baseFlags) : PxJoint(baseFlags) {} virtual bool isKindOf(const char* name) const { PX_IS_KIND_OF(name, "PxRackAndPinionJoint", PxJoint); } }; #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
5,631
C
37.841379
178
0.755994
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxSphericalJoint.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_SPHERICAL_JOINT_H #define PX_SPHERICAL_JOINT_H /** \addtogroup extensions @{ */ #include "extensions/PxJoint.h" #include "extensions/PxJointLimit.h" #if !PX_DOXYGEN namespace physx { #endif class PxSphericalJoint; /** \brief Create a spherical joint. \param[in] physics The physics SDK \param[in] actor0 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame \param[in] localFrame0 The position and orientation of the joint relative to actor0 \param[in] actor1 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame \param[in] localFrame1 The position and orientation of the joint relative to actor1 @see PxSphericalJoint */ PxSphericalJoint* PxSphericalJointCreate(PxPhysics& physics, PxRigidActor* actor0, const PxTransform& localFrame0, PxRigidActor* actor1, const PxTransform& localFrame1); /** \brief Flags specific to the spherical joint. @see PxSphericalJoint */ struct PxSphericalJointFlag { enum Enum { eLIMIT_ENABLED = 1<<1 //!< the cone limit for the spherical joint is enabled }; }; typedef PxFlags<PxSphericalJointFlag::Enum, PxU16> PxSphericalJointFlags; PX_FLAGS_OPERATORS(PxSphericalJointFlag::Enum, PxU16) /** \brief A joint which behaves in a similar way to a ball and socket. A spherical joint removes all linear degrees of freedom from two objects. The position of the joint on each actor is specified by the origin of the body's joint frame. A spherical joint may have a cone limit, to restrict the motion to within a certain range. In addition, the bodies may be projected together if the distance between them exceeds a given threshold. Projection, drive and limits are activated by setting the appropriate flags on the joint. @see PxRevoluteJointCreate() PxJoint */ class PxSphericalJoint : public PxJoint { public: /** \brief Set the limit cone. If enabled, the limit cone will constrain the angular movement of the joint to lie within an elliptical cone. \return the limit cone @see PxJointLimitCone setLimit() */ virtual PxJointLimitCone getLimitCone() const = 0; /** \brief Get the limit cone. \param[in] limit the limit cone @see PxJointLimitCone getLimit() */ virtual void setLimitCone(const PxJointLimitCone& limit) = 0; /** \brief get the swing angle of the joint from the Y axis */ virtual PxReal getSwingYAngle() const = 0; /** \brief get the swing angle of the joint from the Z axis */ virtual PxReal getSwingZAngle() const = 0; /** \brief Set the flags specific to the Spherical Joint. <b>Default</b> PxSphericalJointFlags(0) \param[in] flags The joint flags. @see PxSphericalJointFlag setFlag() getFlags() */ virtual void setSphericalJointFlags(PxSphericalJointFlags flags) = 0; /** \brief Set a single flag specific to a Spherical Joint to true or false. \param[in] flag The flag to set or clear. \param[in] value the value to which to set the flag @see PxSphericalJointFlag, getFlags() setFlags() */ virtual void setSphericalJointFlag(PxSphericalJointFlag::Enum flag, bool value) = 0; /** \brief Get the flags specific to the Spherical Joint. \return the joint flags @see PxSphericalJoint::flags, PxSphericalJointFlag setFlag() setFlags() */ virtual PxSphericalJointFlags getSphericalJointFlags() const = 0; /** \brief Returns string name of PxSphericalJoint, used for serialization */ virtual const char* getConcreteTypeName() const { return "PxSphericalJoint"; } protected: //serialization /** \brief Constructor */ PX_INLINE PxSphericalJoint(PxType concreteType, PxBaseFlags baseFlags) : PxJoint(concreteType, baseFlags) {} /** \brief Deserialization constructor */ PX_INLINE PxSphericalJoint(PxBaseFlags baseFlags) : PxJoint(baseFlags) {} /** \brief Returns whether a given type name matches with the type of this instance */ virtual bool isKindOf(const char* name) const { PX_IS_KIND_OF(name, "PxSphericalJoint", PxJoint); } //~serialization }; #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
5,841
C
30.408602
169
0.751241
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxShapeExt.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_SHAPE_EXT_H #define PX_SHAPE_EXT_H /** \addtogroup extensions @{ */ #include "PxPhysXConfig.h" #include "PxShape.h" #include "PxRigidActor.h" #include "geometry/PxGeometryQuery.h" #include "PxQueryReport.h" #if !PX_DOXYGEN namespace physx { #endif /** \brief utility functions for use with PxShape @see PxShape */ class PxShapeExt { public: /** \brief Retrieves the world space pose of the shape. \param[in] shape The shape for which to get the global pose. \param[in] actor The actor to which the shape is attached \return Global pose of shape. */ static PX_INLINE PxTransform getGlobalPose(const PxShape& shape, const PxRigidActor& actor) { // PT:: tag: scalar transform*transform return actor.getGlobalPose() * shape.getLocalPose(); } /** \brief Raycast test against the shape. \param[in] shape the shape \param[in] actor the actor to which the shape is attached \param[in] rayOrigin The origin of the ray to test the geometry object against \param[in] rayDir The direction of the ray to test the geometry object against \param[in] maxDist Maximum ray length \param[in] hitFlags Specify which properties per hit should be computed and written to result hit array. Combination of #PxHitFlag flags \param[in] maxHits max number of returned hits = size of 'rayHits' buffer \param[out] rayHits Raycast hits information \return Number of hits between the ray and the shape @see PxRaycastHit PxTransform */ static PX_INLINE PxU32 raycast(const PxShape& shape, const PxRigidActor& actor, const PxVec3& rayOrigin, const PxVec3& rayDir, PxReal maxDist, PxHitFlags hitFlags, PxU32 maxHits, PxRaycastHit* rayHits) { return PxGeometryQuery::raycast( rayOrigin, rayDir, shape.getGeometry(), getGlobalPose(shape, actor), maxDist, hitFlags, maxHits, rayHits); } /** \brief Test overlap between the shape and a geometry object \param[in] shape the shape \param[in] actor the actor to which the shape is attached \param[in] otherGeom The other geometry object to test overlap with \param[in] otherGeomPose Pose of the other geometry object \return True if the shape overlaps the geometry object @see PxGeometry PxTransform */ static PX_INLINE bool overlap(const PxShape& shape, const PxRigidActor& actor, const PxGeometry& otherGeom, const PxTransform& otherGeomPose) { return PxGeometryQuery::overlap(shape.getGeometry(), getGlobalPose(shape, actor), otherGeom, otherGeomPose); } /** \brief Sweep a geometry object against the shape. Currently only box, sphere, capsule and convex mesh shapes are supported, i.e. the swept geometry object must be one of those types. \param[in] shape the shape \param[in] actor the actor to which the shape is attached \param[in] unitDir Normalized direction along which the geometry object should be swept. \param[in] distance Sweep distance. Needs to be larger than 0. \param[in] otherGeom The geometry object to sweep against the shape \param[in] otherGeomPose Pose of the geometry object \param[out] sweepHit The sweep hit information. Only valid if this method returns true. \param[in] hitFlags Specify which properties per hit should be computed and written to result hit array. Combination of #PxHitFlag flags \return True if the swept geometry object hits the shape @see PxGeometry PxTransform PxSweepHit */ static PX_INLINE bool sweep(const PxShape& shape, const PxRigidActor& actor, const PxVec3& unitDir, const PxReal distance, const PxGeometry& otherGeom, const PxTransform& otherGeomPose, PxSweepHit& sweepHit, PxHitFlags hitFlags) { return PxGeometryQuery::sweep(unitDir, distance, otherGeom, otherGeomPose, shape.getGeometry(), getGlobalPose(shape, actor), sweepHit, hitFlags); } /** \brief Retrieves the axis aligned bounding box enclosing the shape. \return The shape's bounding box. \param[in] shape the shape \param[in] actor the actor to which the shape is attached \param[in] inflation Scale factor for computed world bounds. Box extents are multiplied by this value. @see PxBounds3 */ static PX_INLINE PxBounds3 getWorldBounds(const PxShape& shape, const PxRigidActor& actor, float inflation=1.01f) { PxBounds3 bounds; PxGeometryQuery::computeGeomBounds(bounds, shape.getGeometry(), getGlobalPose(shape, actor), 0.0f, inflation); return bounds; } }; #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
6,147
C
37.425
147
0.75484
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxParticleExt.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_PARTICLE_EXT_H #define PX_PARTICLE_EXT_H /** \addtogroup extensions @{ */ #include "PxParticleSystem.h" #include "PxParticleBuffer.h" #include "foundation/PxArray.h" #include "foundation/PxHashMap.h" #include "foundation/PxUserAllocated.h" #include "PxAttachment.h" #if !PX_DOXYGEN namespace physx { #endif namespace ExtGpu { /** \brief Structure to define user-defined particle state when constructing a new particle system. */ struct PxParticleBufferDesc { PxVec4* positions; PxVec4* velocities; PxU32* phases; PxParticleVolume* volumes; PxU32 numActiveParticles; PxU32 maxParticles; PxU32 numVolumes; PxU32 maxVolumes; PxParticleBufferDesc() : positions(NULL), velocities(NULL), phases(NULL), volumes(NULL), numActiveParticles(0), maxParticles(0), numVolumes(0), maxVolumes(0) { } }; /** \brief Structure to define user-defined particle state when constructing a new particle system that includes diffuse particles. */ struct PxParticleAndDiffuseBufferDesc : public PxParticleBufferDesc { PxDiffuseParticleParams diffuseParams; PxU32 maxDiffuseParticles; PxU32 maxActiveDiffuseParticles; PxParticleAndDiffuseBufferDesc() : PxParticleBufferDesc() { } }; /** \brief Structure to define user-defined particle state when constructing a new particle system that includes shape-matched rigid bodies. */ struct PxParticleRigidDesc { PxParticleRigidDesc() : rigidOffsets(NULL), rigidCoefficients(NULL), rigidTranslations(NULL), rigidRotations(NULL), rigidLocalPositions(NULL), rigidLocalNormals(NULL), maxRigids(0), numActiveRigids(0) { } PxU32* rigidOffsets; PxReal* rigidCoefficients; PxVec4* rigidTranslations; PxQuat* rigidRotations; PxVec4* rigidLocalPositions; PxVec4* rigidLocalNormals; PxU32 maxRigids; PxU32 numActiveRigids; }; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** \brief Helper class to manage PxParticleClothDesc buffers used for communicating particle based cloths to PxParticleClothBuffer. */ class PxParticleClothBufferHelper { public: virtual void release() = 0; virtual PxU32 getMaxCloths() const = 0; //!< \return The maximum number of cloths this PxParticleClothBufferHelper can hold. virtual PxU32 getNumCloths() const = 0; //!< \return The current number of cloths in this PxParticleClothBufferHelper. virtual PxU32 getMaxSprings() const = 0; //!< \return The maximum number of springs this PxParticleClothBufferHelper can hold. virtual PxU32 getNumSprings() const = 0; //!< \return The current number of springs in this PxParticleClothBufferHelper. virtual PxU32 getMaxTriangles() const = 0; //!< \return The maximum number of triangles this PxParticleClothBufferHelper can hold. virtual PxU32 getNumTriangles() const = 0; //!< \return The current number of triangles in this PxParticleClothBufferHelper. virtual PxU32 getMaxParticles() const = 0; //!< \return The maximum number of particles this PxParticleClothBufferHelper can hold. virtual PxU32 getNumParticles() const = 0; //!< \return The current number of particles in this PxParticleClothBufferHelper. /** \brief Adds a PxParticleCloth to this PxParticleClothBufferHelper instance. \param[in] particleCloth The PxParticleCloth to be added. \param[in] triangles A pointer to the triangles \param[in] numTriangles The number of triangles \param[in] springs A pointer to the springs \param[in] numSprings The number of springs \param[in] restPositions A pointer to the particle rest positions \param[in] numParticles The number of particles in this cloth @see PxParticleCloth PxParticleSpring */ virtual void addCloth(const PxParticleCloth& particleCloth, const PxU32* triangles, const PxU32 numTriangles, const PxParticleSpring* springs, const PxU32 numSprings, const PxVec4* restPositions, const PxU32 numParticles) = 0; /** \brief Adds a cloth to this PxParticleClothBufferHelper instance. Adds a cloth to this PxParticleClothBufferHelper instance. With this method the relevant parameters for inflatable simulation (restVolume, pressure) can be set directly. \param[in] blendScale This should be 1.f / (numPartitions + 1) if the springs are partitioned by the user. Otherwise this will be set during spring partitioning. \param[in] restVolume The rest volume of the inflatable \param[in] pressure The pressure of the inflatable. The target inflatable volume is defined as restVolume * pressure. Setting this to > 0.0 will enable inflatable simulation. \param[in] triangles A pointer to the triangles \param[in] numTriangles The number of triangles \param[in] springs A pointer to the springs \param[in] numSprings The number of springs \param[in] restPositions A pointer to the particle rest positions \param[in] numParticles The number of particles in this cloth @see PxParticleSpring */ virtual void addCloth(const PxReal blendScale, const PxReal restVolume, const PxReal pressure, const PxU32* triangles, const PxU32 numTriangles, const PxParticleSpring* springs, const PxU32 numSprings, const PxVec4* restPositions, const PxU32 numParticles) = 0; /** \brief Returns a PxParticleClothDesc for this PxParticleClothBufferHelper instance to be used for spring partitioning. \return the PxParticleClothDesc. @see PxCreateAndPopulateParticleClothBuffer, PxParticleClothPreProcessor::partitionSprings */ virtual PxParticleClothDesc& getParticleClothDesc() = 0; protected: virtual ~PxParticleClothBufferHelper() {} }; /** \brief Helper struct that holds information about a specific mesh in a PxParticleVolumeBufferHelper. */ struct PxParticleVolumeMesh { PxU32 startIndex; //!< The index of the first triangle of this mesh in the triangle array of the PxParticleVolumeBufferHelper instance. PxU32 count; //!< The number of triangles of this mesh. }; /** \brief Helper class to manage communicating PxParticleVolumes data to PxParticleBuffer. */ class PxParticleVolumeBufferHelper { public: virtual void release() = 0; virtual PxU32 getMaxVolumes() const = 0; //!< \return The maximum number of PxParticleVolume this PxParticleVolumeBufferHelper instance can hold. virtual PxU32 getNumVolumes() const = 0; //!< \return The current number of PxParticleVolume in this PxParticleVolumeBufferHelper instance. virtual PxU32 getMaxTriangles() const = 0; //!< \return The maximum number of triangles this PxParticleVolumeBufferHelper instance can hold. virtual PxU32 getNumTriangles() const = 0; //!< \return The current number of triangles in this PxParticleVolumeBufferHelper instance. virtual PxParticleVolume* getParticleVolumes() = 0; //!< \return A pointer to the PxParticleVolume s of this PxParticleVolumeBufferHelper instance. virtual PxParticleVolumeMesh* getParticleVolumeMeshes() = 0; //!< \return A pointer to the PxParticleVolumeMesh structs describing the PxParticleVolumes of this PxParticleVolumeBufferHelper instance. virtual PxU32* getTriangles() = 0; //!< \return A pointer to the triangle indices in this PxParticleVolumeBufferHelper instance. /** \brief Adds a PxParticleVolume with a PxParticleVolumeMesh \param[in] volume The PxParticleVolume to be added. \param[in] volumeMesh A PxParticleVolumeMesh that describes the volumes to be added. startIndex is the index into the triangle list of the PxParticleVolumeBufferHelper instance. \param[in] triangles A pointer to the triangle indices of the PxParticleVolume to be added. \param[in] numTriangles The number of triangles of the PxParticleVolume to be added. */ virtual void addVolume(const PxParticleVolume& volume, const PxParticleVolumeMesh& volumeMesh, const PxU32* triangles, const PxU32 numTriangles) = 0; /** \brief Adds a volume \param[in] particleOffset The index of the first particle of the cloth that maps to this volume in the PxParticleClothBufferHelper instance. \param[in] numParticles The number of particles of the cloth that maps to this volume in the PxParticleClothBufferHelper instance. \param[in] triangles A pointer to the triangle indices of this volume. \param[in] numTriangles The number of triangles in this volume. */ virtual void addVolume(const PxU32 particleOffset, const PxU32 numParticles, const PxU32* triangles, const PxU32 numTriangles) = 0; protected: virtual ~PxParticleVolumeBufferHelper() {} }; /** \brief Helper class to manage PxParticleRigidDesc buffers used for communicating particle based rigids to PxPaticleSystem. */ class PxParticleRigidBufferHelper { public: virtual void release() = 0; virtual PxU32 getMaxRigids() const = 0; //!< \return The maximum number of rigids this PxParticleRigidBufferHelper instance can hold. virtual PxU32 getNumRigids() const = 0; //!< \return The current number of rigids in this PxParticleRigidBufferHelper instance. virtual PxU32 getMaxParticles() const = 0; //!< \return The maximum number of particles this PxParticleRigidBufferHelper instance can hold. virtual PxU32 getNumParticles() const = 0; //!< \return The current number of particles in this PxParticleRigidBufferHelper instance. /** \brief Adds a rigid. \param[in] translation The world-space location of the rigid. \param[in] rotation The world-space rotation of the rigid. \param[in] coefficient The stiffness of the rigid. \param[in] localPositions The particle positions in local space. \param[in] localNormals The surface normal for all the particles in local space. Each PxVec4 has the normal in the first 3 components and the SDF in the last component. \param[in] numParticles The number of particles in this rigid. */ virtual void addRigid(const PxVec3& translation, const PxQuat& rotation, const PxReal coefficient, const PxVec4* localPositions, const PxVec4* localNormals, PxU32 numParticles) = 0; /** \brief Get the PxParticleRigidDesc for this buffer. \returns A PxParticleRigidDesc. */ virtual PxParticleRigidDesc& getParticleRigidDesc() = 0; protected: virtual ~PxParticleRigidBufferHelper() {} }; /////////////////////////////////////////////////////////////////////////////// /** \brief Holds user-defined attachment data to attach particles to other bodies */ class PxParticleAttachmentBuffer : public PxUserAllocated { PxArray<PxParticleRigidAttachment> mAttachments; PxArray<PxParticleRigidFilterPair> mFilters; PxHashMap<PxRigidActor*, PxU32> mReferencedBodies; PxArray<PxRigidActor*> mNewReferencedBodies; PxArray<PxRigidActor*> mDestroyedRefrencedBodies; PxParticleBuffer& mParticleBuffer; PxParticleRigidAttachment* mDeviceAttachments; PxParticleRigidFilterPair* mDeviceFilters; PxU32 mNumDeviceAttachments; PxU32 mNumDeviceFilters; PxCudaContextManager* mCudaContextManager; PxParticleSystem& mParticleSystem; bool mDirty; PX_NOCOPY(PxParticleAttachmentBuffer) public: PxParticleAttachmentBuffer(PxParticleBuffer& particleBuffer, PxParticleSystem& particleSystem); ~PxParticleAttachmentBuffer(); // adds attachment to attachment buffer - localPose is in actor space for attachments to all types of rigids. void addRigidAttachment(PxRigidActor* rigidBody, const PxU32 particleID, const PxVec3& localPose, PxConeLimitedConstraint* coneLimit = NULL); bool removeRigidAttachment(PxRigidActor* rigidBody, const PxU32 particleID); void addRigidFilter(PxRigidActor* rigidBody, const PxU32 particleID); bool removeRigidFilter(PxRigidActor* rigidBody, const PxU32 particleID); void copyToDevice(CUstream stream = 0); }; /** \brief Creates a PxParticleRigidBufferHelper. \param[in] maxRigids The maximum number of rigids this PxParticleRigidsBuffers instance should hold. \param[in] maxParticles The maximum number of particles this PxParticleRigidBufferHelper instance should hold. \param[in] cudaContextManager A pointer to a PxCudaContextManager. \return A pointer to the new PxParticleRigidBufferHelper. */ PxParticleRigidBufferHelper* PxCreateParticleRigidBufferHelper(PxU32 maxRigids, PxU32 maxParticles, PxCudaContextManager* cudaContextManager); /** \brief Creates a PxParticleClothBufferHelper helper. \param[in] maxCloths The maximum number of cloths this PxParticleClothBufferHelper should hold. \param[in] maxTriangles The maximum number of triangles this PxParticleClothBufferHelper should hold. \param[in] maxSprings The maximum number of springs this PxParticleClothBufferHelper should hold. \param[in] maxParticles The maximum number of particles this PxParticleClothBufferHelper should hold. \param[in] cudaContextManager A pointer to a PxCudaContextManager. \return A pointer to the PxParticleClothBufferHelper that was created. */ PxParticleClothBufferHelper* PxCreateParticleClothBufferHelper(const PxU32 maxCloths, const PxU32 maxTriangles, const PxU32 maxSprings, const PxU32 maxParticles, PxCudaContextManager* cudaContextManager); /** \brief Creates a PxParticleVolumeBufferHelper. \param[in] maxVolumes The maximum number of PxParticleVolume s this PxParticleVolumeBufferHelper instance should hold. \param[in] maxTriangles The maximum number of triangles this PxParticleVolumeBufferHelper instance should hold. \param[in] cudaContextManager A pointer to a PxCudaContextManager. \return A pointer to the new PxParticleVolumeBufferHelper. */ PxParticleVolumeBufferHelper* PxCreateParticleVolumeBufferHelper(PxU32 maxVolumes, PxU32 maxTriangles, PxCudaContextManager* cudaContextManager); /** \brief Creates a particle attachment buffer \param[in] particleBuffer The particle buffer that contains particles that should get attached to something \param[in] particleSystem The particle system that is used to simulate the userBuffer \return An attachment buffer ready to use */ PxParticleAttachmentBuffer* PxCreateParticleAttachmentBuffer(PxParticleBuffer& particleBuffer, PxParticleSystem& particleSystem); /** \brief Creates and populates a particle buffer \param[in] desc The particle buffer descriptor \param[in] cudaContextManager A cuda context manager \return A fully populated particle buffer ready to use */ PxParticleBuffer* PxCreateAndPopulateParticleBuffer(const ExtGpu::PxParticleBufferDesc& desc, PxCudaContextManager* cudaContextManager); /** \brief Creates and populates a particle buffer that includes support for diffuse particles \param[in] desc The particle buffer descriptor \param[in] cudaContextManager A cuda context manager \return A fully populated particle buffer ready to use */ PxParticleAndDiffuseBuffer* PxCreateAndPopulateParticleAndDiffuseBuffer(const ExtGpu::PxParticleAndDiffuseBufferDesc& desc, PxCudaContextManager* cudaContextManager); /** \brief Creates and populates a particle cloth buffer \param[in] desc The particle buffer descriptor \param[in] clothDesc The cloth descriptor \param[out] output A cloth output object to further configure the behavior of the cloth \param[in] cudaContextManager A cuda context manager \return A fully populated particle cloth buffer ready to use */ PxParticleClothBuffer* PxCreateAndPopulateParticleClothBuffer(const ExtGpu::PxParticleBufferDesc& desc, const PxParticleClothDesc& clothDesc, PxPartitionedParticleCloth& output, PxCudaContextManager* cudaContextManager); /** \brief Creates and populates a particle rigid buffer. Particle rigids are particles that try to keep their relative positions. They are a bit commpressible similar to softbodies. \param[in] desc The particle buffer descriptor \param[in] rigidDesc The rigid descriptor \param[in] cudaContextManager A cuda context manager \return A fully populated particle rigid buffer ready to use */ PxParticleRigidBuffer* PxCreateAndPopulateParticleRigidBuffer(const ExtGpu::PxParticleBufferDesc& desc, const ExtGpu::PxParticleRigidDesc& rigidDesc, PxCudaContextManager* cudaContextManager); } // namespace ExtGpu #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
17,570
C
43.483544
207
0.787991
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxTetrahedronMeshExt.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_TETRAHEDRON_MESH_EXT_H #define PX_TETRAHEDRON_MESH_EXT_H /** \addtogroup extensions @{ */ #include "foundation/PxVec3.h" #include "foundation/PxArray.h" #if !PX_DOXYGEN namespace physx { #endif class PxTetrahedronMesh; /** \brief utility functions for use with PxTetrahedronMesh and subclasses */ class PxTetrahedronMeshExt { public: /** Returns the index of the tetrahedron that contains a point \param[in] mesh The tetmesh \param[in] point The point to find the enclosing tetrahedron for \param[in] bary The barycentric coordinates of the point inside the enclosing tetrahedron \param[in] tolerance Tolerance value used classify points as inside if they lie exactly a tetrahedron's surface \return The index of the tetrahedon containing the point, -1 if not tetrahedron contains the opoint */ static PxI32 findTetrahedronContainingPoint(const PxTetrahedronMesh* mesh, const PxVec3& point, PxVec4& bary, PxReal tolerance = 1e-6f); /** Returns the index of the tetrahedron closest to a point \param[in] mesh The tetmesh \param[in] point The point to find the closest tetrahedron for \param[out] bary The barycentric coordinates of the point in the tetrahedron \return The index of the tetrahedon closest to the point */ static PxI32 findTetrahedronClosestToPoint(const PxTetrahedronMesh* mesh, const PxVec3& point, PxVec4& bary); /** Associates points with closest tetrahedra from input tetrahedral mesh \param[in] tetMeshVertices The tetrahedral mesh vertices \param[in] tetMeshIndices The tetraheral mesh indices \param[in] pointsToEmbed The points for which the embedding should be created \param[in] barycentricCoordinates The output barycentric coordinates for each input point relative to its closest tetrahedron \param[in] tetLinks The output indices of the closest tetrahedron for each input point */ static void createPointsToTetrahedronMap(const PxArray<PxVec3>& tetMeshVertices, const PxArray<PxU32>& tetMeshIndices, const PxArray<PxVec3>& pointsToEmbed, PxArray<PxVec4>& barycentricCoordinates, PxArray<PxU32>& tetLinks); /** Extracts the surface triangles of a tetmesh The extracted triangle's vertex indices point to the vertex buffer of the tetmesh. \param[in] tetrahedra The tetrahedra indices \param[in] numTetrahedra The number of tetrahedra \param[in] sixteenBitIndices If set to true, the tetrahedra indices are read as 16bit integers, otherwise 32bit integers are used \param[in] surfaceTriangles The resulting surface triangles \param[in] surfaceTriangleToTet Optional array to get the index of a tetrahedron that is adjacent to the surface triangle with the corresponding index \param[in] flipTriangleOrientation Reverses the orientation of the ouput triangles */ static void extractTetMeshSurface(const void* tetrahedra, PxU32 numTetrahedra, bool sixteenBitIndices, PxArray<PxU32>& surfaceTriangles, PxArray<PxU32>* surfaceTriangleToTet = NULL, bool flipTriangleOrientation = false); /** Extracts the surface triangles of a tetmesh The extracted triangle's vertex indices point to the vertex buffer of the tetmesh. \param[in] mesh The mesh from which the surface shall be computed \param[in] surfaceTriangles The resulting surface triangles \param[in] surfaceTriangleToTet Optional array to get the index of a tetrahedron that is adjacent to the surface triangle with the corresponding index \param[in] flipTriangleOrientation Reverses the orientation of the ouput triangles */ static void extractTetMeshSurface(const PxTetrahedronMesh* mesh, PxArray<PxU32>& surfaceTriangles, PxArray<PxU32>* surfaceTriangleToTet = NULL, bool flipTriangleOrientation = false); }; #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
5,481
C
48.387387
226
0.77869
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxSmoothNormals.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_SMOOTH_NORMALS_H #define PX_SMOOTH_NORMALS_H /** \addtogroup extensions @{ */ #include "common/PxPhysXCommonConfig.h" /** \brief Builds smooth vertex normals over a mesh. - "smooth" because smoothing groups are not supported here - takes angles into account for correct cube normals computation To use 32bit indices pass a pointer in dFaces and set wFaces to zero. Alternatively pass a pointer to wFaces and set dFaces to zero. \param[in] nbTris Number of triangles \param[in] nbVerts Number of vertices \param[in] verts Array of vertices \param[in] dFaces Array of dword triangle indices, or null \param[in] wFaces Array of word triangle indices, or null \param[out] normals Array of computed normals (assumes nbVerts vectors) \param[in] flip Flips the normals or not \return True on success. */ PX_C_EXPORT bool PX_CALL_CONV PxBuildSmoothNormals(physx::PxU32 nbTris, physx::PxU32 nbVerts, const physx::PxVec3* verts, const physx::PxU32* dFaces, const physx::PxU16* wFaces, physx::PxVec3* normals, bool flip); /** @} */ #endif
2,761
C
45.033333
121
0.760594
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxBroadPhaseExt.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_BROAD_PHASE_EXT_H #define PX_BROAD_PHASE_EXT_H /** \addtogroup extensions @{ */ #include "PxPhysXConfig.h" #include "common/PxPhysXCommonConfig.h" #if !PX_DOXYGEN namespace physx { #endif class PxBroadPhaseExt { public: /** \brief Creates regions for PxSceneDesc, from a global box. This helper simply subdivides the given global box into a 2D grid of smaller boxes. Each one of those smaller boxes is a region of interest for the broadphase. There are nbSubdiv*nbSubdiv regions in the 2D grid. The function does not subdivide along the given up axis. This is the simplest setup one can use with PxBroadPhaseType::eMBP. A more sophisticated setup would try to cover the game world with a non-uniform set of regions (i.e. not just a grid). \param[out] regions Regions computed from the input global box \param[in] globalBounds World-space box covering the game world \param[in] nbSubdiv Grid subdivision level. The function will create nbSubdiv*nbSubdiv regions. \param[in] upAxis Up axis (0 for X, 1 for Y, 2 for Z). \return number of regions written out to the 'regions' array @see PxSceneDesc PxBroadPhaseType */ static PxU32 createRegionsFromWorldBounds(PxBounds3* regions, const PxBounds3& globalBounds, PxU32 nbSubdiv, PxU32 upAxis=1); }; #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
3,047
C
40.189189
126
0.761405
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxRevoluteJoint.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_REVOLUTE_JOINT_H #define PX_REVOLUTE_JOINT_H /** \addtogroup extensions @{ */ #include "extensions/PxJoint.h" #include "extensions/PxJointLimit.h" #if !PX_DOXYGEN namespace physx { #endif class PxRevoluteJoint; /** \brief Create a revolute joint. \param[in] physics The physics SDK \param[in] actor0 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame \param[in] localFrame0 The position and orientation of the joint relative to actor0 \param[in] actor1 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame \param[in] localFrame1 The position and orientation of the joint relative to actor1 @see PxRevoluteJoint */ PxRevoluteJoint* PxRevoluteJointCreate(PxPhysics& physics, PxRigidActor* actor0, const PxTransform& localFrame0, PxRigidActor* actor1, const PxTransform& localFrame1); /** \brief Flags specific to the Revolute Joint. @see PxRevoluteJoint */ struct PxRevoluteJointFlag { enum Enum { eLIMIT_ENABLED = 1<<0, //!< enable the limit eDRIVE_ENABLED = 1<<1, //!< enable the drive eDRIVE_FREESPIN = 1<<2 //!< if the existing velocity is beyond the drive velocity, do not add force }; }; typedef PxFlags<PxRevoluteJointFlag::Enum, PxU16> PxRevoluteJointFlags; PX_FLAGS_OPERATORS(PxRevoluteJointFlag::Enum, PxU16) /** \brief A joint which behaves in a similar way to a hinge or axle. A hinge joint removes all but a single rotational degree of freedom from two objects. The axis along which the two bodies may rotate is specified with a point and a direction vector. The position of the hinge on each body is specified by the origin of the body's joint frame. The axis of the hinge is specified as the direction of the x-axis in the body's joint frame. \image html revoluteJoint.png A revolute joint can be given a motor, so that it can apply a force to rotate the attached actors. It may also be given a limit, to restrict the revolute motion to within a certain range. In addition, the bodies may be projected together if the distance or angle between them exceeds a given threshold. Projection, drive and limits are activated by setting the appropriate flags on the joint. @see PxRevoluteJointCreate() PxJoint */ class PxRevoluteJoint : public PxJoint { public: /** \brief return the angle of the joint, in the range (-2*Pi, 2*Pi] */ virtual PxReal getAngle() const = 0; /** \brief return the velocity of the joint */ virtual PxReal getVelocity() const = 0; /** \brief set the joint limit parameters. The limit is activated using the flag PxRevoluteJointFlag::eLIMIT_ENABLED The limit angle range is (-2*Pi, 2*Pi). \param[in] limits The joint limit parameters. @see PxJointAngularLimitPair getLimit() */ virtual void setLimit(const PxJointAngularLimitPair& limits) = 0; /** \brief get the joint limit parameters. \return the joint limit parameters @see PxJointAngularLimitPair setLimit() */ virtual PxJointAngularLimitPair getLimit() const = 0; /** \brief set the target velocity for the drive model. The motor will only be able to reach this velocity if the maxForce is sufficiently large. If the joint is spinning faster than this velocity, the motor will actually try to brake (see PxRevoluteJointFlag::eDRIVE_FREESPIN.) The sign of this variable determines the rotation direction, with positive values going the same way as positive joint angles. Setting a very large target velocity may cause undesirable results. \param[in] velocity the drive target velocity \param[in] autowake Whether to wake up the joint rigids if they are asleep. <b>Range:</b> (-PX_MAX_F32, PX_MAX_F32)<br> <b>Default:</b> 0.0 @see PxRevoluteFlags::eDRIVE_FREESPIN */ virtual void setDriveVelocity(PxReal velocity, bool autowake = true) = 0; /** \brief gets the target velocity for the drive model. \return the drive target velocity @see setDriveVelocity() */ virtual PxReal getDriveVelocity() const = 0; /** \brief sets the maximum torque the drive can exert. The value set here may be used either as an impulse limit or a force limit, depending on the flag PxConstraintFlag::eDRIVE_LIMITS_ARE_FORCES <b>Range:</b> [0, PX_MAX_F32)<br> <b>Default:</b> PX_MAX_F32 @see setDriveVelocity() */ virtual void setDriveForceLimit(PxReal limit) = 0; /** \brief gets the maximum torque the drive can exert. \return the torque limit @see setDriveVelocity() */ virtual PxReal getDriveForceLimit() const = 0; /** \brief sets the gear ratio for the drive. When setting up the drive constraint, the velocity of the first actor is scaled by this value, and its response to drive torque is scaled down. So if the drive target velocity is zero, the second actor will be driven to the velocity of the first scaled by the gear ratio <b>Range:</b> [0, PX_MAX_F32)<br> <b>Default:</b> 1.0 \param[in] ratio the drive gear ratio @see getDriveGearRatio() */ virtual void setDriveGearRatio(PxReal ratio) = 0; /** \brief gets the gear ratio. \return the drive gear ratio @see setDriveGearRatio() */ virtual PxReal getDriveGearRatio() const = 0; /** \brief sets the flags specific to the Revolute Joint. <b>Default</b> PxRevoluteJointFlags(0) \param[in] flags The joint flags. @see PxRevoluteJointFlag setFlag() getFlags() */ virtual void setRevoluteJointFlags(PxRevoluteJointFlags flags) = 0; /** \brief sets a single flag specific to a Revolute Joint. \param[in] flag The flag to set or clear. \param[in] value the value to which to set the flag @see PxRevoluteJointFlag, getFlags() setFlags() */ virtual void setRevoluteJointFlag(PxRevoluteJointFlag::Enum flag, bool value) = 0; /** \brief gets the flags specific to the Revolute Joint. \return the joint flags @see PxRevoluteJoint::flags, PxRevoluteJointFlag setFlag() setFlags() */ virtual PxRevoluteJointFlags getRevoluteJointFlags() const = 0; /** \brief Returns string name of PxRevoluteJoint, used for serialization */ virtual const char* getConcreteTypeName() const { return "PxRevoluteJoint"; } protected: //serialization /** \brief Constructor */ PX_INLINE PxRevoluteJoint(PxType concreteType, PxBaseFlags baseFlags) : PxJoint(concreteType, baseFlags) {} /** \brief Deserialization constructor */ PX_INLINE PxRevoluteJoint(PxBaseFlags baseFlags) : PxJoint(baseFlags) {} /** \brief Returns whether a given type name matches with the type of this instance */ virtual bool isKindOf(const char* name) const { PX_IS_KIND_OF(name, "PxRevoluteJoint", PxJoint); } //~serialization }; #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
8,448
C
30.0625
167
0.745147
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxContactJoint.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_CONTACT_JOINT_H #define PX_CONTACT_JOINT_H #include "extensions/PxJoint.h" #if !PX_DOXYGEN namespace physx { #endif class PxContactJoint; /** \brief Create a contact Joint. \param[in] physics The physics SDK \param[in] actor0 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame \param[in] localFrame0 The position and orientation of the joint relative to actor0 \param[in] actor1 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame \param[in] localFrame1 The position and orientation of the joint relative to actor1 @see PxContactJoint */ PX_DEPRECATED PxContactJoint* PxContactJointCreate(PxPhysics& physics, PxRigidActor* actor0, const PxTransform& localFrame0, PxRigidActor* actor1, const PxTransform& localFrame1); struct PX_DEPRECATED PxJacobianRow { PxVec3 linear0; PxVec3 linear1; PxVec3 angular0; PxVec3 angular1; PxJacobianRow(){} PxJacobianRow(const PxVec3& lin0, const PxVec3& lin1, const PxVec3& ang0, const PxVec3& ang1) : linear0(lin0), linear1(lin1), angular0(ang0), angular1(ang1) { } void operator *= (const PxReal scale) { linear0 *= scale; linear1 *= scale; angular0 *= scale; angular1 *= scale; } PxJacobianRow operator * (const PxReal scale) const { return PxJacobianRow(linear0*scale, linear1*scale, angular0*scale, angular1*scale); } }; /** \brief PxContactJoint is best viewed as a helper function for the inverse dynamics of articulations. The expected use case is to use PxContactJoint::getConstraint() in conjunction with PxArticulationReducedCoordinate::addLoopJoint(). @see PxContactJointCreate PxJoint */ PX_DEPRECATED class PxContactJoint : public PxJoint { public: /** \brief Set the current contact of the joint */ virtual void setContact(const PxVec3& contact) = 0; /** \brief Set the current contact normal of the joint */ virtual void setContactNormal(const PxVec3& contactNormal) = 0; /** \brief Set the current penetration of the joint */ virtual void setPenetration(const PxReal penetration) = 0; /** \brief Return the current contact of the joint */ virtual PxVec3 getContact() const = 0; /** \brief Return the current contact normal of the joint */ virtual PxVec3 getContactNormal() const = 0; /** \brief Return the current penetration value of the joint */ virtual PxReal getPenetration() const = 0; virtual PxReal getRestitution() const = 0; virtual void setRestitution(const PxReal restitution) = 0; virtual PxReal getBounceThreshold() const = 0; virtual void setBounceThreshold(const PxReal bounceThreshold) = 0; /** \brief Returns string name of PxContactJoint, used for serialization */ virtual const char* getConcreteTypeName() const { return "PxContactJoint"; } virtual void computeJacobians(PxJacobianRow* jacobian) const = 0; virtual PxU32 getNbJacobianRows() const = 0; protected: //serialization /** \brief Constructor */ PX_INLINE PxContactJoint(PxType concreteType, PxBaseFlags baseFlags) : PxJoint(concreteType, baseFlags) {} /** \brief Deserialization constructor */ PX_INLINE PxContactJoint(PxBaseFlags baseFlags) : PxJoint(baseFlags) {} /** \brief Returns whether a given type name matches with the type of this instance */ virtual bool isKindOf(const char* name) const { PX_IS_KIND_OF(name, "PxContactJoint", PxJoint); } //~serialization }; #if !PX_DOXYGEN } #endif #endif
5,340
C
31.766871
180
0.733146
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxD6Joint.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_D6_JOINT_H #define PX_D6_JOINT_H /** \addtogroup extensions @{ */ #include "extensions/PxJoint.h" #include "extensions/PxJointLimit.h" #include "foundation/PxFlags.h" #if !PX_DOXYGEN namespace physx { #endif class PxD6Joint; /** \brief Create a D6 joint. \param[in] physics The physics SDK \param[in] actor0 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame \param[in] localFrame0 The position and orientation of the joint relative to actor0 \param[in] actor1 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame \param[in] localFrame1 The position and orientation of the joint relative to actor1 @see PxD6Joint */ PxD6Joint* PxD6JointCreate(PxPhysics& physics, PxRigidActor* actor0, const PxTransform& localFrame0, PxRigidActor* actor1, const PxTransform& localFrame1); /** \brief Used to specify one of the degrees of freedom of a D6 joint. @see PxD6Joint */ struct PxD6Axis { enum Enum { eX = 0, //!< motion along the X axis eY = 1, //!< motion along the Y axis eZ = 2, //!< motion along the Z axis eTWIST = 3, //!< motion around the X axis eSWING1 = 4, //!< motion around the Y axis eSWING2 = 5, //!< motion around the Z axis eCOUNT = 6 }; }; /** \brief Used to specify the range of motions allowed for a degree of freedom in a D6 joint. @see PxD6Joint */ struct PxD6Motion { enum Enum { eLOCKED, //!< The DOF is locked, it does not allow relative motion. eLIMITED, //!< The DOF is limited, it only allows motion within a specific range. eFREE //!< The DOF is free and has its full range of motion. }; }; /** \brief Used to specify which axes of a D6 joint are driven. Each drive is an implicit force-limited damped spring: force = spring * (target position - position) + damping * (targetVelocity - velocity) Alternatively, the spring may be configured to generate a specified acceleration instead of a force. A linear axis is affected by drive only if the corresponding drive flag is set. There are two possible models for angular drive: swing/twist, which may be used to drive one or more angular degrees of freedom, or slerp, which may only be used to drive all three angular degrees simultaneously. @see PxD6Joint */ struct PxD6Drive { enum Enum { eX = 0, //!< drive along the X-axis eY = 1, //!< drive along the Y-axis eZ = 2, //!< drive along the Z-axis eSWING = 3, //!< drive of displacement from the X-axis eTWIST = 4, //!< drive of the displacement around the X-axis eSLERP = 5, //!< drive of all three angular degrees along a SLERP-path eCOUNT = 6 }; }; /** \brief flags for configuring the drive model of a PxD6Joint @see PxD6JointDrive PxD6Joint */ struct PxD6JointDriveFlag { enum Enum { eACCELERATION = 1 //!< drive spring is for the acceleration at the joint (rather than the force) }; }; typedef PxFlags<PxD6JointDriveFlag::Enum, PxU32> PxD6JointDriveFlags; PX_FLAGS_OPERATORS(PxD6JointDriveFlag::Enum, PxU32) /** \brief parameters for configuring the drive model of a PxD6Joint @see PxD6Joint */ class PxD6JointDrive : public PxSpring { public: PxReal forceLimit; //!< the force limit of the drive - may be an impulse or a force depending on PxConstraintFlag::eDRIVE_LIMITS_ARE_FORCES PxD6JointDriveFlags flags; //!< the joint drive flags /** \brief default constructor for PxD6JointDrive. */ PxD6JointDrive(): PxSpring(0,0), forceLimit(PX_MAX_F32), flags(0) {} /** \brief constructor a PxD6JointDrive. \param[in] driveStiffness The stiffness of the drive spring. \param[in] driveDamping The damping of the drive spring \param[in] driveForceLimit The maximum impulse or force that can be exerted by the drive \param[in] isAcceleration Whether the drive is an acceleration drive or a force drive */ PxD6JointDrive(PxReal driveStiffness, PxReal driveDamping, PxReal driveForceLimit, bool isAcceleration = false) : PxSpring(driveStiffness, driveDamping) , forceLimit(driveForceLimit) , flags(isAcceleration?PxU32(PxD6JointDriveFlag::eACCELERATION) : 0) {} /** \brief returns true if the drive is valid */ bool isValid() const { return PxIsFinite(stiffness) && stiffness>=0 && PxIsFinite(damping) && damping >=0 && PxIsFinite(forceLimit) && forceLimit >=0; } }; /** \brief A D6 joint is a general constraint between two actors. It allows the application to individually define the linear and rotational degrees of freedom, and also to configure a variety of limits and driven degrees of freedom. By default all degrees of freedom are locked. So to create a prismatic joint with free motion along the x-axis: \code ... joint->setMotion(PxD6Axis::eX, PxD6JointMotion::eFREE); ... \endcode Or a Revolute joint with motion free allowed around the x-axis: \code ... joint->setMotion(PxD6Axis::eTWIST, PxD6JointMotion::eFREE); ... \endcode Degrees of freedom may also be set to limited instead of locked. There are two different kinds of linear limits available. The first kind is a single limit value for all linear degrees of freedom, which may act as a linear, circular, or spherical limit depending on which degrees of freedom are limited. This is similar to a distance limit. Then, the second kind supports a pair of limit values for each linear axis, which can be used to implement a traditional prismatic joint for example. If the twist degree of freedom is limited, is supports upper and lower limits. The two swing degrees of freedom are limited with a cone limit. @see PxD6JointCreate() PxJoint */ class PxD6Joint : public PxJoint { public: /** \brief Set the motion type around the specified axis. Each axis may independently specify that the degree of freedom is locked (blocking relative movement along or around this axis), limited by the corresponding limit, or free. \param[in] axis the axis around which motion is specified \param[in] type the motion type around the specified axis <b>Default:</b> all degrees of freedom are locked @see getMotion() PxD6Axis PxD6Motion */ virtual void setMotion(PxD6Axis::Enum axis, PxD6Motion::Enum type) = 0; /** \brief Get the motion type around the specified axis. @see setMotion() PxD6Axis PxD6Motion \param[in] axis the degree of freedom around which the motion type is specified \return the motion type around the specified axis */ virtual PxD6Motion::Enum getMotion(PxD6Axis::Enum axis) const = 0; /** \brief get the twist angle of the joint, in the range (-2*Pi, 2*Pi] */ virtual PxReal getTwistAngle() const = 0; /** \brief get the twist angle of the joint \deprecated Use getTwistAngle instead. Deprecated since PhysX version 4.0 */ PX_DEPRECATED PX_FORCE_INLINE PxReal getTwist() const { return getTwistAngle(); } /** \brief get the swing angle of the joint from the Y axis */ virtual PxReal getSwingYAngle() const = 0; /** \brief get the swing angle of the joint from the Z axis */ virtual PxReal getSwingZAngle() const = 0; /** \brief Set the distance limit for the joint. A single limit constraints all linear limited degrees of freedom, forming a linear, circular or spherical constraint on motion depending on the number of limited degrees. This is similar to a distance limit. \param[in] limit the distance limit structure @see getDistanceLimit() PxJointLinearLimit */ virtual void setDistanceLimit(const PxJointLinearLimit& limit) = 0; /** \brief Get the distance limit for the joint. \return the distance limit structure @see setDistanceLimit() PxJointLinearLimit */ virtual PxJointLinearLimit getDistanceLimit() const = 0; /** \deprecated Use setDistanceLimit instead. Deprecated since PhysX version 4.0 */ PX_DEPRECATED PX_FORCE_INLINE void setLinearLimit(const PxJointLinearLimit& limit) { setDistanceLimit(limit); } /** \deprecated Use getDistanceLimit instead. Deprecated since PhysX version 4.0 */ PX_DEPRECATED PX_FORCE_INLINE PxJointLinearLimit getLinearLimit() const { return getDistanceLimit(); } /** \brief Set the linear limit for a given linear axis. This function extends the previous setDistanceLimit call with the following features: - there can be a different limit for each linear axis - each limit is defined by two values, i.e. it can now be asymmetric This can be used to create prismatic joints similar to PxPrismaticJoint, or point-in-quad joints, or point-in-box joints. \param[in] axis The limited linear axis (must be PxD6Axis::eX, PxD6Axis::eY or PxD6Axis::eZ) \param[in] limit The linear limit pair structure @see getLinearLimit() */ virtual void setLinearLimit(PxD6Axis::Enum axis, const PxJointLinearLimitPair& limit) = 0; /** \brief Get the linear limit for a given linear axis. \param[in] axis The limited linear axis (must be PxD6Axis::eX, PxD6Axis::eY or PxD6Axis::eZ) \return the linear limit pair structure from desired axis @see setLinearLimit() PxJointLinearLimit */ virtual PxJointLinearLimitPair getLinearLimit(PxD6Axis::Enum axis) const = 0; /** \brief Set the twist limit for the joint. The twist limit controls the range of motion around the twist axis. The limit angle range is (-2*Pi, 2*Pi). \param[in] limit the twist limit structure @see getTwistLimit() PxJointAngularLimitPair */ virtual void setTwistLimit(const PxJointAngularLimitPair& limit) = 0; /** \brief Get the twist limit for the joint. \return the twist limit structure @see setTwistLimit() PxJointAngularLimitPair */ virtual PxJointAngularLimitPair getTwistLimit() const = 0; /** \brief Set the swing cone limit for the joint. The cone limit is used if either or both swing axes are limited. The extents are symmetrical and measured in the frame of the parent. If only one swing degree of freedom is limited, the corresponding value from the cone limit defines the limit range. \param[in] limit the cone limit structure @see getLimitCone() PxJointLimitCone */ virtual void setSwingLimit(const PxJointLimitCone& limit) = 0; /** \brief Get the cone limit for the joint. \return the swing limit structure @see setLimitCone() PxJointLimitCone */ virtual PxJointLimitCone getSwingLimit() const = 0; /** \brief Set a pyramidal swing limit for the joint. The pyramid limits will only be used in the following cases: - both swing Y and Z are limited. The limit shape is then a pyramid. - Y is limited and Z is locked, or vice versa. The limit shape is an asymmetric angular section, similar to what is supported for the twist axis. The remaining cases (Y limited and Z is free, or vice versa) are not supported. \param[in] limit the cone limit structure @see getLimitCone() PxJointLimitPyramid */ virtual void setPyramidSwingLimit(const PxJointLimitPyramid& limit) = 0; /** \brief Get the pyramidal swing limit for the joint. \return the swing limit structure @see setLimitCone() PxJointLimitPyramid */ virtual PxJointLimitPyramid getPyramidSwingLimit() const = 0; /** \brief Set the drive parameters for the specified drive type. \param[in] index the type of drive being specified \param[in] drive the drive parameters @see getDrive() PxD6JointDrive <b>Default</b> The default drive spring and damping values are zero, the force limit is zero, and no flags are set. */ virtual void setDrive(PxD6Drive::Enum index, const PxD6JointDrive& drive) = 0; /** \brief Get the drive parameters for the specified drive type. \param[in] index the specified drive type @see setDrive() PxD6JointDrive */ virtual PxD6JointDrive getDrive(PxD6Drive::Enum index) const = 0; /** \brief Set the drive goal pose The goal is relative to the constraint frame of actor[0] <b>Default</b> the identity transform \param[in] pose The goal drive pose if positional drive is in use. \param[in] autowake If true and the attached actors are in a scene, this call wakes them up and increases their wake counters to #PxSceneDesc::wakeCounterResetValue if the counter value is below the reset value. @see setDrivePosition() */ virtual void setDrivePosition(const PxTransform& pose, bool autowake = true) = 0; /** \brief Get the drive goal pose. @see getDrivePosition() */ virtual PxTransform getDrivePosition() const = 0; /** \brief Set the target goal velocity for drive. The velocity is measured in the constraint frame of actor[0] \param[in] linear The goal velocity for linear drive \param[in] angular The goal velocity for angular drive \param[in] autowake If true and the attached actors are in a scene, this call wakes them up and increases their wake counters to #PxSceneDesc::wakeCounterResetValue if the counter value is below the reset value. @see getDriveVelocity() */ virtual void setDriveVelocity(const PxVec3& linear, const PxVec3& angular, bool autowake = true) = 0; /** \brief Get the target goal velocity for joint drive. \param[in] linear The goal velocity for linear drive \param[in] angular The goal velocity for angular drive @see setDriveVelocity() */ virtual void getDriveVelocity(PxVec3& linear, PxVec3& angular) const = 0; /** \brief Returns string name of PxD6Joint, used for serialization */ virtual const char* getConcreteTypeName() const { return "PxD6Joint"; } protected: //serialization /** \brief Constructor */ PX_INLINE PxD6Joint(PxType concreteType, PxBaseFlags baseFlags) : PxJoint(concreteType, baseFlags) {} /** \brief Deserialization constructor */ PX_INLINE PxD6Joint(PxBaseFlags baseFlags) : PxJoint(baseFlags) {} /** \brief Returns whether a given type name matches with the type of this instance */ virtual bool isKindOf(const char* name) const { PX_IS_KIND_OF(name, "PxD6Joint", PxJoint); } //~serialization }; #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
15,691
C
30.70101
155
0.739468
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxSamplingExt.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_SAMPLING_EXT_H #define PX_SAMPLING_EXT_H /** \addtogroup extensions @{ */ #include "foundation/PxArray.h" #include "geometry/PxGeometry.h" #include "foundation/PxUserAllocated.h" #include "geometry/PxSimpleTriangleMesh.h" #if !PX_DOXYGEN namespace physx { #endif /** \brief utility functions to sample vertices on or inside a triangle mesh or other geometries */ class PxSamplingExt { public: /** Computes samples on a triangle mesh's surface that are not closer to each other than a given distance. Optionally the mesh's interior can be filled with samples as well. \param[in] mesh The triangle mesh \param[in] r The closest distance two surface samples are allowed to have \param[out] result Equally distributed samples on and if specified inside the triangle mesh \param[in] rVolume The average distance of samples inside the mesh. If set to zero, samples will only be placed on the mesh's surface \param[out] triangleIds Optional output containing the index of the triangle for all samples on the mesh's surface. The array will contain less entries than output vertices if volume samples are active since volume samples are not on the surface. \param[out] barycentricCoordinates Optional output containing the barycentric coordinates for all samples on the mesh's surface. The array will contain less entries than output vertices if volume samples are active since volume samples are not on the surface. \param[in] axisAlignedBox A box that limits the space where samples can get created \param[in] boxOrientation The orientation of the box that limits the space where samples can get created \param[in] maxNumSamples If larger than zero, the sampler will stop when the sample count reaches maxNumSamples \param[in] numSampleAttemptsAroundPoint Number of repetitions the underlying algorithm performs to find a new valid sample that matches all criteria like minimal distance to existing samples etc. \return Returns true if the sampling was successful and false if there was a problem. Usually an internal overflow is the problem for very big meshes or very small sampling radii. */ static bool poissonSample(const PxSimpleTriangleMesh& mesh, PxReal r, PxArray<PxVec3>& result, PxReal rVolume = 0.0f, PxArray<PxI32>* triangleIds = NULL, PxArray<PxVec3>* barycentricCoordinates = NULL, const PxBounds3* axisAlignedBox = NULL, const PxQuat* boxOrientation = NULL, PxU32 maxNumSamples = 0, PxU32 numSampleAttemptsAroundPoint = 30); /** Computes samples on a geometry's surface that are not closer to each other than a given distance. \param[in] geometry The geometry that defines the surface on which the samples get created \param[in] transform The geometry's global pose \param[in] worldBounds The geometry's bounding box \param[in] r The closest distance two surface samples are allowed to have \param[out] result Equally distributed samples on and if specified inside the triangle mesh \param[in] rVolume The average distance of samples inside the mesh. If set to zero, samples will only be placed on the mesh's surface \param[in] axisAlignedBox A box that limits the space where samples can get created \param[in] boxOrientation The orientation of the box that limits the space where samples can get created \param[in] maxNumSamples If larger than zero, the sampler will stop when the sample count reaches maxNumSamples \param[in] numSampleAttemptsAroundPoint Number of repetitions the underlying algorithm performs to find a new valid sample that matches all criteria like minimal distance to existing samples etc. \return Returns true if the sampling was successful and false if there was a problem. Usually an internal overflow is the problem for very big meshes or very small sampling radii. */ static bool poissonSample(const PxGeometry& geometry, const PxTransform& transform, const PxBounds3& worldBounds, PxReal r, PxArray<PxVec3>& result, PxReal rVolume = 0.0f, const PxBounds3* axisAlignedBox = NULL, const PxQuat* boxOrientation = NULL, PxU32 maxNumSamples = 0, PxU32 numSampleAttemptsAroundPoint = 30); }; /** \brief Sampler to generate Poisson Samples locally on a triangle mesh or a shape. For every local addition of new samples, an individual sampling density can be used. */ class PxPoissonSampler : public PxUserAllocated { public: /** Sets the sampling radius \param[in] samplingRadius The closest distance two surface samples are allowed to have. Changing the sampling radius is a bit an expensive operation. \return Returns true if the sampling was successful and false if there was a problem. Usually an internal overflow is the problem for very big meshes or very small sampling radii. */ virtual bool setSamplingRadius(PxReal samplingRadius) = 0; /** Adds samples \param[in] samples The samples to add. Adding samples is a bit an expensive operation. */ virtual void addSamples(const PxArray<PxVec3>& samples) = 0; /** Adds samples \param[in] samples The samples to remove. Removing samples is a bit an expensive operation. \return Returns the number of removed samples. If some samples were not found, then the number of actually removed samples will be smaller than the number of samples requested to remove */ virtual PxU32 removeSamples(const PxArray<PxVec3>& samples) = 0; /** Adds new Poisson Samples inside the sphere specified \param[in] sphereCenter The sphere's center. Used to define the region where new samples get added. \param[in] sphereRadius The sphere's radius. Used to define the region where new samples get added. \param[in] createVolumeSamples If set to true, samples will also get generated inside of the mesh, not just on its surface. */ virtual void addSamplesInSphere(const PxVec3& sphereCenter, PxReal sphereRadius, bool createVolumeSamples = false) = 0; /** Adds new Poisson Samples inside the box specified \param[in] axisAlignedBox The axis aligned bounding box. Used to define the region where new samples get added. \param[in] boxOrientation The orientation making an oriented bounding box out of the axis aligned one. Used to define the region where new samples get added. \param[in] createVolumeSamples If set to true, samples will also get generated inside of the mesh, not just on its surface. */ virtual void addSamplesInBox(const PxBounds3& axisAlignedBox, const PxQuat& boxOrientation, bool createVolumeSamples = false) = 0; /** Gets the Poisson Samples \return Returns the generated Poisson Samples */ virtual const PxArray<PxVec3>& getSamples() const = 0; virtual ~PxPoissonSampler() { } }; /** Creates a shape sampler \param[in] geometry The shape that defines the surface on which the samples get created \param[in] transform The shape's global pose \param[in] worldBounds The shapes bounding box \param[in] initialSamplingRadius The closest distance two surface samples are allowed to have \param[in] numSampleAttemptsAroundPoint Number of repetitions the underlying algorithm performs to find a new valid sample that matches all criteria like minimal distance to existing samples etc. \return Returns the sampler */ PxPoissonSampler* PxCreateShapeSampler(const PxGeometry& geometry, const PxTransform& transform, const PxBounds3& worldBounds, PxReal initialSamplingRadius, PxI32 numSampleAttemptsAroundPoint = 30); /** \brief Sampler to generate Poisson Samples on a triangle mesh. */ class PxTriangleMeshPoissonSampler : public virtual PxPoissonSampler { public: /** Gets the Poisson Samples' triangle indices \return Returns the generated Poisson Samples' triangle indices */ virtual const PxArray<PxI32>& getSampleTriangleIds() const = 0; /** Gets the Poisson Samples' barycentric coordinates \return Returns the generated Poisson Samples' barycentric coordinates */ virtual const PxArray<PxVec3>& getSampleBarycentrics() const = 0; /** Checks whether a point is inside the triangle mesh \return Returns true if the point is inside the triangle mesh */ virtual bool isPointInTriangleMesh(const PxVec3& p) = 0; virtual ~PxTriangleMeshPoissonSampler() { } }; /** Creates a triangle mesh sampler \param[in] triangles The triangle indices of the mesh \param[in] numTriangles The total number of triangles \param[in] vertices The vertices of the mesh \param[in] numVertices The total number of vertices \param[in] initialSamplingRadius The closest distance two surface samples are allowed to have \param[in] numSampleAttemptsAroundPoint Number of repetitions the underlying algorithm performs to find a new valid sample that matches all criteria like minimal distance to existing samples etc. \return Returns the sampler */ PxTriangleMeshPoissonSampler* PxCreateTriangleMeshSampler(const PxU32* triangles, PxU32 numTriangles, const PxVec3* vertices, PxU32 numVertices, PxReal initialSamplingRadius, PxI32 numSampleAttemptsAroundPoint = 30); #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
10,597
C
55.978494
260
0.787676
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxExtensionsAPI.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_EXTENSIONS_API_H #define PX_EXTENSIONS_API_H /** \addtogroup extensions @{ */ #include "foundation/PxErrorCallback.h" #include "extensions/PxDefaultAllocator.h" #include "extensions/PxConstraintExt.h" #include "extensions/PxDistanceJoint.h" #include "extensions/PxContactJoint.h" #include "extensions/PxFixedJoint.h" #include "extensions/PxPrismaticJoint.h" #include "extensions/PxRevoluteJoint.h" #include "extensions/PxSphericalJoint.h" #include "extensions/PxD6Joint.h" #include "extensions/PxGearJoint.h" #include "extensions/PxRackAndPinionJoint.h" #include "extensions/PxDefaultSimulationFilterShader.h" #include "extensions/PxDefaultErrorCallback.h" #include "extensions/PxDefaultStreams.h" #include "extensions/PxRigidActorExt.h" #include "extensions/PxRigidBodyExt.h" #include "extensions/PxShapeExt.h" #include "extensions/PxTriangleMeshExt.h" #include "extensions/PxSerialization.h" #include "extensions/PxDefaultCpuDispatcher.h" #include "extensions/PxSmoothNormals.h" #include "extensions/PxSimpleFactory.h" #include "extensions/PxStringTableExt.h" #include "extensions/PxBroadPhaseExt.h" #include "extensions/PxMassProperties.h" #include "extensions/PxSceneQueryExt.h" #include "extensions/PxSceneQuerySystemExt.h" #include "extensions/PxCustomSceneQuerySystem.h" #include "extensions/PxConvexMeshExt.h" #include "extensions/PxSamplingExt.h" #include "extensions/PxTetrahedronMeshExt.h" #include "extensions/PxCustomGeometryExt.h" #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION #include "extensions/PxFEMClothExt.h" #endif /** \brief Initialize the PhysXExtensions library. This should be called before calling any functions or methods in extensions which may require allocation. \note This function does not need to be called before creating a PxDefaultAllocator object. \param physics a PxPhysics object \param pvd an PxPvd (PhysX Visual Debugger) object @see PxCloseExtensions PxFoundation PxPhysics */ PX_C_EXPORT bool PX_CALL_CONV PxInitExtensions(physx::PxPhysics& physics, physx::PxPvd* pvd); /** \brief Shut down the PhysXExtensions library. This function should be called to cleanly shut down the PhysXExtensions library before application exit. \note This function is required to be called to release foundation usage. @see PxInitExtensions */ PX_C_EXPORT void PX_CALL_CONV PxCloseExtensions(); /** @} */ #endif
4,057
C
40.835051
106
0.791225
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxCustomSceneQuerySystem.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_NEW_SCENE_QUERY_SYSTEM_H #define PX_NEW_SCENE_QUERY_SYSTEM_H /** \addtogroup extensions @{ */ #include "PxSceneQuerySystem.h" #if !PX_DOXYGEN namespace physx { #endif /** \brief A custom scene query system. This is an example of a custom scene query system. It augments the PxSceneQuerySystem API to support an arbitrary number of "pruners", instead of the usual hardcoded two. It might not be possible to support the whole PxSceneQuerySystem API in this context. See the source code for details. @see PxSceneQuerySystem */ class PxCustomSceneQuerySystem : public PxSceneQuerySystem { public: PxCustomSceneQuerySystem() {} virtual ~PxCustomSceneQuerySystem() {} /** \brief Adds a pruner to the system. The internal PhysX scene-query system uses two regular pruners (one for static shapes, one for dynamic shapes) and an optional compound pruner. Our custom scene query system supports an arbitrary number of regular pruners. This can be useful to reduce the load on each pruner, in particular during updates, when internal trees are rebuilt in the background. On the other hand this implementation simply iterates over all created pruners to perform queries, so their cost might increase if a large number of pruners is used. In any case this serves as an example of how the PxSceneQuerySystem API can be used to customize scene queries. \param[in] primaryType Desired primary (main) type for the new pruner \param[in] secondaryType Secondary type when primary type is PxPruningStructureType::eDYNAMIC_AABB_TREE. \param[in] preallocated Optional number of preallocated shapes in the new pruner \return A pruner index @see PxCustomSceneQuerySystem PxSceneQueryUpdateMode PxCustomSceneQuerySystemAdapter PxSceneDesc::sceneQuerySystem */ virtual PxU32 addPruner(PxPruningStructureType::Enum primaryType, PxDynamicTreeSecondaryPruner::Enum secondaryType, PxU32 preallocated=0) = 0; /** \brief Start custom build-steps for all pruners This function is used in combination with customBuildstep() and finishCustomBuildstep() to let users take control of the pruners' build-step & commit calls - basically the pruners' update functions. These functions should be used with the PxSceneQueryUpdateMode::eBUILD_DISABLED_COMMIT_DISABLED update mode, otherwise the build-steps will happen automatically in fetchResults. For N pruners it can be more efficient to use these custom build-step functions to perform the updates in parallel: - call startCustomBuildstep() first (one synchronous call) - for each pruner, call customBuildstep() (asynchronous calls from multiple threads) - once it is done, call finishCustomBuildstep() to finish the update (synchronous call) The multi-threaded update is more efficient here than what it is in PxScene, because the "flushShapes()" call is also multi-threaded (while it is not in PxScene). Note that users are responsible for locks here, and these calls should not overlap with other SQ calls. In particular one should not add new objects to the SQ system or perform queries while these calls are happening. \return The number of pruners in the system. @see customBuildstep finishCustomBuildstep PxSceneQueryUpdateMode */ virtual PxU32 startCustomBuildstep() = 0; /** \brief Perform a custom build-step for a given pruner. \param[in] index Pruner index (should be between 0 and the number returned by startCustomBuildstep) @see startCustomBuildstep finishCustomBuildstep */ virtual void customBuildstep(PxU32 index) = 0; /** \brief Finish custom build-steps Call this function once after all the customBuildstep() calls are done. @see startCustomBuildstep customBuildstep */ virtual void finishCustomBuildstep() = 0; }; /** \brief An adapter class to customize the object-to-pruner mapping. In the regular PhysX code static shapes went to the static pruner, and dynamic shapes went to the dynamic pruner. This class is a replacement for this mapping when N user-defined pruners are involved. */ class PxCustomSceneQuerySystemAdapter { public: PxCustomSceneQuerySystemAdapter() {} virtual ~PxCustomSceneQuerySystemAdapter() {} /** \brief Gets a pruner index for an actor/shape. This user-defined function tells the system in which pruner a given actor/shape should go. \note The returned index must be valid, i.e. it must have been previously returned to users by PxCustomSceneQuerySystem::addPruner. \param[in] actor The actor \param[in] shape The shape \return A pruner index for this actor/shape. @see PxRigidActor PxShape PxCustomSceneQuerySystem::addPruner */ virtual PxU32 getPrunerIndex(const PxRigidActor& actor, const PxShape& shape) const = 0; /** \brief Pruner filtering callback. This will be called for each query to validate whether it should process a given pruner. \param[in] prunerIndex The index of currently processed pruner \param[in] context The query context \param[in] filterData The query's filter data \param[in] filterCall The query's filter callback \return True to process the pruner, false to skip it entirely */ virtual bool processPruner(PxU32 prunerIndex, const PxQueryThreadContext* context, const PxQueryFilterData& filterData, PxQueryFilterCallback* filterCall) const = 0; }; /** \brief Creates a custom scene query system. This is similar to PxCreateExternalSceneQuerySystem, except this function creates a PxCustomSceneQuerySystem object. It can be plugged to PxScene the same way, via PxSceneDesc::sceneQuerySystem. \param[in] sceneQueryUpdateMode Desired update mode \param[in] contextID Context ID parameter, sent to the profiler \param[in] adapter Adapter class implementing our extended API \param[in] usesTreeOfPruners True to keep pruners themselves in a BVH, which might increase query performance if a lot of pruners are involved \return A custom SQ system instance @see PxCustomSceneQuerySystem PxSceneQueryUpdateMode PxCustomSceneQuerySystemAdapter PxSceneDesc::sceneQuerySystem */ PxCustomSceneQuerySystem* PxCreateCustomSceneQuerySystem(PxSceneQueryUpdateMode::Enum sceneQueryUpdateMode, PxU64 contextID, const PxCustomSceneQuerySystemAdapter& adapter, bool usesTreeOfPruners=false); #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
8,072
C
41.046875
204
0.776759
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxSceneQueryExt.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_SCENE_QUERY_EXT_H #define PX_SCENE_QUERY_EXT_H /** \addtogroup extensions @{ */ #include "PxPhysXConfig.h" #include "PxScene.h" #if !PX_DOXYGEN namespace physx { #endif // These types have been deprecated (removed) in PhysX 3.4. We typedef them to the new types here for easy migration from 3.3 to 3.4. typedef PxQueryHit PxSceneQueryHit; typedef PxQueryFilterData PxSceneQueryFilterData; typedef PxQueryFilterCallback PxSceneQueryFilterCallback; typedef PxQueryCache PxSceneQueryCache; typedef PxHitFlag PxSceneQueryFlag; typedef PxHitFlags PxSceneQueryFlags; /** \brief utility functions for use with PxScene, related to scene queries. Some of these functions have been deprecated (removed) in PhysX 3.4. We re-implement them here for easy migration from 3.3 to 3.4. @see PxShape */ class PxSceneQueryExt { public: /** \brief Raycast returning any blocking hit, not necessarily the closest. Returns whether any rigid actor is hit along the ray. \note Shooting a ray from within an object leads to different results depending on the shape type. Please check the details in article SceneQuery. User can ignore such objects by using one of the provided filter mechanisms. \param[in] scene The scene \param[in] origin Origin of the ray. \param[in] unitDir Normalized direction of the ray. \param[in] distance Length of the ray. Needs to be larger than 0. \param[out] hit Raycast hit information. \param[in] filterData Filtering data and simple logic. \param[in] filterCall Custom filtering logic (optional). Only used if the corresponding #PxHitFlag flags are set. If NULL, all hits are assumed to be blocking. \param[in] cache Cached hit shape (optional). Ray is tested against cached shape first. If no hit is found the ray gets queried against the scene. Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit. Note: Using past touching hits as cache will produce incorrect behavior since the cached hit will always be treated as blocking. \return True if a blocking hit was found. @see PxSceneQueryFilterData PxSceneQueryFilterCallback PxSceneQueryCache PxSceneQueryHit */ static bool raycastAny( const PxScene& scene, const PxVec3& origin, const PxVec3& unitDir, const PxReal distance, PxSceneQueryHit& hit, const PxSceneQueryFilterData& filterData = PxSceneQueryFilterData(), PxSceneQueryFilterCallback* filterCall = NULL, const PxSceneQueryCache* cache = NULL); /** \brief Raycast returning a single result. Returns the first rigid actor that is hit along the ray. Data for a blocking hit will be returned as specified by the outputFlags field. Touching hits will be ignored. \note Shooting a ray from within an object leads to different results depending on the shape type. Please check the details in article SceneQuery. User can ignore such objects by using one of the provided filter mechanisms. \param[in] scene The scene \param[in] origin Origin of the ray. \param[in] unitDir Normalized direction of the ray. \param[in] distance Length of the ray. Needs to be larger than 0. \param[in] outputFlags Specifies which properties should be written to the hit information \param[out] hit Raycast hit information. \param[in] filterData Filtering data and simple logic. \param[in] filterCall Custom filtering logic (optional). Only used if the corresponding #PxHitFlag flags are set. If NULL, all hits are assumed to be blocking. \param[in] cache Cached hit shape (optional). Ray is tested against cached shape first then against the scene. Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit. Note: Using past touching hits as cache will produce incorrect behavior since the cached hit will always be treated as blocking. \return True if a blocking hit was found. @see PxSceneQueryFlags PxRaycastHit PxSceneQueryFilterData PxSceneQueryFilterCallback PxSceneQueryCache */ static bool raycastSingle( const PxScene& scene, const PxVec3& origin, const PxVec3& unitDir, const PxReal distance, PxSceneQueryFlags outputFlags, PxRaycastHit& hit, const PxSceneQueryFilterData& filterData = PxSceneQueryFilterData(), PxSceneQueryFilterCallback* filterCall = NULL, const PxSceneQueryCache* cache = NULL); /** \brief Raycast returning multiple results. Find all rigid actors that get hit along the ray. Each result contains data as specified by the outputFlags field. \note Touching hits are not ordered. \note Shooting a ray from within an object leads to different results depending on the shape type. Please check the details in article SceneQuery. User can ignore such objects by using one of the provided filter mechanisms. \param[in] scene The scene \param[in] origin Origin of the ray. \param[in] unitDir Normalized direction of the ray. \param[in] distance Length of the ray. Needs to be larger than 0. \param[in] outputFlags Specifies which properties should be written to the hit information \param[out] hitBuffer Raycast hit information buffer. If the buffer overflows, the blocking hit is returned as the last entry together with an arbitrary subset of the nearer touching hits (typically the query should be restarted with a larger buffer). \param[in] hitBufferSize Size of the hit buffer. \param[out] blockingHit True if a blocking hit was found. If found, it is the last in the buffer, preceded by any touching hits which are closer. Otherwise the touching hits are listed. \param[in] filterData Filtering data and simple logic. \param[in] filterCall Custom filtering logic (optional). Only used if the corresponding #PxHitFlag flags are set. If NULL, all hits are assumed to be touching. \param[in] cache Cached hit shape (optional). Ray is tested against cached shape first then against the scene. Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit. Note: Using past touching hits as cache will produce incorrect behavior since the cached hit will always be treated as blocking. \return Number of hits in the buffer, or -1 if the buffer overflowed. @see PxSceneQueryFlags PxRaycastHit PxSceneQueryFilterData PxSceneQueryFilterCallback PxSceneQueryCache */ static PxI32 raycastMultiple( const PxScene& scene, const PxVec3& origin, const PxVec3& unitDir, const PxReal distance, PxSceneQueryFlags outputFlags, PxRaycastHit* hitBuffer, PxU32 hitBufferSize, bool& blockingHit, const PxSceneQueryFilterData& filterData = PxSceneQueryFilterData(), PxSceneQueryFilterCallback* filterCall = NULL, const PxSceneQueryCache* cache = NULL); /** \brief Sweep returning any blocking hit, not necessarily the closest. Returns whether any rigid actor is hit along the sweep path. \note If a shape from the scene is already overlapping with the query shape in its starting position, behavior is controlled by the PxSceneQueryFlag::eINITIAL_OVERLAP flag. \param[in] scene The scene \param[in] geometry Geometry of object to sweep (supported types are: box, sphere, capsule, convex). \param[in] pose Pose of the sweep object. \param[in] unitDir Normalized direction of the sweep. \param[in] distance Sweep distance. Needs to be larger than 0. Will be clamped to PX_MAX_SWEEP_DISTANCE. \param[in] queryFlags Combination of PxSceneQueryFlag defining the query behavior \param[out] hit Sweep hit information. \param[in] filterData Filtering data and simple logic. \param[in] filterCall Custom filtering logic (optional). Only used if the corresponding #PxHitFlag flags are set. If NULL, all hits are assumed to be blocking. \param[in] cache Cached hit shape (optional). Sweep is performed against cached shape first. If no hit is found the sweep gets queried against the scene. Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit. Note: Using past touching hits as cache will produce incorrect behavior since the cached hit will always be treated as blocking. \param[in] inflation This parameter creates a skin around the swept geometry which increases its extents for sweeping. The sweep will register a hit as soon as the skin touches a shape, and will return the corresponding distance and normal. \return True if a blocking hit was found. @see PxSceneQueryFilterData PxSceneQueryFilterCallback PxSceneQueryHit PxSceneQueryCache */ static bool sweepAny( const PxScene& scene, const PxGeometry& geometry, const PxTransform& pose, const PxVec3& unitDir, const PxReal distance, PxSceneQueryFlags queryFlags, PxSceneQueryHit& hit, const PxSceneQueryFilterData& filterData = PxSceneQueryFilterData(), PxSceneQueryFilterCallback* filterCall = NULL, const PxSceneQueryCache* cache = NULL, PxReal inflation = 0.0f); /** \brief Sweep returning a single result. Returns the first rigid actor that is hit along the ray. Data for a blocking hit will be returned as specified by the outputFlags field. Touching hits will be ignored. \note If a shape from the scene is already overlapping with the query shape in its starting position, behavior is controlled by the PxSceneQueryFlag::eINITIAL_OVERLAP flag. \param[in] scene The scene \param[in] geometry Geometry of object to sweep (supported types are: box, sphere, capsule, convex). \param[in] pose Pose of the sweep object. \param[in] unitDir Normalized direction of the sweep. \param[in] distance Sweep distance. Needs to be larger than 0. Will be clamped to PX_MAX_SWEEP_DISTANCE. \param[in] outputFlags Specifies which properties should be written to the hit information. \param[out] hit Sweep hit information. \param[in] filterData Filtering data and simple logic. \param[in] filterCall Custom filtering logic (optional). Only used if the corresponding #PxHitFlag flags are set. If NULL, all hits are assumed to be blocking. \param[in] cache Cached hit shape (optional). Sweep is performed against cached shape first then against the scene. Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit. Note: Using past touching hits as cache will produce incorrect behavior since the cached hit will always be treated as blocking. \param[in] inflation This parameter creates a skin around the swept geometry which increases its extents for sweeping. The sweep will register a hit as soon as the skin touches a shape, and will return the corresponding distance and normal. \return True if a blocking hit was found. @see PxSceneQueryFlags PxSweepHit PxSceneQueryFilterData PxSceneQueryFilterCallback PxSceneQueryCache */ static bool sweepSingle(const PxScene& scene, const PxGeometry& geometry, const PxTransform& pose, const PxVec3& unitDir, const PxReal distance, PxSceneQueryFlags outputFlags, PxSweepHit& hit, const PxSceneQueryFilterData& filterData = PxSceneQueryFilterData(), PxSceneQueryFilterCallback* filterCall = NULL, const PxSceneQueryCache* cache = NULL, PxReal inflation=0.0f); /** \brief Sweep returning multiple results. Find all rigid actors that get hit along the sweep. Each result contains data as specified by the outputFlags field. \note Touching hits are not ordered. \note If a shape from the scene is already overlapping with the query shape in its starting position, behavior is controlled by the PxSceneQueryFlag::eINITIAL_OVERLAP flag. \param[in] scene The scene \param[in] geometry Geometry of object to sweep (supported types are: box, sphere, capsule, convex). \param[in] pose Pose of the sweep object. \param[in] unitDir Normalized direction of the sweep. \param[in] distance Sweep distance. Needs to be larger than 0. Will be clamped to PX_MAX_SWEEP_DISTANCE. \param[in] outputFlags Specifies which properties should be written to the hit information. \param[out] hitBuffer Sweep hit information buffer. If the buffer overflows, the blocking hit is returned as the last entry together with an arbitrary subset of the nearer touching hits (typically the query should be restarted with a larger buffer). \param[in] hitBufferSize Size of the hit buffer. \param[out] blockingHit True if a blocking hit was found. If found, it is the last in the buffer, preceded by any touching hits which are closer. Otherwise the touching hits are listed. \param[in] filterData Filtering data and simple logic. \param[in] filterCall Custom filtering logic (optional). Only used if the corresponding #PxHitFlag flags are set. If NULL, all hits are assumed to be touching. \param[in] cache Cached hit shape (optional). Sweep is performed against cached shape first then against the scene. Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit. Note: Using past touching hits as cache will produce incorrect behavior since the cached hit will always be treated as blocking. \param[in] inflation This parameter creates a skin around the swept geometry which increases its extents for sweeping. The sweep will register a hit as soon as the skin touches a shape, and will return the corresponding distance and normal. \return Number of hits in the buffer, or -1 if the buffer overflowed. @see PxSceneQueryFlags PxSweepHit PxSceneQueryFilterData PxSceneQueryFilterCallback PxSceneQueryCache */ static PxI32 sweepMultiple( const PxScene& scene, const PxGeometry& geometry, const PxTransform& pose, const PxVec3& unitDir, const PxReal distance, PxSceneQueryFlags outputFlags, PxSweepHit* hitBuffer, PxU32 hitBufferSize, bool& blockingHit, const PxSceneQueryFilterData& filterData = PxSceneQueryFilterData(), PxSceneQueryFilterCallback* filterCall = NULL, const PxSceneQueryCache* cache = NULL, PxReal inflation = 0.0f); /** \brief Test overlap between a geometry and objects in the scene. \note Filtering: Overlap tests do not distinguish between touching and blocking hit types. Both get written to the hit buffer. \note PxHitFlag::eMESH_MULTIPLE and PxHitFlag::eMESH_BOTH_SIDES have no effect in this case \param[in] scene The scene \param[in] geometry Geometry of object to check for overlap (supported types are: box, sphere, capsule, convex). \param[in] pose Pose of the object. \param[out] hitBuffer Buffer to store the overlapping objects to. If the buffer overflows, an arbitrary subset of overlapping objects is stored (typically the query should be restarted with a larger buffer). \param[in] hitBufferSize Size of the hit buffer. \param[in] filterData Filtering data and simple logic. \param[in] filterCall Custom filtering logic (optional). Only used if the corresponding #PxHitFlag flags are set. If NULL, all hits are assumed to overlap. \return Number of hits in the buffer, or -1 if the buffer overflowed. @see PxSceneQueryFlags PxSceneQueryFilterData PxSceneQueryFilterCallback */ static PxI32 overlapMultiple( const PxScene& scene, const PxGeometry& geometry, const PxTransform& pose, PxOverlapHit* hitBuffer, PxU32 hitBufferSize, const PxSceneQueryFilterData& filterData = PxSceneQueryFilterData(), PxSceneQueryFilterCallback* filterCall = NULL); /** \brief Test returning, for a given geometry, any overlapping object in the scene. \note Filtering: Overlap tests do not distinguish between touching and blocking hit types. Both trigger a hit. \note PxHitFlag::eMESH_MULTIPLE and PxHitFlag::eMESH_BOTH_SIDES have no effect in this case \param[in] scene The scene \param[in] geometry Geometry of object to check for overlap (supported types are: box, sphere, capsule, convex). \param[in] pose Pose of the object. \param[out] hit Pointer to store the overlapping object to. \param[in] filterData Filtering data and simple logic. \param[in] filterCall Custom filtering logic (optional). Only used if the corresponding #PxHitFlag flags are set. If NULL, all hits are assumed to overlap. \return True if an overlap was found. @see PxSceneQueryFlags PxSceneQueryFilterData PxSceneQueryFilterCallback */ static bool overlapAny( const PxScene& scene, const PxGeometry& geometry, const PxTransform& pose, PxOverlapHit& hit, const PxSceneQueryFilterData& filterData = PxSceneQueryFilterData(), PxSceneQueryFilterCallback* filterCall = NULL); }; struct PxBatchQueryStatus { enum Enum { /** \brief This is the initial state before a query starts. */ ePENDING = 0, /** \brief The query is finished; results have been written into the result and hit buffers. */ eSUCCESS, /** \brief The query results were incomplete due to touch hit buffer overflow. Blocking hit is still correct. */ eOVERFLOW }; static PX_FORCE_INLINE Enum getStatus(const PxRaycastBuffer& r) { return (0xffffffff == r.nbTouches) ? ePENDING : (0xffffffff == r.maxNbTouches ? eOVERFLOW : eSUCCESS); } static PX_FORCE_INLINE Enum getStatus(const PxSweepBuffer& r) { return (0xffffffff == r.nbTouches) ? ePENDING : (0xffffffff == r.maxNbTouches ? eOVERFLOW : eSUCCESS); } static PX_FORCE_INLINE Enum getStatus(const PxOverlapBuffer& r) { return (0xffffffff == r.nbTouches) ? ePENDING : (0xffffffff == r.maxNbTouches ? eOVERFLOW : eSUCCESS); } }; class PxBatchQueryExt { public: virtual void release() = 0; /** \brief Performs a raycast against objects in the scene. \note Touching hits are not ordered. \note Shooting a ray from within an object leads to different results depending on the shape type. Please check the details in article SceneQuery. User can ignore such objects by using one of the provided filter mechanisms. \param[in] origin Origin of the ray. \param[in] unitDir Normalized direction of the ray. \param[in] distance Length of the ray. Needs to be larger than 0. \param[in] maxNbTouches Maximum number of hits to record in the touch buffer for this query. Default=0 reports a single blocking hit. If maxTouchHits is set to 0 all hits are treated as blocking by default. \param[in] hitFlags Specifies which properties per hit should be computed and returned in hit array and blocking hit. \param[in] filterData Filtering data passed to the filter shader. See #PxQueryFilterData #PxQueryFilterCallback \param[in] cache Cached hit shape (optional). Query is tested against cached shape first. If no hit is found the ray gets queried against the scene. Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit. Note: Using past touching hits as cache will produce incorrect behavior since the cached hit will always be treated as blocking. \note This query call writes to a list associated with the query object and is NOT thread safe (for performance reasons there is no lock and overlapping writes from different threads may result in undefined behavior). \return Returns a PxRaycastBuffer pointer that will store the result of the query after execute() is completed. This will point either to an element of the buffer allocated on construction or to a user buffer passed to the constructor. @see PxCreateBatchQueryExt @see PxQueryFilterData PxQueryFilterCallback PxRaycastHit PxScene::raycast */ virtual PxRaycastBuffer* raycast( const PxVec3& origin, const PxVec3& unitDir, const PxReal distance, const PxU16 maxNbTouches = 0, PxHitFlags hitFlags = PxHitFlags(PxHitFlag::eDEFAULT), const PxQueryFilterData& filterData = PxQueryFilterData(), const PxQueryCache* cache = NULL) = 0; /** \brief Performs a sweep test against objects in the scene. \note Touching hits are not ordered. \note If a shape from the scene is already overlapping with the query shape in its starting position, the hit is returned unless eASSUME_NO_INITIAL_OVERLAP was specified. \param[in] geometry Geometry of object to sweep (supported types are: box, sphere, capsule, convex). \param[in] pose Pose of the sweep object. \param[in] unitDir Normalized direction of the sweep. \param[in] distance Sweep distance. Needs to be larger than 0. Will be clamped to PX_MAX_SWEEP_DISTANCE. \param[in] maxNbTouches Maximum number of hits to record in the touch buffer for this query. Default=0 reports a single blocking hit. If maxTouchHits is set to 0 all hits are treated as blocking by default. \param[in] hitFlags Specifies which properties per hit should be computed and returned in hit array and blocking hit. \param[in] filterData Filtering data and simple logic. See #PxQueryFilterData #PxQueryFilterCallback \param[in] cache Cached hit shape (optional). Query is tested against cached shape first. If no hit is found the ray gets queried against the scene. Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit. Note: Using past touching hits as cache will produce incorrect behavior since the cached hit will always be treated as blocking. \param[in] inflation This parameter creates a skin around the swept geometry which increases its extents for sweeping. The sweep will register a hit as soon as the skin touches a shape, and will return the corresponding distance and normal. Note: ePRECISE_SWEEP doesn't support inflation. Therefore the sweep will be performed with zero inflation. \note This query call writes to a list associated with the query object and is NOT thread safe (for performance reasons there is no lock and overlapping writes from different threads may result in undefined behavior). \return Returns a PxSweepBuffer pointer that will store the result of the query after execute() is completed. This will point either to an element of the buffer allocated on construction or to a user buffer passed to the constructor. @see PxCreateBatchQueryExt @see PxHitFlags PxQueryFilterData PxBatchQueryPreFilterShader PxBatchQueryPostFilterShader PxSweepHit */ virtual PxSweepBuffer* sweep( const PxGeometry& geometry, const PxTransform& pose, const PxVec3& unitDir, const PxReal distance, const PxU16 maxNbTouches = 0, PxHitFlags hitFlags = PxHitFlags(PxHitFlag::eDEFAULT), const PxQueryFilterData& filterData = PxQueryFilterData(), const PxQueryCache* cache = NULL, const PxReal inflation = 0.0f) = 0; /** \brief Performs an overlap test of a given geometry against objects in the scene. \note Filtering: returning eBLOCK from user filter for overlap queries will cause a warning (see #PxQueryHitType). \param[in] geometry Geometry of object to check for overlap (supported types are: box, sphere, capsule, convex). \param[in] pose Pose of the object. \param[in] maxNbTouches Maximum number of hits to record in the touch buffer for this query. Default=0 reports a single blocking hit. If maxTouchHits is set to 0 all hits are treated as blocking by default. \param[in] filterData Filtering data and simple logic. See #PxQueryFilterData #PxQueryFilterCallback \param[in] cache Cached hit shape (optional). Query is tested against cached shape first. If no hit is found the ray gets queried against the scene. Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit. Note: Using past touching hits as cache will produce incorrect behavior since the cached hit will always be treated as blocking. \note eBLOCK should not be returned from user filters for overlap(). Doing so will result in undefined behavior, and a warning will be issued. \note If the PxQueryFlag::eNO_BLOCK flag is set, the eBLOCK will instead be automatically converted to an eTOUCH and the warning suppressed. \note This query call writes to a list associated with the query object and is NOT thread safe (for performance reasons there is no lock and overlapping writes from different threads may result in undefined behavior). \return Returns a PxOverlapBuffer pointer that will store the result of the query after execute() is completed. This will point either to an element of the buffer allocated on construction or to a user buffer passed to the constructor. @see PxCreateBatchQueryExt @see PxQueryFilterData PxQueryFilterCallback */ virtual PxOverlapBuffer* overlap( const PxGeometry& geometry, const PxTransform& pose, PxU16 maxNbTouches = 0, const PxQueryFilterData& filterData = PxQueryFilterData(), const PxQueryCache* cache = NULL) = 0; virtual void execute() = 0; protected: virtual ~PxBatchQueryExt() {} }; /** \brief Create a PxBatchQueryExt without the need for pre-allocated result or touch buffers. \param[in] scene Queries will be performed against objects in the specified PxScene \param[in] queryFilterCallback Filtering for all queries is performed using queryFilterCallback. A null pointer results in all shapes being considered. \param[in] maxNbRaycasts A result buffer will be allocated that is large enough to accommodate maxNbRaycasts calls to PxBatchQueryExt::raycast() \param[in] maxNbRaycastTouches A touch buffer will be allocated that is large enough to accommodate maxNbRaycastTouches touches for all raycasts in the batch. \param[in] maxNbSweeps A result buffer will be allocated that is large enough to accommodate maxNbSweeps calls to PxBatchQueryExt::sweep() \param[in] maxNbSweepTouches A touch buffer will be allocated that is large enough to accommodate maxNbSweepTouches touches for all sweeps in the batch. \param[in] maxNbOverlaps A result buffer will be allocated that is large enough to accommodate maxNbOverlaps calls to PxBatchQueryExt::overlap() \param[in] maxNbOverlapTouches A touch buffer will be allocated that is large enough to accommodate maxNbOverlapTouches touches for all overlaps in the batch. \return Returns a PxBatchQueryExt instance. A NULL pointer will be returned if the subsequent allocations fail or if any of the arguments are illegal. In the event that a NULL pointer is returned a corresponding error will be issued to the error stream. */ PxBatchQueryExt* PxCreateBatchQueryExt( const PxScene& scene, PxQueryFilterCallback* queryFilterCallback, const PxU32 maxNbRaycasts, const PxU32 maxNbRaycastTouches, const PxU32 maxNbSweeps, const PxU32 maxNbSweepTouches, const PxU32 maxNbOverlaps, const PxU32 maxNbOverlapTouches); /** \brief Create a PxBatchQueryExt with user-supplied result and touch buffers. \param[in] scene Queries will be performed against objects in the specified PxScene \param[in] queryFilterCallback Filtering for all queries is performed using queryFilterCallback. A null pointer results in all shapes being considered. \param[in] raycastBuffers This is the array that will be used to store the results of each raycast in a batch. \param[in] maxNbRaycasts This is the length of the raycastBuffers array. \param[in] raycastTouches This is the array that will be used to store the touches generated by all raycasts in a batch. \param[in] maxNbRaycastTouches This is the length of the raycastTouches array. \param[in] sweepBuffers This is the array that will be used to store the results of each sweep in a batch. \param[in] maxNbSweeps This is the length of the sweepBuffers array. \param[in] sweepTouches This is the array that will be used to store the touches generated by all sweeps in a batch. \param[in] maxNbSweepTouches This is the length of the sweepTouches array. \param[in] overlapBuffers This is the array that will be used to store the results of each overlap in a batch. \param[in] maxNbOverlaps This is the length of the overlapBuffers array. \param[in] overlapTouches This is the array that will be used to store the touches generated by all overlaps in a batch. \param[in] maxNbOverlapTouches This is the length of the overlapTouches array. \return Returns a PxBatchQueryExt instance. A NULL pointer will be returned if the subsequent allocations fail or if any of the arguments are illegal. In the event that a NULL pointer is returned a corresponding error will be issued to the error stream. */ PxBatchQueryExt* PxCreateBatchQueryExt( const PxScene& scene, PxQueryFilterCallback* queryFilterCallback, PxRaycastBuffer* raycastBuffers, const PxU32 maxNbRaycasts, PxRaycastHit* raycastTouches, const PxU32 maxNbRaycastTouches, PxSweepBuffer* sweepBuffers, const PxU32 maxNbSweeps, PxSweepHit* sweepTouches, const PxU32 maxNbSweepTouches, PxOverlapBuffer* overlapBuffers, const PxU32 maxNbOverlaps, PxOverlapHit* overlapTouches, const PxU32 maxNbOverlapTouches); #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
30,622
C
59.045098
242
0.775619
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxDistanceJoint.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_DISTANCE_JOINT_H #define PX_DISTANCE_JOINT_H /** \addtogroup extensions @{ */ #include "extensions/PxJoint.h" #if !PX_DOXYGEN namespace physx { #endif class PxDistanceJoint; /** \brief Create a distance Joint. \param[in] physics The physics SDK \param[in] actor0 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame \param[in] localFrame0 The position and orientation of the joint relative to actor0 \param[in] actor1 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame \param[in] localFrame1 The position and orientation of the joint relative to actor1 @see PxDistanceJoint */ PxDistanceJoint* PxDistanceJointCreate(PxPhysics& physics, PxRigidActor* actor0, const PxTransform& localFrame0, PxRigidActor* actor1, const PxTransform& localFrame1); /** \brief flags for configuring the drive of a PxDistanceJoint @see PxDistanceJoint */ struct PxDistanceJointFlag { enum Enum { eMAX_DISTANCE_ENABLED = 1<<1, eMIN_DISTANCE_ENABLED = 1<<2, eSPRING_ENABLED = 1<<3 }; }; typedef PxFlags<PxDistanceJointFlag::Enum, PxU16> PxDistanceJointFlags; PX_FLAGS_OPERATORS(PxDistanceJointFlag::Enum, PxU16) /** \brief a joint that maintains an upper or lower bound (or both) on the distance between two points on different objects @see PxDistanceJointCreate PxJoint */ class PxDistanceJoint : public PxJoint { public: /** \brief Return the current distance of the joint */ virtual PxReal getDistance() const = 0; /** \brief Set the allowed minimum distance for the joint. The minimum distance must be no more than the maximum distance <b>Default</b> 0.0f <b>Range</b> [0, PX_MAX_F32) \param[in] distance the minimum distance @see PxDistanceJoint::minDistance, PxDistanceJointFlag::eMIN_DISTANCE_ENABLED getMinDistance() */ virtual void setMinDistance(PxReal distance) = 0; /** \brief Get the allowed minimum distance for the joint. \return the allowed minimum distance @see PxDistanceJoint::minDistance, PxDistanceJointFlag::eMIN_DISTANCE_ENABLED setMinDistance() */ virtual PxReal getMinDistance() const = 0; /** \brief Set the allowed maximum distance for the joint. The maximum distance must be no less than the minimum distance. <b>Default</b> 0.0f <b>Range</b> [0, PX_MAX_F32) \param[in] distance the maximum distance @see PxDistanceJoint::maxDistance, PxDistanceJointFlag::eMAX_DISTANCE_ENABLED getMinDistance() */ virtual void setMaxDistance(PxReal distance) = 0; /** \brief Get the allowed maximum distance for the joint. \return the allowed maximum distance @see PxDistanceJoint::maxDistance, PxDistanceJointFlag::eMAX_DISTANCE_ENABLED setMaxDistance() */ virtual PxReal getMaxDistance() const = 0; /** \brief Set the error tolerance of the joint. \param[in] tolerance the distance beyond the allowed range at which the joint becomes active @see PxDistanceJoint::tolerance, getTolerance() */ virtual void setTolerance(PxReal tolerance) = 0; /** \brief Get the error tolerance of the joint. the distance beyond the joint's [min, max] range before the joint becomes active. <b>Default</b> 0.25f * PxTolerancesScale::length <b>Range</b> (0, PX_MAX_F32) This value should be used to ensure that if the minimum distance is zero and the spring function is in use, the rest length of the spring is non-zero. @see PxDistanceJoint::tolerance, setTolerance() */ virtual PxReal getTolerance() const = 0; /** \brief Set the strength of the joint spring. The spring is used if enabled, and the distance exceeds the range [min-error, max+error]. <b>Default</b> 0.0f <b>Range</b> [0, PX_MAX_F32) \param[in] stiffness the spring strength of the joint @see PxDistanceJointFlag::eSPRING_ENABLED getStiffness() */ virtual void setStiffness(PxReal stiffness) = 0; /** \brief Get the strength of the joint spring. \return stiffness the spring strength of the joint @see PxDistanceJointFlag::eSPRING_ENABLED setStiffness() */ virtual PxReal getStiffness() const = 0; /** \brief Set the damping of the joint spring. The spring is used if enabled, and the distance exceeds the range [min-error, max+error]. <b>Default</b> 0.0f <b>Range</b> [0, PX_MAX_F32) \param[in] damping the degree of damping of the joint spring of the joint @see PxDistanceJointFlag::eSPRING_ENABLED setDamping() */ virtual void setDamping(PxReal damping) = 0; /** \brief Get the damping of the joint spring. \return the degree of damping of the joint spring of the joint @see PxDistanceJointFlag::eSPRING_ENABLED setDamping() */ virtual PxReal getDamping() const = 0; /** \brief Set the flags specific to the Distance Joint. <b>Default</b> PxDistanceJointFlag::eMAX_DISTANCE_ENABLED \param[in] flags The joint flags. @see PxDistanceJointFlag setFlag() getFlags() */ virtual void setDistanceJointFlags(PxDistanceJointFlags flags) = 0; /** \brief Set a single flag specific to a Distance Joint to true or false. \param[in] flag The flag to set or clear. \param[in] value the value to which to set the flag @see PxDistanceJointFlag, getFlags() setFlags() */ virtual void setDistanceJointFlag(PxDistanceJointFlag::Enum flag, bool value) = 0; /** \brief Get the flags specific to the Distance Joint. \return the joint flags @see PxDistanceJoint::flags, PxDistanceJointFlag setFlag() setFlags() */ virtual PxDistanceJointFlags getDistanceJointFlags() const = 0; /** \brief Returns string name of PxDistanceJoint, used for serialization */ virtual const char* getConcreteTypeName() const { return "PxDistanceJoint"; } protected: //serialization /** \brief Constructor */ PX_INLINE PxDistanceJoint(PxType concreteType, PxBaseFlags baseFlags) : PxJoint(concreteType, baseFlags) {} /** \brief Deserialization constructor */ PX_INLINE PxDistanceJoint(PxBaseFlags baseFlags) : PxJoint(baseFlags) {} /** \brief Returns whether a given type name matches with the type of this instance */ virtual bool isKindOf(const char* name) const { PX_IS_KIND_OF(name, "PxDistanceJoint", PxJoint); } //~serialization }; #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
8,026
C
28.840149
167
0.740718
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxPrismaticJoint.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_PRISMATIC_JOINT_H #define PX_PRISMATIC_JOINT_H /** \addtogroup extensions @{ */ #include "extensions/PxJoint.h" #include "extensions/PxJointLimit.h" #if !PX_DOXYGEN namespace physx { #endif class PxPrismaticJoint; /** \brief Create a prismatic joint. \param[in] physics The physics SDK \param[in] actor0 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame \param[in] localFrame0 The position and orientation of the joint relative to actor0 \param[in] actor1 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame \param[in] localFrame1 The position and orientation of the joint relative to actor1 @see PxPrismaticJoint */ PxPrismaticJoint* PxPrismaticJointCreate(PxPhysics& physics, PxRigidActor* actor0, const PxTransform& localFrame0, PxRigidActor* actor1, const PxTransform& localFrame1); /** \brief Flags specific to the prismatic joint. @see PxPrismaticJoint */ struct PxPrismaticJointFlag { enum Enum { eLIMIT_ENABLED = 1<<1 }; }; typedef PxFlags<PxPrismaticJointFlag::Enum, PxU16> PxPrismaticJointFlags; PX_FLAGS_OPERATORS(PxPrismaticJointFlag::Enum, PxU16) /** \brief A prismatic joint permits relative translational movement between two bodies along an axis, but no relative rotational movement. the axis on each body is defined as the line containing the origin of the joint frame and extending along the x-axis of that frame \image html prismJoint.png @see PxPrismaticJointCreate() PxJoint */ class PxPrismaticJoint : public PxJoint { public: /** \brief returns the displacement of the joint along its axis. */ virtual PxReal getPosition() const = 0; /** \brief returns the velocity of the joint along its axis */ virtual PxReal getVelocity() const = 0; /** \brief sets the joint limit parameters. The limit range is [-PX_MAX_F32, PX_MAX_F32], but note that the width of the limit (upper-lower) must also be a valid float. @see PxJointLinearLimitPair getLimit() */ virtual void setLimit(const PxJointLinearLimitPair&) = 0; /** \brief gets the joint limit parameters. @see PxJointLinearLimit getLimit() */ virtual PxJointLinearLimitPair getLimit() const = 0; /** \brief Set the flags specific to the Prismatic Joint. <b>Default</b> PxPrismaticJointFlags(0) \param[in] flags The joint flags. @see PxPrismaticJointFlag setFlag() getFlags() */ virtual void setPrismaticJointFlags(PxPrismaticJointFlags flags) = 0; /** \brief Set a single flag specific to a Prismatic Joint to true or false. \param[in] flag The flag to set or clear. \param[in] value The value to which to set the flag @see PxPrismaticJointFlag, getFlags() setFlags() */ virtual void setPrismaticJointFlag(PxPrismaticJointFlag::Enum flag, bool value) = 0; /** \brief Get the flags specific to the Prismatic Joint. \return the joint flags @see PxPrismaticJoint::flags, PxPrismaticJointFlag setFlag() setFlags() */ virtual PxPrismaticJointFlags getPrismaticJointFlags() const = 0; /** \brief Returns string name of PxPrismaticJoint, used for serialization */ virtual const char* getConcreteTypeName() const { return "PxPrismaticJoint"; } protected: //serialization /** \brief Constructor */ PX_INLINE PxPrismaticJoint(PxType concreteType, PxBaseFlags baseFlags) : PxJoint(concreteType, baseFlags) {} /** \brief Deserialization constructor */ PX_INLINE PxPrismaticJoint(PxBaseFlags baseFlags) : PxJoint(baseFlags) {} /** \brief Returns whether a given type name matches with the type of this instance */ virtual bool isKindOf(const char* name) const { PX_IS_KIND_OF(name, "PxPrismaticJoint", PxJoint); } //~serialization }; #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
5,545
C
29.98324
169
0.750586
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxRepXSimpleType.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_REPX_SIMPLE_TYPE_H #define PX_REPX_SIMPLE_TYPE_H /** \addtogroup extensions @{ */ #include "foundation/PxSimpleTypes.h" #include "cooking/PxCooking.h" #include "common/PxStringTable.h" #include "common/PxSerialFramework.h" #if !PX_DOXYGEN namespace physx { #endif /** \brief Helper class containing the mapping of id to object, and type name. \deprecated Xml serialization is deprecated. An alternative serialization system is provided through USD Physics. */ struct PX_DEPRECATED PxRepXObject { /** \brief Identifies the extension meant to handle this object. @see PxTypeInfo, PX_DEFINE_TYPEINFO, PxRepXSerializer */ const char* typeName; /** \brief Pointer to the serializable this was created from */ const void* serializable; /** \brief Id given to this object at some point */ PxSerialObjectId id; PxRepXObject( const char* inTypeName = "", const void* inSerializable = NULL, const PxSerialObjectId inId = 0 ) : typeName( inTypeName ) , serializable( inSerializable ) , id( inId ) { } bool isValid() const { return serializable != NULL; } }; /** \brief Arguments required to instantiate a serializable object from RepX. \deprecated Xml serialization is deprecated. An alternative serialization system is provided through USD Physics. Extra arguments can be added to the object map under special ids. @see PxRepXSerializer::objectToFile, PxRepXSerializer::fileToObject */ struct PX_DEPRECATED PxRepXInstantiationArgs { PxPhysics& physics; const PxCookingParams* cooker; PxStringTable* stringTable; PxRepXInstantiationArgs( PxPhysics& inPhysics, const PxCookingParams* inCooking = NULL , PxStringTable* inStringTable = NULL ) : physics( inPhysics ) , cooker( inCooking ) , stringTable( inStringTable ) { } PxRepXInstantiationArgs& operator=(const PxRepXInstantiationArgs&); }; #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
3,661
C
32.907407
129
0.746244
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxDefaultStreams.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_DEFAULT_STREAMS_H #define PX_DEFAULT_STREAMS_H /** \addtogroup extensions @{ */ #include <stdio.h> #include "common/PxPhysXCommonConfig.h" #include "foundation/PxIO.h" #include "foundation/PxFoundation.h" typedef FILE* PxFileHandle; #if !PX_DOXYGEN namespace physx { #endif /** \brief default implementation of a memory write stream @see PxOutputStream */ class PxDefaultMemoryOutputStream: public PxOutputStream { public: PxDefaultMemoryOutputStream(PxAllocatorCallback &allocator = *PxGetAllocatorCallback()); virtual ~PxDefaultMemoryOutputStream(); virtual PxU32 write(const void* src, PxU32 count); virtual PxU32 getSize() const { return mSize; } virtual PxU8* getData() const { return mData; } private: PxDefaultMemoryOutputStream(const PxDefaultMemoryOutputStream&); PxDefaultMemoryOutputStream& operator=(const PxDefaultMemoryOutputStream&); PxAllocatorCallback& mAllocator; PxU8* mData; PxU32 mSize; PxU32 mCapacity; }; /** \brief default implementation of a memory read stream @see PxInputData */ class PxDefaultMemoryInputData: public PxInputData { public: PxDefaultMemoryInputData(PxU8* data, PxU32 length); virtual PxU32 read(void* dest, PxU32 count); virtual PxU32 getLength() const; virtual void seek(PxU32 pos); virtual PxU32 tell() const; private: PxU32 mSize; const PxU8* mData; PxU32 mPos; }; /** \brief default implementation of a file write stream @see PxOutputStream */ class PxDefaultFileOutputStream: public PxOutputStream { public: PxDefaultFileOutputStream(const char* name); virtual ~PxDefaultFileOutputStream(); virtual PxU32 write(const void* src, PxU32 count); virtual bool isValid(); private: PxFileHandle mFile; }; /** \brief default implementation of a file read stream @see PxInputData */ class PxDefaultFileInputData: public PxInputData { public: PxDefaultFileInputData(const char* name); virtual ~PxDefaultFileInputData(); virtual PxU32 read(void* dest, PxU32 count); virtual void seek(PxU32 pos); virtual PxU32 tell() const; virtual PxU32 getLength() const; bool isValid() const; private: PxFileHandle mFile; PxU32 mLength; }; #if !PX_DOXYGEN } #endif /** @} */ #endif
3,962
C
25.777027
94
0.748864
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxMassProperties.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_MASS_PROPERTIES_H #define PX_MASS_PROPERTIES_H /** \addtogroup extensions @{ */ #include "PxPhysXConfig.h" #include "foundation/PxMath.h" #include "foundation/PxMathUtils.h" #include "foundation/PxVec3.h" #include "foundation/PxMat33.h" #include "foundation/PxQuat.h" #include "foundation/PxTransform.h" #include "geometry/PxGeometry.h" #include "geometry/PxBoxGeometry.h" #include "geometry/PxSphereGeometry.h" #include "geometry/PxCapsuleGeometry.h" #include "geometry/PxConvexMeshGeometry.h" #include "geometry/PxConvexMesh.h" #include "geometry/PxCustomGeometry.h" #include "geometry/PxTriangleMeshGeometry.h" #include "geometry/PxTriangleMesh.h" #if !PX_DOXYGEN namespace physx { #endif /** \brief Utility class to compute and manipulate mass and inertia tensor properties. In most cases #PxRigidBodyExt::updateMassAndInertia(), #PxRigidBodyExt::setMassAndUpdateInertia() should be enough to setup the mass properties of a rigid body. This utility class targets users that need to customize the mass properties computation. */ class PxMassProperties { public: /** \brief Default constructor. */ PX_FORCE_INLINE PxMassProperties() : inertiaTensor(PxIdentity), centerOfMass(0.0f), mass(1.0f) {} /** \brief Construct from individual elements. */ PX_FORCE_INLINE PxMassProperties(const PxReal m, const PxMat33& inertiaT, const PxVec3& com) : inertiaTensor(inertiaT), centerOfMass(com), mass(m) {} /** \brief Compute mass properties based on a provided geometry structure. This constructor assumes the geometry has a density of 1. Mass and inertia tensor scale linearly with density. \param[in] geometry The geometry to compute the mass properties for. Supported geometry types are: sphere, box, capsule and convex mesh. */ PxMassProperties(const PxGeometry& geometry) { switch (geometry.getType()) { case PxGeometryType::eSPHERE: { const PxSphereGeometry& s = static_cast<const PxSphereGeometry&>(geometry); mass = (4.0f / 3.0f) * PxPi * s.radius * s.radius * s.radius; inertiaTensor = PxMat33::createDiagonal(PxVec3(2.0f / 5.0f * mass * s.radius * s.radius)); centerOfMass = PxVec3(0.0f); } break; case PxGeometryType::eBOX: { const PxBoxGeometry& b = static_cast<const PxBoxGeometry&>(geometry); mass = b.halfExtents.x * b.halfExtents.y * b.halfExtents.z * 8.0f; PxVec3 d2 = b.halfExtents.multiply(b.halfExtents); inertiaTensor = PxMat33::createDiagonal(PxVec3(d2.y + d2.z, d2.x + d2.z, d2.x + d2.y)) * (mass * 1.0f / 3.0f); centerOfMass = PxVec3(0.0f); } break; case PxGeometryType::eCAPSULE: { const PxCapsuleGeometry& c = static_cast<const PxCapsuleGeometry&>(geometry); PxReal r = c.radius, h = c.halfHeight; mass = ((4.0f / 3.0f) * r + 2 * c.halfHeight) * PxPi * r * r; PxReal a = r*r*r * (8.0f / 15.0f) + h*r*r * (3.0f / 2.0f) + h*h*r * (4.0f / 3.0f) + h*h*h * (2.0f / 3.0f); PxReal b = r*r*r * (8.0f / 15.0f) + h*r*r; inertiaTensor = PxMat33::createDiagonal(PxVec3(b, a, a) * PxPi * r * r); centerOfMass = PxVec3(0.0f); } break; case PxGeometryType::eCONVEXMESH: { const PxConvexMeshGeometry& c = static_cast<const PxConvexMeshGeometry&>(geometry); PxVec3 unscaledCoM; PxMat33 unscaledInertiaTensorNonCOM; // inertia tensor of convex mesh in mesh local space PxMat33 unscaledInertiaTensorCOM; PxReal unscaledMass; c.convexMesh->getMassInformation(unscaledMass, unscaledInertiaTensorNonCOM, unscaledCoM); // inertia tensor relative to center of mass unscaledInertiaTensorCOM[0][0] = unscaledInertiaTensorNonCOM[0][0] - unscaledMass*PxReal((unscaledCoM.y*unscaledCoM.y+unscaledCoM.z*unscaledCoM.z)); unscaledInertiaTensorCOM[1][1] = unscaledInertiaTensorNonCOM[1][1] - unscaledMass*PxReal((unscaledCoM.z*unscaledCoM.z+unscaledCoM.x*unscaledCoM.x)); unscaledInertiaTensorCOM[2][2] = unscaledInertiaTensorNonCOM[2][2] - unscaledMass*PxReal((unscaledCoM.x*unscaledCoM.x+unscaledCoM.y*unscaledCoM.y)); unscaledInertiaTensorCOM[0][1] = unscaledInertiaTensorCOM[1][0] = (unscaledInertiaTensorNonCOM[0][1] + unscaledMass*PxReal(unscaledCoM.x*unscaledCoM.y)); unscaledInertiaTensorCOM[1][2] = unscaledInertiaTensorCOM[2][1] = (unscaledInertiaTensorNonCOM[1][2] + unscaledMass*PxReal(unscaledCoM.y*unscaledCoM.z)); unscaledInertiaTensorCOM[0][2] = unscaledInertiaTensorCOM[2][0] = (unscaledInertiaTensorNonCOM[0][2] + unscaledMass*PxReal(unscaledCoM.z*unscaledCoM.x)); const PxMeshScale& s = c.scale; mass = unscaledMass * s.scale.x * s.scale.y * s.scale.z; centerOfMass = s.transform(unscaledCoM); inertiaTensor = scaleInertia(unscaledInertiaTensorCOM, s.rotation, s.scale); } break; case PxGeometryType::eCUSTOM: { *this = PxMassProperties(); static_cast<const PxCustomGeometry&>(geometry).callbacks->computeMassProperties(geometry, *this); } break; case PxGeometryType::eTRIANGLEMESH: { const PxTriangleMeshGeometry& g = static_cast<const PxTriangleMeshGeometry&>(geometry); PxVec3 unscaledCoM; PxMat33 unscaledInertiaTensorNonCOM; // inertia tensor of convex mesh in mesh local space PxMat33 unscaledInertiaTensorCOM; PxReal unscaledMass; g.triangleMesh->getMassInformation(unscaledMass, unscaledInertiaTensorNonCOM, unscaledCoM); // inertia tensor relative to center of mass unscaledInertiaTensorCOM[0][0] = unscaledInertiaTensorNonCOM[0][0] - unscaledMass * PxReal((unscaledCoM.y*unscaledCoM.y + unscaledCoM.z*unscaledCoM.z)); unscaledInertiaTensorCOM[1][1] = unscaledInertiaTensorNonCOM[1][1] - unscaledMass * PxReal((unscaledCoM.z*unscaledCoM.z + unscaledCoM.x*unscaledCoM.x)); unscaledInertiaTensorCOM[2][2] = unscaledInertiaTensorNonCOM[2][2] - unscaledMass * PxReal((unscaledCoM.x*unscaledCoM.x + unscaledCoM.y*unscaledCoM.y)); unscaledInertiaTensorCOM[0][1] = unscaledInertiaTensorCOM[1][0] = (unscaledInertiaTensorNonCOM[0][1] + unscaledMass * PxReal(unscaledCoM.x*unscaledCoM.y)); unscaledInertiaTensorCOM[1][2] = unscaledInertiaTensorCOM[2][1] = (unscaledInertiaTensorNonCOM[1][2] + unscaledMass * PxReal(unscaledCoM.y*unscaledCoM.z)); unscaledInertiaTensorCOM[0][2] = unscaledInertiaTensorCOM[2][0] = (unscaledInertiaTensorNonCOM[0][2] + unscaledMass * PxReal(unscaledCoM.z*unscaledCoM.x)); const PxMeshScale& s = g.scale; mass = unscaledMass * s.scale.x * s.scale.y * s.scale.z; centerOfMass = s.transform(unscaledCoM); inertiaTensor = scaleInertia(unscaledInertiaTensorCOM, s.rotation, s.scale); } break; default: { *this = PxMassProperties(); } } PX_ASSERT(inertiaTensor.column0.isFinite() && inertiaTensor.column1.isFinite() && inertiaTensor.column2.isFinite()); PX_ASSERT(centerOfMass.isFinite()); PX_ASSERT(PxIsFinite(mass)); } /** \brief Scale mass properties. \param[in] scale The linear scaling factor to apply to the mass properties. \return The scaled mass properties. */ PX_FORCE_INLINE PxMassProperties operator*(const PxReal scale) const { PX_ASSERT(PxIsFinite(scale)); return PxMassProperties(mass * scale, inertiaTensor * scale, centerOfMass); } /** \brief Translate the center of mass by a given vector and adjust the inertia tensor accordingly. \param[in] t The translation vector for the center of mass. */ PX_FORCE_INLINE void translate(const PxVec3& t) { PX_ASSERT(t.isFinite()); inertiaTensor = translateInertia(inertiaTensor, mass, t); centerOfMass += t; PX_ASSERT(inertiaTensor.column0.isFinite() && inertiaTensor.column1.isFinite() && inertiaTensor.column2.isFinite()); PX_ASSERT(centerOfMass.isFinite()); } /** \brief Get the entries of the diagonalized inertia tensor and the corresponding reference rotation. \param[in] inertia The inertia tensor to diagonalize. \param[out] massFrame The frame the diagonalized tensor refers to. \return The entries of the diagonalized inertia tensor. */ PX_FORCE_INLINE static PxVec3 getMassSpaceInertia(const PxMat33& inertia, PxQuat& massFrame) { PX_ASSERT(inertia.column0.isFinite() && inertia.column1.isFinite() && inertia.column2.isFinite()); PxVec3 diagT = PxDiagonalize(inertia, massFrame); PX_ASSERT(diagT.isFinite()); PX_ASSERT(massFrame.isFinite()); return diagT; } /** \brief Translate an inertia tensor using the parallel axis theorem \param[in] inertia The inertia tensor to translate. \param[in] mass The mass of the object. \param[in] t The relative frame to translate the inertia tensor to. \return The translated inertia tensor. */ PX_FORCE_INLINE static PxMat33 translateInertia(const PxMat33& inertia, const PxReal mass, const PxVec3& t) { PX_ASSERT(inertia.column0.isFinite() && inertia.column1.isFinite() && inertia.column2.isFinite()); PX_ASSERT(PxIsFinite(mass)); PX_ASSERT(t.isFinite()); PxMat33 s( PxVec3(0,t.z,-t.y), PxVec3(-t.z,0,t.x), PxVec3(t.y,-t.x,0) ); PxMat33 translatedIT = s.getTranspose() * s * mass + inertia; PX_ASSERT(translatedIT.column0.isFinite() && translatedIT.column1.isFinite() && translatedIT.column2.isFinite()); return translatedIT; } /** \brief Rotate an inertia tensor around the center of mass \param[in] inertia The inertia tensor to rotate. \param[in] q The rotation from the new to the old coordinate frame, i.e. q.rotate(v) transforms the coordinates of vector v from the old to the new coordinate frame. \return The rotated inertia tensor. */ PX_FORCE_INLINE static PxMat33 rotateInertia(const PxMat33& inertia, const PxQuat& q) { PX_ASSERT(inertia.column0.isFinite() && inertia.column1.isFinite() && inertia.column2.isFinite()); PX_ASSERT(q.isUnit()); PxMat33 m(q); PxMat33 rotatedIT = m * inertia * m.getTranspose(); PX_ASSERT(rotatedIT.column0.isFinite() && rotatedIT.column1.isFinite() && rotatedIT.column2.isFinite()); return rotatedIT; } /** \brief Non-uniform scaling of the inertia tensor \param[in] inertia The inertia tensor to scale. \param[in] scaleRotation The rotation from the scaling frame to the frame that inertia is expressed in. I.e. scaleRotation.rotate(v) transforms the coordinates of vertex v from inertia's frame to the scaling-axes frame. \param[in] scale The scaling factor for each axis (relative to the frame specified with scaleRotation). \return The scaled inertia tensor. */ static PxMat33 scaleInertia(const PxMat33& inertia, const PxQuat& scaleRotation, const PxVec3& scale) { PX_ASSERT(inertia.column0.isFinite() && inertia.column1.isFinite() && inertia.column2.isFinite()); PX_ASSERT(scaleRotation.isUnit()); PX_ASSERT(scale.isFinite()); PxMat33 localInertiaT = rotateInertia(inertia, scaleRotation); // rotate inertia into scaling frame PxVec3 diagonal(localInertiaT[0][0], localInertiaT[1][1], localInertiaT[2][2]); PxVec3 xyz2 = PxVec3(diagonal.dot(PxVec3(0.5f))) - diagonal; // original x^2, y^2, z^2 PxVec3 scaledxyz2 = xyz2.multiply(scale).multiply(scale); PxReal xx = scaledxyz2.y + scaledxyz2.z, yy = scaledxyz2.z + scaledxyz2.x, zz = scaledxyz2.x + scaledxyz2.y; PxReal xy = localInertiaT[0][1] * scale.x * scale.y, xz = localInertiaT[0][2] * scale.x * scale.z, yz = localInertiaT[1][2] * scale.y * scale.z; PxMat33 scaledInertia( PxVec3(xx, xy, xz), PxVec3(xy, yy, yz), PxVec3(xz, yz, zz)); PxMat33 scaledIT = rotateInertia(scaledInertia * (scale.x * scale.y * scale.z), scaleRotation.getConjugate()); PX_ASSERT(scaledIT.column0.isFinite() && scaledIT.column1.isFinite() && scaledIT.column2.isFinite()); return scaledIT; } /** \brief Sum up individual mass properties. \param[in] props Array of mass properties to sum up. \param[in] transforms Reference transforms for each mass properties entry. \param[in] count The number of mass properties to sum up. \return The summed up mass properties. */ static PxMassProperties sum(const PxMassProperties* props, const PxTransform* transforms, const PxU32 count) { PxReal combinedMass = 0.0f; PxVec3 combinedCoM(0.0f); PxMat33 combinedInertiaT = PxMat33(PxZero); for(PxU32 i = 0; i < count; i++) { PX_ASSERT(props[i].inertiaTensor.column0.isFinite() && props[i].inertiaTensor.column1.isFinite() && props[i].inertiaTensor.column2.isFinite()); PX_ASSERT(props[i].centerOfMass.isFinite()); PX_ASSERT(PxIsFinite(props[i].mass)); combinedMass += props[i].mass; const PxVec3 comTm = transforms[i].transform(props[i].centerOfMass); combinedCoM += comTm * props[i].mass; } if(combinedMass > 0.f) combinedCoM /= combinedMass; for(PxU32 i = 0; i < count; i++) { const PxVec3 comTm = transforms[i].transform(props[i].centerOfMass); combinedInertiaT += translateInertia(rotateInertia(props[i].inertiaTensor, transforms[i].q), props[i].mass, combinedCoM - comTm); } PX_ASSERT(combinedInertiaT.column0.isFinite() && combinedInertiaT.column1.isFinite() && combinedInertiaT.column2.isFinite()); PX_ASSERT(combinedCoM.isFinite()); PX_ASSERT(PxIsFinite(combinedMass)); return PxMassProperties(combinedMass, combinedInertiaT, combinedCoM); } PxMat33 inertiaTensor; //!< The inertia tensor of the object. PxVec3 centerOfMass; //!< The center of mass of the object. PxReal mass; //!< The mass of the object. }; #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
15,019
C
40.038251
159
0.731873
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxTetMakerExt.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_TETMAKER_EXT_H #define PX_TETMAKER_EXT_H /** \addtogroup extensions @{ */ #include "foundation/PxSimpleTypes.h" #include "foundation/PxVec3.h" #include "common/PxCoreUtilityTypes.h" #include "foundation/PxArray.h" #include "PxTriangleMeshAnalysisResult.h" #include "PxTetrahedronMeshAnalysisResult.h" #if !PX_DOXYGEN namespace physx { #endif class PxTriangleMesh; class PxTetrahedronMeshDesc; class PxSoftBodySimulationDataDesc; struct PxTetMakerData; class PxSimpleTriangleMesh; /** \brief Provides functionality to create a tetrahedral mesh from a triangle mesh. */ class PxTetMaker { public: /** \brief Create conforming tetrahedron mesh using TetMaker \param[in] triangleMesh The description of the triangle mesh including vertices and indices \param[out] outVertices The vertices to store the conforming tetrahedral mesh \param[out] outTetIndices The indices to store the conforming tetrahedral mesh \param[in] validate If set to true the input triangle mesh will get analyzed to find possible deficiencies \param[in] volumeThreshold Tetrahedra with a volume smaller than the specified threshold will be removed from the mesh \return True if success */ static bool createConformingTetrahedronMesh(const PxSimpleTriangleMesh& triangleMesh, physx::PxArray<physx::PxVec3>& outVertices, physx::PxArray<physx::PxU32>& outTetIndices, const bool validate = true, PxReal volumeThreshold = 0.0f); /** \brief Create voxel-based tetrahedron mesh using TetMaker \param[in] tetMesh The description of the tetrahedral mesh including vertices and indices \param[in] numVoxelsAlongLongestBoundingBoxAxis The number of voxels along the longest bounding box axis \param[out] outVertices The vertices to store the voxel-based tetrahedral mesh \param[out] outTetIndices The indices to store the voxel-based tetrahedral mesh \param[out] inputPointToOutputTetIndex Buffer with the size of nbTetVerts that contains the tetrahedron index containing the input point with the same index \param[in] anchorNodeIndices Some input vertices may not be referenced by any tetrahedron. They can be mapped to another input vertex that is used by a tetrahedron to support embedding of additional points. \param[in] numTetsPerVoxel The number of tetrahedra used to fill a voxel. Only a value of 5 or 6 is supported. 5 is recommended because it mostly avoids mesh anisotropy. \return True if success */ static bool createVoxelTetrahedronMesh(const PxTetrahedronMeshDesc& tetMesh, const PxU32 numVoxelsAlongLongestBoundingBoxAxis, physx::PxArray<physx::PxVec3>& outVertices, physx::PxArray<physx::PxU32>& outTetIndices, PxI32* inputPointToOutputTetIndex = NULL, const PxU32* anchorNodeIndices = NULL, PxU32 numTetsPerVoxel = 5); /** \brief Create voxel-based tetrahedron mesh using TetMaker \param[in] tetMesh The description of the tetrahedral mesh including vertices and indices \param[in] voxelEdgeLength The edge length of a voxel.Can be adjusted slightly such that a multiple of it matches the input points' bounding box size \param[out] outVertices The vertices to store the voxel-based tetrahedral mesh \param[out] outTetIndices The indices to store the voxel-based tetrahedral mesh \param[out] inputPointToOutputTetIndex Buffer with the size of nbTetVerts that contains the tetrahedron index containing the input point with the same index \param[in] anchorNodeIndices Some input vertices may not be referenced by any tetrahedron. They can be mapped to another input vertex that is used by a tetrahedron to support embedding of additional points. \param[in] numTetsPerVoxel The number of tetrahedra used to fill a voxel. Only a value of 5 or 6 is supported. 5 is recommended because it mostly avoids mesh anisotropy. \return True if success */ static bool createVoxelTetrahedronMeshFromEdgeLength(const PxTetrahedronMeshDesc& tetMesh, const PxReal voxelEdgeLength, physx::PxArray<physx::PxVec3>& outVertices, physx::PxArray<physx::PxU32>& outTetIndices, PxI32* inputPointToOutputTetIndex = NULL, const PxU32* anchorNodeIndices = NULL, PxU32 numTetsPerVoxel = 5); /** \brief Analyzes the triangle mesh to get a report about deficiencies. Some deficiencies can be handled by the tetmesher, others cannot. \param[in] triangleMesh The description of the triangle mesh including vertices and indices \param[in] minVolumeThreshold Minimum volume the mesh must have such that no volume warning is generated \param[in] minTriangleAngleRadians Minimum angle allowed for triangles such that no angle warning is generated \return Flags that describe the triangle mesh's deficiencies */ static PxTriangleMeshAnalysisResults validateTriangleMesh(const PxSimpleTriangleMesh& triangleMesh, const PxReal minVolumeThreshold = 1e-6f, const PxReal minTriangleAngleRadians = 10.0f*3.1415926535898f / 180.0f); /** \brief Analyzes the tetrahedron mesh to get a report about deficiencies. Some deficiencies can be handled by the softbody cooker, others cannot. \param[in] points The mesh's points \param[in] tetrahedra The mesh's tetrahedra (index buffer) \param[in] minTetVolumeThreshold Minimum volume every tetrahedron in the mesh must have such that no volume warning is generated \return Flags that describe the tetrahedron mesh's deficiencies */ static PxTetrahedronMeshAnalysisResults validateTetrahedronMesh(const PxBoundedData& points, const PxBoundedData& tetrahedra, const PxReal minTetVolumeThreshold = 1e-8f); /** \brief Simplifies (decimates) a triangle mesh using quadric simplification. \param[in] inputVertices The vertices of the input triangle mesh \param[in] inputIndices The indices of the input triangle mesh of the form (id0, id1, id2), (id0, id1, id2), .. \param[in] targetTriangleCount Desired number of triangles in the output mesh \param[in] maximalEdgeLength Edges below this length will not be collapsed. A value of zero means there is no limit. \param[out] outputVertices The vertices of the output (decimated) triangle mesh \param[out] outputIndices The indices of the output (decimated) triangle mesh of the form (id0, id1, id2), (id0, id1, id2), .. \param[out] vertexMap Optional parameter which returns the mapping from input to output vertices. Note that multiple input vertices are typically collapsed into the same output vertex. \param[in] edgeLengthCostWeight Factor to scale influence of edge length when prioritizing edge collapses. Has no effect if set to zero. \param[in] flatnessDetectionThreshold Threshold used to detect edges in flat regions and to improve the placement of the collapsed point. If set to a large value it will have no effect. \param[in] projectSimplifiedPointsOnInputMeshSurface If set to true, the simplified points will lie exactly on the original surface. \param[out] outputVertexToInputTriangle Optional indices providing the triangle index per resulting vertex. Only available when projectSimplifiedPointsOnInputMeshSurface is set to true \param[in] removeDisconnectedPatches Enables the optional removal of disconnected triangles in the mesh. Only the largest connected set/patch will be kept */ static void simplifyTriangleMesh(const PxArray<PxVec3>& inputVertices, const PxArray<PxU32>&inputIndices, int targetTriangleCount, PxF32 maximalEdgeLength, PxArray<PxVec3>& outputVertices, PxArray<PxU32>& outputIndices, PxArray<PxU32> *vertexMap = NULL, PxReal edgeLengthCostWeight = 0.1f, PxReal flatnessDetectionThreshold = 0.01f, bool projectSimplifiedPointsOnInputMeshSurface = false, PxArray<PxU32>* outputVertexToInputTriangle = NULL, bool removeDisconnectedPatches = false); /** \brief Creates a new mesh from a given mesh. The input mesh is first voxelized. The new surface is created from the voxel surface and subsequent projection to the original mesh. \param[in] inputVertices The vertices of the input triangle mesh \param[in] inputIndices The indices of the input triangle mesh of the form (id0, id1, id2), (id0, id1, id2), .. \param[in] gridResolution Size of the voxel grid (number of voxels along the longest dimension) \param[out] outputVertices The vertices of the output (decimated) triangle mesh \param[out] outputIndices The indices of the output (decimated) triangle mesh of the form (id0, id1, id2), (id0, id1, id2), .. \param[out] vertexMap Optional parameter which returns a mapping from input to output vertices. Since the meshes are independent, the mapping returns an output vertex that is topologically close to the input vertex. */ static void remeshTriangleMesh(const PxArray<PxVec3>& inputVertices, const PxArray<PxU32>&inputIndices, PxU32 gridResolution, PxArray<PxVec3>& outputVertices, PxArray<PxU32>& outputIndices, PxArray<PxU32> *vertexMap = NULL); /** \brief Creates a new mesh from a given mesh. The input mesh is first voxelized. The new surface is created from the voxel surface and subsequent projection to the original mesh. \param[in] inputVertices The vertices of the input triangle mesh \param[in] nbVertices The number of vertices of the input triangle mesh \param[in] inputIndices The indices of the input triangle mesh of the form (id0, id1, id2), (id0, id1, id2), .. \param[in] nbIndices The number of indices of the input triangle mesh (equal to three times the number of triangles) \param[in] gridResolution Size of the voxel grid (number of voxels along the longest dimension) \param[out] outputVertices The vertices of the output (decimated) triangle mesh \param[out] outputIndices The indices of the output (decimated) triangle mesh of the form (id0, id1, id2), (id0, id1, id2), .. \param[out] vertexMap Optional parameter which returns a mapping from input to output vertices. Since the meshes are independent, the mapping returns an output vertex that is topologically close to the input vertex. */ static void remeshTriangleMesh(const PxVec3* inputVertices, PxU32 nbVertices, const PxU32* inputIndices, PxU32 nbIndices, PxU32 gridResolution, PxArray<PxVec3>& outputVertices, PxArray<PxU32>& outputIndices, PxArray<PxU32> *vertexMap = NULL); /** \brief Creates a tetrahedral mesh using an octree. \param[in] inputVertices The vertices of the input triangle mesh \param[in] inputIndices The indices of the input triangle mesh of the form (id0, id1, id2), (id0, id1, id2), .. \param[in] useTreeNodes Using the nodes of the octree as tetrahedral vertices \param[out] outputVertices The vertices of the output tetrahedral mesh \param[out] outputIndices The indices of the output tetrahedral mesh of the form (id0, id1, id2, id3), (id0, id1, id2, id3), .. \param[in] volumeThreshold Tetrahedra with a volume smaller than the specified threshold will be removed from the mesh */ static void createTreeBasedTetrahedralMesh(const PxArray<PxVec3>& inputVertices, const PxArray<PxU32>&inputIndices, bool useTreeNodes, PxArray<PxVec3>& outputVertices, PxArray<PxU32>& outputIndices, PxReal volumeThreshold = 0.0f); /** \brief Creates a tetrahedral mesh by relaxing a voxel mesh around the input mesh \param[in] inputVertices The vertices of the input triangle mesh \param[in] inputIndices The indices of the input triangle mesh of the form (id0, id1, id2), (id0, id1, id2), .. \param[out] outputVertices The vertices of the output tetrahedral mesh \param[out] outputIndices The indices of the output tetrahedral mesh of the form (id0, id1, id2, id3), (id0, id1, id2, id3), .. \param[in] resolution The grid spacing is computed as the diagonal of the bounding box of the input mesh divided by the resolution. \param[in] numRelaxationIterations Number of iterations to pull the tetrahedral mesh towards the input mesh \param[in] relMinTetVolume Constrains the volumes of the tetrahedra to stay abobe relMinTetvolume times the tetrahedron's rest volume. */ static void createRelaxedVoxelTetrahedralMesh(const PxArray<PxVec3>& inputVertices, const PxArray<PxU32>&inputIndices, PxArray<PxVec3>& outputVertices, PxArray<PxU32>& outputIndices, PxI32 resolution, PxI32 numRelaxationIterations = 5, PxF32 relMinTetVolume = 0.05f); /** \brief Creates a tetrahedral mesh by relaxing a voxel mesh around the input mesh \param[in] triangles The indices of the input triangle mesh of the form (id0, id1, id2), (id0, id1, id2), .. \param[in] numTriangles The number of triangles \param[out] islandIndexPerTriangle Every triangle gets an island index assigned. Triangles with the same island index belong to the same patch of connected triangles. */ static void detectTriangleIslands(const PxI32* triangles, PxU32 numTriangles, PxArray<PxU32>& islandIndexPerTriangle); /** \brief Creates a tetrahedral mesh by relaxing a voxel mesh around the input mesh \param[in] islandIndexPerTriangle An island marker per triangles. All triangles with the same marker belong to an island. Can becomputed using the method detectTriangleIslands. \param[in] numTriangles The number of triangles \return The marker value of the island that contains the most triangles */ static PxU32 findLargestIslandId(const PxU32* islandIndexPerTriangle, PxU32 numTriangles); }; #if !PX_DOXYGEN } #endif /** @} */ #endif
14,854
C
64.730088
216
0.790359
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxTriangleMeshAnalysisResult.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. #ifndef PX_TRIANGLE_MESH_ANALYSIS_RESULT_H #define PX_TRIANGLE_MESH_ANALYSIS_RESULT_H #include "PxPhysXConfig.h" #include "foundation/PxFlags.h" #if !PX_DOXYGEN namespace physx { #endif /** \brief These flags indicate what kind of deficiencies a triangle mesh has and describe if the mesh is considered ok, problematic or invalid for tetmeshing */ class PxTriangleMeshAnalysisResult { public: enum Enum { eVALID = 0, eZERO_VOLUME = (1 << 0), //!< invalid: Flat mesh without meaningful amount of volume - cannot be meshed since a tetmesh is volumetric eOPEN_BOUNDARIES = (1 << 1), //!< problematic: Open boundary means that the mesh is not watertight and that there are holes. The mesher can fill holes but the surface might have an unexpected shape where the hole was. eSELF_INTERSECTIONS = (1 << 2), //!< problematic: The surface of the resulting mesh won't match exactly at locations of self-intersections. The tetmesh might be connected at self-intersections even if the input triangle mesh is not eINCONSISTENT_TRIANGLE_ORIENTATION = (1 << 3), //!< invalid: It is not possible to distinguish what is inside and outside of the mesh. If there are no self-intersections and not edges shared by more than two triangles, a call to makeTriOrientationConsistent can fix this. Without fixing it, the output from the tetmesher will be incorrect eCONTAINS_ACUTE_ANGLED_TRIANGLES = (1 << 4), //!< problematic: An ideal mesh for a softbody has triangles with similar angles and evenly distributed vertices. Acute angles can be handled but might lead to a poor quality tetmesh. eEDGE_SHARED_BY_MORE_THAN_TWO_TRIANGLES = (1 << 5), //!< problematic: Border case of a self-intersecting mesh. The tetmesh might not match the surace exactly near such edges. eCONTAINS_DUPLICATE_POINTS = (1 << 6), //!< ok: Duplicate points can be handled by the mesher without problems. The resulting tetmesh will only make use of first unique point that is found, duplicate points will get mapped to that unique point in the tetmesh. Therefore the tetmesh can contain points that are not accessed by a tet. eCONTAINS_INVALID_POINTS = (1 << 7), //!< invalid: Points contain NAN, infinity or similar values that will lead to an invalid mesh eREQUIRES_32BIT_INDEX_BUFFER = (1 << 8), //!< invalid: Mesh contains more indices than a 16bit index buffer can address eTRIANGLE_INDEX_OUT_OF_RANGE = (1 << 9), //!< invalid: A mesh triangle index is negative or lager than the size of the vertex buffer eMESH_IS_PROBLEMATIC = (1 << 10), //!< flag is set if the mesh is categorized as problematic eMESH_IS_INVALID = (1 << 11) //!< flag is set if the mesh is categorized as invalid }; }; typedef PxFlags<PxTriangleMeshAnalysisResult::Enum, PxU32> PxTriangleMeshAnalysisResults; PX_FLAGS_OPERATORS(PxTriangleMeshAnalysisResult::Enum, PxU32) #if !PX_DOXYGEN } #endif #endif
4,498
C
62.366196
343
0.749
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxCustomGeometryExt.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_CUSTOM_GEOMETRY_EXT_H #define PX_CUSTOM_GEOMETRY_EXT_H /** \addtogroup extensions @{ */ #include <geometry/PxCustomGeometry.h> #include <geometry/PxGjkQuery.h> #if !PX_DOXYGEN namespace physx { #endif class PxGeometry; class PxMassProperties; class PxGeometryHolder; struct PxContactPoint; /** \brief Pre-made custom geometry callbacks implementations. */ class PxCustomGeometryExt { public: /// \cond PRIVATE struct BaseConvexCallbacks : PxCustomGeometry::Callbacks, PxGjkQuery::Support { BaseConvexCallbacks(float _margin) : margin(_margin) {} // override PxCustomGeometry::Callbacks virtual PxBounds3 getLocalBounds(const PxGeometry& geometry) const; virtual bool generateContacts(const PxGeometry& geom0, const PxGeometry& geom1, const PxTransform& pose0, const PxTransform& pose1, const PxReal contactDistance, const PxReal meshContactMargin, const PxReal toleranceLength, PxContactBuffer& contactBuffer) const; virtual PxU32 raycast(const PxVec3& origin, const PxVec3& unitDir, const PxGeometry& geom, const PxTransform& pose, PxReal maxDist, PxHitFlags hitFlags, PxU32 maxHits, PxGeomRaycastHit* rayHits, PxU32 stride, PxRaycastThreadContext*) const; virtual bool overlap(const PxGeometry& geom0, const PxTransform& pose0, const PxGeometry& geom1, const PxTransform& pose1, PxOverlapThreadContext*) const; virtual bool sweep(const PxVec3& unitDir, const PxReal maxDist, const PxGeometry& geom0, const PxTransform& pose0, const PxGeometry& geom1, const PxTransform& pose1, PxGeomSweepHit& sweepHit, PxHitFlags hitFlags, const PxReal inflation, PxSweepThreadContext*) const; virtual bool usePersistentContactManifold(const PxGeometry& geometry, PxReal& breakingThreshold) const; // override PxGjkQuery::Support virtual PxReal getMargin() const { return margin; } // set margin void setMargin(float m); protected: // Shape margin float margin; // Substitute geometry virtual bool useSubstituteGeometry(PxGeometryHolder& geom, PxTransform& preTransform, const PxContactPoint& p, const PxTransform& pose0) const = 0; }; /// \endcond /** \brief Cylinder geometry callbacks */ struct CylinderCallbacks : BaseConvexCallbacks { /** \brief Construct cylinder geometry callbacks object \param[in] height The cylinder height. \param[in] radius The cylinder radius. \param[in] axis The cylinder axis (0 - X, 1 - Y, 2 - Z). \param[in] margin The cylinder margin. */ CylinderCallbacks(float height, float radius, int axis = 0, float margin = 0); /// \brief Set cylinder height /// \param[in] h The cylinder height void setHeight(float h); /// \brief Get cylinder height /// \return The cylinder height float getHeight() const { return height; } /// \brief Set cylinder radius /// \param[in] r The cylinder radius. void setRadius(float r); /// \brief Get cylinder radius /// \return The cylinder radius float getRadius() const { return radius; } /// \brief Set cylinder axis /// \param[in] a The cylinder axis (0 - X, 1 - Y, 2 - Z). void setAxis(int a); /// \brief Get cylinder axis /// \return The cylinder axis int getAxis() const { return axis; } /// \cond PRIVATE // override PxCustomGeometry::Callbacks DECLARE_CUSTOM_GEOMETRY_TYPE virtual void visualize(const PxGeometry&, PxRenderOutput&, const PxTransform&, const PxBounds3&) const; virtual void computeMassProperties(const PxGeometry& geometry, PxMassProperties& massProperties) const; // override PxGjkQuery::Support virtual PxVec3 supportLocal(const PxVec3& dir) const; protected: // Cylinder height float height; // Cylinder radius float radius; // Cylinder axis int axis; // Substitute geometry virtual bool useSubstituteGeometry(PxGeometryHolder& geom, PxTransform& preTransform, const PxContactPoint& p, const PxTransform& pose0) const; // Radius at height float getRadiusAtHeight(float height) const; /// \endcond }; /** \brief Cone geometry callbacks */ struct ConeCallbacks : BaseConvexCallbacks { /** \brief Construct cone geometry callbacks object \param[in] height The cylinder height. \param[in] radius The cylinder radius. \param[in] axis The cylinder axis (0 - X, 1 - Y, 2 - Z). \param[in] margin The cylinder margin. */ ConeCallbacks(float height, float radius, int axis = 0, float margin = 0); /// \brief Set cone height /// \param[in] h The cone height void setHeight(float h); /// \brief Get cone height /// \return The cone height float getHeight() const { return height; } /// \brief Set cone radius /// \param[in] r The cone radius void setRadius(float r); /// \brief Get cone radius /// \return The cone radius float getRadius() const { return radius; } /// \brief Set cone axis /// \param[in] a The cone axis void setAxis(int a); /// \brief Get cone axis /// \return The cone axis int getAxis() const { return axis; } /// \cond PRIVATE // override PxCustomGeometry::Callbacks DECLARE_CUSTOM_GEOMETRY_TYPE virtual void visualize(const PxGeometry&, PxRenderOutput&, const PxTransform&, const PxBounds3&) const; virtual void computeMassProperties(const PxGeometry& geometry, PxMassProperties& massProperties) const; // override PxGjkQuery::Support virtual PxVec3 supportLocal(const PxVec3& dir) const; protected: // Cone height float height; // Cone radius float radius; // Cone axis int axis; // Substitute geometry virtual bool useSubstituteGeometry(PxGeometryHolder& geom, PxTransform& preTransform, const PxContactPoint& p, const PxTransform& pose0) const; // Radius at height float getRadiusAtHeight(float height) const; /// \endcond }; }; /// \cond PRIVATE // OmniPVD friendly aliases typedef PxCustomGeometryExt::BaseConvexCallbacks PxCustomGeometryExtBaseConvexCallbacks; typedef PxCustomGeometryExt::CylinderCallbacks PxCustomGeometryExtCylinderCallbacks; typedef PxCustomGeometryExt::ConeCallbacks PxCustomGeometryExtConeCallbacks; /// \endcond #if !PX_DOXYGEN } #endif /** @} */ #endif
7,757
C
33.327433
156
0.743329
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxJoint.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_JOINT_H #define PX_JOINT_H /** \addtogroup extensions @{ */ #include "foundation/PxTransform.h" #include "PxRigidActor.h" #include "PxConstraint.h" #include "common/PxBase.h" #if !PX_DOXYGEN namespace physx { #endif class PxRigidActor; class PxScene; class PxPhysics; class PxConstraint; /** \brief an enumeration of PhysX' built-in joint types @see PxJoint */ struct PxJointConcreteType { enum Enum { eSPHERICAL = PxConcreteType::eFIRST_PHYSX_EXTENSION, eREVOLUTE, ePRISMATIC, eFIXED, eDISTANCE, eD6, eCONTACT, eGEAR, eRACK_AND_PINION, eLast }; }; PX_DEFINE_TYPEINFO(PxJoint, PxConcreteType::eUNDEFINED) PX_DEFINE_TYPEINFO(PxRackAndPinionJoint, PxJointConcreteType::eRACK_AND_PINION) PX_DEFINE_TYPEINFO(PxGearJoint, PxJointConcreteType::eGEAR) PX_DEFINE_TYPEINFO(PxD6Joint, PxJointConcreteType::eD6) PX_DEFINE_TYPEINFO(PxDistanceJoint, PxJointConcreteType::eDISTANCE) PX_DEFINE_TYPEINFO(PxContactJoint, PxJointConcreteType::eCONTACT) PX_DEFINE_TYPEINFO(PxFixedJoint, PxJointConcreteType::eFIXED) PX_DEFINE_TYPEINFO(PxPrismaticJoint, PxJointConcreteType::ePRISMATIC) PX_DEFINE_TYPEINFO(PxRevoluteJoint, PxJointConcreteType::eREVOLUTE) PX_DEFINE_TYPEINFO(PxSphericalJoint, PxJointConcreteType::eSPHERICAL) /** \brief an enumeration for specifying one or other of the actors referenced by a joint @see PxJoint */ struct PxJointActorIndex { enum Enum { eACTOR0, eACTOR1, COUNT }; }; /** \brief a base interface providing common functionality for PhysX joints */ class PxJoint : public PxBase { public: /** \brief Set the actors for this joint. An actor may be NULL to indicate the world frame. At most one of the actors may be NULL. \param[in] actor0 the first actor. \param[in] actor1 the second actor @see getActors() */ virtual void setActors(PxRigidActor* actor0, PxRigidActor* actor1) = 0; /** \brief Get the actors for this joint. \param[out] actor0 the first actor. \param[out] actor1 the second actor @see setActors() */ virtual void getActors(PxRigidActor*& actor0, PxRigidActor*& actor1) const = 0; /** \brief Set the joint local pose for an actor. This is the relative pose which locates the joint frame relative to the actor. \param[in] actor 0 for the first actor, 1 for the second actor. \param[in] localPose the local pose for the actor this joint @see getLocalPose() */ virtual void setLocalPose(PxJointActorIndex::Enum actor, const PxTransform& localPose) = 0; /** \brief get the joint local pose for an actor. \param[in] actor 0 for the first actor, 1 for the second actor. return the local pose for this joint @see setLocalPose() */ virtual PxTransform getLocalPose(PxJointActorIndex::Enum actor) const = 0; /** \brief get the relative pose for this joint This function returns the pose of the joint frame of actor1 relative to actor0 */ virtual PxTransform getRelativeTransform() const = 0; /** \brief get the relative linear velocity of the joint This function returns the linear velocity of the origin of the constraint frame of actor1, relative to the origin of the constraint frame of actor0. The value is returned in the constraint frame of actor0 */ virtual PxVec3 getRelativeLinearVelocity() const = 0; /** \brief get the relative angular velocity of the joint This function returns the angular velocity of actor1 relative to actor0. The value is returned in the constraint frame of actor0 */ virtual PxVec3 getRelativeAngularVelocity() const = 0; /** \brief set the break force for this joint. if the constraint force or torque on the joint exceeds the specified values, the joint will break, at which point it will not constrain the two actors and the flag PxConstraintFlag::eBROKEN will be set. The force and torque are measured in the joint frame of the first actor \param[in] force the maximum force the joint can apply before breaking \param[in] torque the maximum torque the joint can apply before breaking */ virtual void setBreakForce(PxReal force, PxReal torque) = 0; /** \brief get the break force for this joint. \param[out] force the maximum force the joint can apply before breaking \param[out] torque the maximum torque the joint can apply before breaking @see setBreakForce() */ virtual void getBreakForce(PxReal& force, PxReal& torque) const = 0; /** \brief set the constraint flags for this joint. \param[in] flags the constraint flags @see PxConstraintFlag */ virtual void setConstraintFlags(PxConstraintFlags flags) = 0; /** \brief set a constraint flags for this joint to a specified value. \param[in] flag the constraint flag \param[in] value the value to which to set the flag @see PxConstraintFlag */ virtual void setConstraintFlag(PxConstraintFlag::Enum flag, bool value) = 0; /** \brief get the constraint flags for this joint. \return the constraint flags @see PxConstraintFlag */ virtual PxConstraintFlags getConstraintFlags() const = 0; /** \brief set the inverse mass scale for actor0. \param[in] invMassScale the scale to apply to the inverse mass of actor 0 for resolving this constraint @see getInvMassScale0 */ virtual void setInvMassScale0(PxReal invMassScale) = 0; /** \brief get the inverse mass scale for actor0. \return inverse mass scale for actor0 @see setInvMassScale0 */ virtual PxReal getInvMassScale0() const = 0; /** \brief set the inverse inertia scale for actor0. \param[in] invInertiaScale the scale to apply to the inverse inertia of actor0 for resolving this constraint @see getInvMassScale0 */ virtual void setInvInertiaScale0(PxReal invInertiaScale) = 0; /** \brief get the inverse inertia scale for actor0. \return inverse inertia scale for actor0 @see setInvInertiaScale0 */ virtual PxReal getInvInertiaScale0() const = 0; /** \brief set the inverse mass scale for actor1. \param[in] invMassScale the scale to apply to the inverse mass of actor 1 for resolving this constraint @see getInvMassScale1 */ virtual void setInvMassScale1(PxReal invMassScale) = 0; /** \brief get the inverse mass scale for actor1. \return inverse mass scale for actor1 @see setInvMassScale1 */ virtual PxReal getInvMassScale1() const = 0; /** \brief set the inverse inertia scale for actor1. \param[in] invInertiaScale the scale to apply to the inverse inertia of actor1 for resolving this constraint @see getInvInertiaScale1 */ virtual void setInvInertiaScale1(PxReal invInertiaScale) = 0; /** \brief get the inverse inertia scale for actor1. \return inverse inertia scale for actor1 @see setInvInertiaScale1 */ virtual PxReal getInvInertiaScale1() const = 0; /** \brief Retrieves the PxConstraint corresponding to this joint. This can be used to determine, among other things, the force applied at the joint. \return the constraint */ virtual PxConstraint* getConstraint() const = 0; /** \brief Sets a name string for the object that can be retrieved with getName(). This is for debugging and is not used by the SDK. The string is not copied by the SDK, only the pointer is stored. \param[in] name String to set the objects name to. @see getName() */ virtual void setName(const char* name) = 0; /** \brief Retrieves the name string set with setName(). \return Name string associated with object. @see setName() */ virtual const char* getName() const = 0; /** \brief Deletes the joint. \note This call does not wake up the connected rigid bodies. */ virtual void release() = 0; /** \brief Retrieves the scene which this joint belongs to. \return Owner Scene. NULL if not part of a scene. @see PxScene */ virtual PxScene* getScene() const = 0; void* userData; //!< user can assign this to whatever, usually to create a 1:1 relationship with a user object. //serialization /** \brief Put class meta data in stream, used for serialization */ static void getBinaryMetaData(PxOutputStream& stream); //~serialization protected: virtual ~PxJoint() {} //serialization /** \brief Constructor */ PX_INLINE PxJoint(PxType concreteType, PxBaseFlags baseFlags) : PxBase(concreteType, baseFlags), userData(NULL) {} /** \brief Deserialization constructor */ PX_INLINE PxJoint(PxBaseFlags baseFlags) : PxBase(baseFlags) {} /** \brief Returns whether a given type name matches with the type of this instance */ virtual bool isKindOf(const char* name) const { PX_IS_KIND_OF(name, "PxJoint", PxBase); } //~serialization }; class PxSpring { public: PxReal stiffness; //!< the spring strength of the drive: that is, the force proportional to the position error PxReal damping; //!< the damping strength of the drive: that is, the force proportional to the velocity error PxSpring(PxReal stiffness_, PxReal damping_): stiffness(stiffness_), damping(damping_) {} }; #if !PX_DOXYGEN } // namespace physx #endif /** \brief Helper function to setup a joint's global frame This replaces the following functions from previous SDK versions: void NxJointDesc::setGlobalAnchor(const NxVec3& wsAnchor); void NxJointDesc::setGlobalAxis(const NxVec3& wsAxis); The function sets the joint's localPose using world-space input parameters. \param[in] wsAnchor Global frame anchor point. <b>Range:</b> position vector \param[in] wsAxis Global frame axis. <b>Range:</b> direction vector \param[in,out] joint Joint having its global frame set. */ PX_C_EXPORT void PX_CALL_CONV PxSetJointGlobalFrame(physx::PxJoint& joint, const physx::PxVec3* wsAnchor, const physx::PxVec3* wsAxis); /** @} */ #endif
11,402
C
26.744525
135
0.741361
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxCollectionExt.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_COLLECTION_EXT_H #define PX_COLLECTION_EXT_H /** \addtogroup extensions @{ */ #include "PxPhysXConfig.h" #include "common/PxCollection.h" #if !PX_DOXYGEN namespace physx { #endif class PxCollection; class PxScene; class PxCollectionExt { public: /** \brief Removes and releases all object from a collection. The Collection itself is not released. If the releaseExclusiveShapes flag is not set to true, release() will not be called on exclusive shapes. It is assumed that the application holds a reference to each of the objects in the collection, with the exception of objects that are not releasable (PxBase::isReleasable()). In general, objects that violate this assumption need to be removed from the collection prior to calling releaseObjects. \note when a shape is created with PxRigidActor::createShape() or PxRigidActorExt::createExclusiveShape(), the only counted reference is held by the actor. If such a shape and its actor are present in the collection, the reference count will be decremented once when the actor is released, and once when the shape is released, resulting in undefined behavior. Shape reference counts can be incremented with PxShape::acquireReference(). \param[in] collection to remove and release all object from. \param[in] releaseExclusiveShapes if this parameter is set to false, release() will not be called on exclusive shapes. */ static void releaseObjects(PxCollection& collection, bool releaseExclusiveShapes = true); /** \brief Removes objects of a given type from a collection, potentially adding them to another collection. \param[in,out] collection Collection from which objects are removed \param[in] concreteType PxConcreteType of sdk objects that should be removed \param[in,out] to Optional collection to which the removed objects are added @see PxCollection, PxConcreteType */ static void remove(PxCollection& collection, PxType concreteType, PxCollection* to = NULL); /** \brief Collects all objects in PxPhysics that are shareable across multiple scenes. This function creates a new collection from all objects that are shareable across multiple scenes. Instances of the following types are included: PxConvexMesh, PxTriangleMesh, PxHeightField, PxShape and PxMaterial. This is a helper function to ease the creation of collections for serialization. \param[in] physics The physics SDK instance from which objects are collected. See #PxPhysics \return Collection to which objects are added. See #PxCollection @see PxCollection, PxPhysics */ static PxCollection* createCollection(PxPhysics& physics); /** \brief Collects all objects from a PxScene. This function creates a new collection from all objects that were added to the specified PxScene. Instances of the following types are included: PxActor, PxAggregate, PxArticulationReducedCoordinate and PxJoint (other PxConstraint types are not included). This is a helper function to ease the creation of collections for serialization. The function PxSerialization.complete() can be used to complete the collection with required objects prior to serialization. \param[in] scene The PxScene instance from which objects are collected. See #PxScene \return Collection to which objects are added. See #PxCollection @see PxCollection, PxScene, PxSerialization.complete() */ static PxCollection* createCollection(PxScene& scene); }; #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
5,234
C
42.625
158
0.77073
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxGjkQueryExt.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_GJK_QUERY_EXT_H #define PX_GJK_QUERY_EXT_H #include "geometry/PxGjkQuery.h" #include "geometry/PxGeometry.h" #if !PX_DOXYGEN namespace physx { #endif class PxSphereGeometry; class PxCapsuleGeometry; class PxBoxGeometry; class PxConvexMeshGeometry; class PxContactBuffer; class PxConvexMesh; /** \brief Pre-made support mapping for built-in convex geometry types. */ class PxGjkQueryExt { public: /** \brief Pre-made support mapping for a sphere */ struct SphereSupport : PxGjkQuery::Support { PxReal radius; /** \brief Default constructor */ SphereSupport(); /** \brief Constructs a SphereSupport for a sphere radius */ SphereSupport(PxReal radius); /** \brief Constructs a SphereSupport for a PxSphereGeometry */ SphereSupport(const PxSphereGeometry& geom); virtual PxReal getMargin() const; virtual PxVec3 supportLocal(const PxVec3& dir) const; }; /** \brief Pre-made support mapping for a capsule */ struct CapsuleSupport : PxGjkQuery::Support { PxReal radius, halfHeight; /** \brief Default constructor */ CapsuleSupport(); /** \brief Constructs a CapsuleSupport for capsule radius and halfHeight */ CapsuleSupport(PxReal radius, PxReal halfHeight); /** \brief Constructs a CapsuleSupport for a PxCapsuleGeometry */ CapsuleSupport(const PxCapsuleGeometry& geom); virtual PxReal getMargin() const; virtual PxVec3 supportLocal(const PxVec3& dir) const; }; /** \brief Pre-made support mapping for a box */ struct BoxSupport : PxGjkQuery::Support { PxVec3 halfExtents; PxReal margin; /** \brief Default constructor */ BoxSupport(); /** \brief Constructs a BoxSupport for a box halfExtents with optional margin */ BoxSupport(const PxVec3& halfExtents, PxReal margin = 0); /** \brief Constructs a BoxSupport for a PxBoxGeometry */ BoxSupport(const PxBoxGeometry& box, PxReal margin = 0); virtual PxReal getMargin() const; virtual PxVec3 supportLocal(const PxVec3& dir) const; }; /** \brief Pre-made support mapping for a convex mesh */ struct ConvexMeshSupport : PxGjkQuery::Support { const PxConvexMesh* convexMesh; PxVec3 scale; PxQuat scaleRotation; PxReal margin; /** \brief Default constructor */ ConvexMeshSupport(); /** \brief Constructs a BoxSupport for a PxConvexMesh */ ConvexMeshSupport(const PxConvexMesh& convexMesh, const PxVec3& scale = PxVec3(1), const PxQuat& scaleRotation = PxQuat(PxIdentity), PxReal margin = 0); /** \brief Constructs a BoxSupport for a PxConvexMeshGeometry */ ConvexMeshSupport(const PxConvexMeshGeometry& convexMesh, PxReal margin = 0); virtual PxReal getMargin() const; virtual PxVec3 supportLocal(const PxVec3& dir) const; }; /** \brief Pre-made support mapping for any PhysX's convex geometry (sphere, capsule, box, convex mesh) */ struct ConvexGeomSupport : PxGjkQuery::Support { /** \brief Default constructor */ ConvexGeomSupport(); /** \brief Constructs a BoxSupport for a PxGeometry */ ConvexGeomSupport(const PxGeometry& geom, PxReal margin = 0); /** \brief Destructor */ ~ConvexGeomSupport(); /** \brief Returns false if ConvexGeomSupport was constructed from non-convex geometry */ bool isValid() const; virtual PxReal getMargin() const; virtual PxVec3 supportLocal(const PxVec3& dir) const; private: PxGeometryType::Enum mType; union { void* alignment; PxU8 sphere[sizeof(SphereSupport)]; PxU8 capsule[sizeof(CapsuleSupport)]; PxU8 box[sizeof(BoxSupport)]; PxU8 convexMesh[sizeof(ConvexMeshSupport)]; } mSupport; }; /** \brief Generates a contact point between two shapes using GJK-EPA algorithm \param[in] a Shape A support mapping \param[in] b Shape B support mapping \param[in] poseA Shape A transformation \param[in] poseB Shape B transformation \param[in] contactDistance The distance at which contacts begin to be generated between the shapes \param[in] toleranceLength The toleranceLength. Used for scaling distance-based thresholds internally to produce appropriate results given simulations in different units \param[out] contactBuffer A buffer to store the contact \return True if there is a contact. */ static bool generateContacts(const PxGjkQuery::Support& a, const PxGjkQuery::Support& b, const PxTransform& poseA, const PxTransform& poseB, PxReal contactDistance, PxReal toleranceLength, PxContactBuffer& contactBuffer); }; #if !PX_DOXYGEN } #endif #endif
6,199
C
28.107981
170
0.742055
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxD6JointCreate.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_D6_JOINT_CREATE_H #define PX_D6_JOINT_CREATE_H #include "common/PxPhysXCommonConfig.h" /** \addtogroup extensions @{ */ #if !PX_DOXYGEN namespace physx { #endif class PxPhysics; class PxRigidActor; class PxJoint; /** \brief Helper function to create a fixed joint, using either a PxD6Joint or PxFixedJoint. For fixed joints it is important that the joint frames have the same orientation. This helper function uses an identity rotation for both. It is also important that the joint frames have an equivalent position in world space. The function does not check this, so it is up to users to ensure that this is the case. \param[in] physics The physics SDK \param[in] actor0 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame \param[in] localPos0 The position of the joint relative to actor0 \param[in] actor1 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame \param[in] localPos1 The position of the joint relative to actor1 \param[in] useD6 True to use a PxD6Joint, false to use a PxFixedJoint; \return The created joint. @see PxD6Joint PxFixedJoint */ PxJoint* PxD6JointCreate_Fixed(PxPhysics& physics, PxRigidActor* actor0, const PxVec3& localPos0, PxRigidActor* actor1, const PxVec3& localPos1, bool useD6); /** \brief Helper function to create a distance joint, using either a PxD6Joint or PxDistanceJoint. This helper function only supports a maximum distance constraint, because PxD6Joint does not support a minimum distance constraint (contrary to PxDistanceJoint). The distance is computed between the joint frames' world-space positions. The joint frames' orientations are irrelevant here so the function sets them to identity. \param[in] physics The physics SDK \param[in] actor0 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame \param[in] localPos0 The position of the joint relative to actor0 \param[in] actor1 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame \param[in] localPos1 The position of the joint relative to actor1 \param[in] maxDist The maximum allowed distance \param[in] useD6 True to use a PxD6Joint, false to use a PxDistanceJoint; \return The created joint. @see PxD6Joint PxDistanceJoint */ PxJoint* PxD6JointCreate_Distance(PxPhysics& physics, PxRigidActor* actor0, const PxVec3& localPos0, PxRigidActor* actor1, const PxVec3& localPos1, float maxDist, bool useD6); /** \brief Helper function to create a prismatic joint, using either a PxD6Joint or PxPrismaticJoint. This function enforces that the joint frames have the same orientation, which is a local frame whose X is the desired translation axis. This orientation is computed by the function, so users only have to define the desired translation axis (typically 1;0;0 or 0;1;0 or 0;0;1). The translation can be limited. Limits are enforced if minLimit<maxLimit. If minLimit=maxLimit the axis is locked. If minLimit>maxLimit the limits are not enforced and the axis is free. The limit values are computed relative to the position of actor0's joint frame. The function creates hard limits, and uses PhysX's default contact distance parameter. \param[in] physics The physics SDK \param[in] actor0 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame \param[in] localPos0 The position of the joint relative to actor0 \param[in] actor1 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame \param[in] localPos1 The position of the joint relative to actor1 \param[in] axis The axis along which objects are allowed to move, expressed in the actors' local space \param[in] minLimit The minimum allowed position along the axis \param[in] maxLimit The maximum allowed position along the axis \param[in] useD6 True to use a PxD6Joint, false to use a PxPrismaticJoint; \return The created joint. @see PxD6Joint PxPrismaticJoint */ PxJoint* PxD6JointCreate_Prismatic(PxPhysics& physics, PxRigidActor* actor0, const PxVec3& localPos0, PxRigidActor* actor1, const PxVec3& localPos1, const PxVec3& axis, float minLimit, float maxLimit, bool useD6); /** \brief Helper function to create a revolute joint, using either a PxD6Joint or PxRevoluteJoint. This function enforces that the joint frames have the same orientation, which is a local frame whose X is the desired rotation axis. This orientation is computed by the function, so users only have to define the desired rotation axis (typically 1;0;0 or 0;1;0 or 0;0;1). The rotation can be limited. Limits are enforced if minLimit<maxLimit. If minLimit=maxLimit the axis is locked. If minLimit>maxLimit the limits are not enforced and the axis is free. The limit values are computed relative to the rotation of actor0's joint frame. The function creates hard limits, and uses PhysX's default contact distance parameter. Limits are expressed in radians. Allowed range is ]-2*PI;+2*PI[ \param[in] physics The physics SDK \param[in] actor0 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame \param[in] localPos0 The position of the joint relative to actor0 \param[in] actor1 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame \param[in] localPos1 The position of the joint relative to actor1 \param[in] axis The axis around which objects are allowed to move, expressed in the actors' local space \param[in] minLimit The minimum allowed rotation along the axis \param[in] maxLimit The maximum allowed rotation along the axis \param[in] useD6 True to use a PxD6Joint, false to use a PxRevoluteJoint; \return The created joint. @see PxD6Joint PxRevoluteJoint */ PxJoint* PxD6JointCreate_Revolute(PxPhysics& physics, PxRigidActor* actor0, const PxVec3& localPos0, PxRigidActor* actor1, const PxVec3& localPos1, const PxVec3& axis, float minLimit, float maxLimit, bool useD6); /** \brief Helper function to create a spherical joint, using either a PxD6Joint or PxSphericalJoint. This function supports a cone limit shape, defined by a cone axis and two angular limit values. This function enforces that the joint frames have the same orientation, which is a local frame whose X is the desired cone axis. This orientation is computed by the function, so users only have to define the desired cone axis (typically 1;0;0 or 0;1;0 or 0;0;1). The rotations can be limited. Limits are enforced if limit1>0 and limit2>0. Otherwise the motion is free. The limit values define an ellipse, which is the cross-section of the cone limit shape. The function creates hard limits, and uses PhysX's default contact distance parameter. Limits are expressed in radians. Allowed range is ]0;PI[. Limits are symmetric around the cone axis. The cone axis is equivalent to the twist axis for the D6 joint. The twist motion is not limited. \param[in] physics The physics SDK \param[in] actor0 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame \param[in] localPos0 The position of the joint relative to actor0 \param[in] actor1 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame \param[in] localPos1 The position of the joint relative to actor1 \param[in] axis The cone axis, expressed in the actors' local space \param[in] limit1 Max angular limit for the ellipse along the joint frame's second axis (first axis = cone axis) \param[in] limit2 Max angular limit for the ellipse along the joint frame's third axis (first axis = cone axis) \param[in] useD6 True to use a PxD6Joint, false to use a PxSphericalJoint; \return The created joint. @see PxD6Joint PxSphericalJoint */ PxJoint* PxD6JointCreate_Spherical(PxPhysics& physics, PxRigidActor* actor0, const PxVec3& localPos0, PxRigidActor* actor1, const PxVec3& localPos1, const PxVec3& axis, float limit1, float limit2, bool useD6); /** \brief Helper function to create a spherical joint, using either a PxD6Joint or PxSphericalJoint. This function supports a cone limit shape, defined by two pairs of angular limit values. This can be used to create an asymmetric cone. If the angular limit values are symmetric (i.e. minLimit1=-maxLimit1 and minLimit2=-maxLimit2) then the cone axis is the X axis in actor0's space. If the limits are not symmetric, the function rotates the cone axis accordingly so that limits remain symmetric for PhysX. If this happens, the initial joint frames will be different for both actors. By default minLimit1/maxLimit1 are limits around the joint's Y axis, and minLimit2/maxLimit2 are limits around the joint's Z axis. The function creates hard limits, and uses PhysX's default contact distance parameter. Limits are expressed in radians. Allowed range is ]-PI;PI[. The cone axis is equivalent to the twist axis for the D6 joint. The twist motion is not limited. The returned apiroty and apirotz values can later be added to retrieved Y and Z swing angle values (from the joint), to remap angle values to the given input range. \param[out] apiroty Amount of rotation around Y used to setup actor0's joint frame \param[out] apirotz Amount of rotation around Z used to setup actor0's joint frame \param[in] physics The physics SDK \param[in] actor0 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame \param[in] localPos0 The position of the joint relative to actor0 \param[in] actor1 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame \param[in] localPos1 The position of the joint relative to actor1 \param[in] minLimit1 Min angular limit along the joint frame's second axis (first axis = cone axis) \param[in] maxLimit1 Max angular limit along the joint frame's second axis (first axis = cone axis) \param[in] minLimit2 Min angular limit along the joint frame's third axis (first axis = cone axis) \param[in] maxLimit2 Max angular limit along the joint frame's third axis (first axis = cone axis) \param[in] useD6 True to use a PxD6Joint, false to use a PxSphericalJoint; \return The created joint. @see PxD6Joint PxSphericalJoint */ PxJoint* PxD6JointCreate_GenericCone(float& apiroty, float& apirotz, PxPhysics& physics, PxRigidActor* actor0, const PxVec3& localPos0, PxRigidActor* actor1, const PxVec3& localPos1, float minLimit1, float maxLimit1, float minLimit2, float maxLimit2, bool useD6); /** \brief Helper function to create a D6 joint with pyramidal swing limits. This function supports a pyramid limit shape, defined by two pairs of angular limit values. This can be used to create an asymmetric pyramid. If the angular limit values are symmetric (i.e. minLimit1=-maxLimit1 and minLimit2=-maxLimit2) then the pyramid axis is the X axis in actor0's space. By default minLimit1/maxLimit1 are limits around the joint's Y axis, and minLimit2/maxLimit2 are limits around the joint's Z axis. The function creates hard limits, and uses PhysX's default contact distance parameter. Limits are expressed in radians. Allowed range is ]-PI;PI[. The pyramid axis is equivalent to the twist axis for the D6 joint. The twist motion is not limited. \param[in] physics The physics SDK \param[in] actor0 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame \param[in] localPos0 The position of the joint relative to actor0 \param[in] actor1 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame \param[in] localPos1 The position of the joint relative to actor1 \param[in] axis The pyramid axis, expressed in the actors' local space \param[in] minLimit1 Min angular limit along the joint frame's second axis (first axis = pyramid axis) \param[in] maxLimit1 Max angular limit along the joint frame's second axis (first axis = pyramid axis) \param[in] minLimit2 Min angular limit along the joint frame's third axis (first axis = pyramid axis) \param[in] maxLimit2 Max angular limit along the joint frame's third axis (first axis = pyramid axis) \return The created joint. @see PxD6Joint */ PxJoint* PxD6JointCreate_Pyramid(PxPhysics& physics, PxRigidActor* actor0, const PxVec3& localPos0, PxRigidActor* actor1, const PxVec3& localPos1, const PxVec3& axis, float minLimit1, float maxLimit1, float minLimit2, float maxLimit2); #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
14,632
C
56.384314
263
0.774399
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxFixedJoint.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_FIXED_JOINT_H #define PX_FIXED_JOINT_H /** \addtogroup extensions @{ */ #include "extensions/PxJoint.h" #if !PX_DOXYGEN namespace physx { #endif class PxFixedJoint; /** \brief Create a fixed joint. \param[in] physics The physics SDK \param[in] actor0 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame \param[in] localFrame0 The position and orientation of the joint relative to actor0 \param[in] actor1 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame \param[in] localFrame1 The position and orientation of the joint relative to actor1 @see PxFixedJoint */ PxFixedJoint* PxFixedJointCreate(PxPhysics& physics, PxRigidActor* actor0, const PxTransform& localFrame0, PxRigidActor* actor1, const PxTransform& localFrame1); /** \brief A fixed joint permits no relative movement between two bodies. ie the bodies are glued together. \image html fixedJoint.png @see PxFixedJointCreate() PxJoint */ class PxFixedJoint : public PxJoint { public: /** \brief Returns string name of PxFixedJoint, used for serialization */ virtual const char* getConcreteTypeName() const { return "PxFixedJoint"; } protected: //serialization /** \brief Constructor */ PX_INLINE PxFixedJoint(PxType concreteType, PxBaseFlags baseFlags) : PxJoint(concreteType, baseFlags) {} /** \brief Deserialization constructor */ PX_INLINE PxFixedJoint(PxBaseFlags baseFlags) : PxJoint(baseFlags) {} /** \brief Returns whether a given type name matches with the type of this instance */ virtual bool isKindOf(const char* name) const { PX_IS_KIND_OF(name, "PxFixedJoint", PxJoint); } //~serialization }; #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
3,528
C
33.940594
161
0.753118
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxDefaultAllocator.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_DEFAULT_ALLOCATOR_H #define PX_DEFAULT_ALLOCATOR_H /** \addtogroup extensions @{ */ #include "foundation/PxAllocatorCallback.h" #include "foundation/PxAssert.h" #include "foundation/PxMemory.h" #include "common/PxPhysXCommonConfig.h" #include <stdlib.h> #if PX_WINDOWS_FAMILY || PX_LINUX_FAMILY || PX_SWITCH #include <malloc.h> #endif #if !PX_DOXYGEN namespace physx { #endif #if PX_WINDOWS_FAMILY // on win32 we only have 8-byte alignment guaranteed, but the CRT provides special aligned allocation fns PX_FORCE_INLINE void* platformAlignedAlloc(size_t size) { return _aligned_malloc(size, 16); } PX_FORCE_INLINE void platformAlignedFree(void* ptr) { _aligned_free(ptr); } #elif PX_LINUX_FAMILY || PX_SWITCH PX_FORCE_INLINE void* platformAlignedAlloc(size_t size) { return ::memalign(16, size); } PX_FORCE_INLINE void platformAlignedFree(void* ptr) { ::free(ptr); } #else // on all other platforms we get 16-byte alignment by default PX_FORCE_INLINE void* platformAlignedAlloc(size_t size) { return ::malloc(size); } PX_FORCE_INLINE void platformAlignedFree(void* ptr) { ::free(ptr); } #endif /** \brief default implementation of the allocator interface required by the SDK */ class PxDefaultAllocator : public PxAllocatorCallback { public: virtual void* allocate(size_t size, const char*, const char*, int) { void* ptr = platformAlignedAlloc(size); PX_ASSERT((size_t(ptr) & 15)==0); #if PX_STOMP_ALLOCATED_MEMORY if(ptr != NULL) { PxMemSet(ptr, PxI32(0xcd), PxU32(size)); } #endif return ptr; } virtual void deallocate(void* ptr) { platformAlignedFree(ptr); } }; #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
3,376
C
28.112069
105
0.744372
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxTriangleMeshExt.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_TRIANGLE_MESH_EXT_H #define PX_TRIANGLE_MESH_EXT_H /** \addtogroup extensions @{ */ #include "PxPhysXConfig.h" #include "common/PxPhysXCommonConfig.h" #include "foundation/PxArray.h" #if !PX_DOXYGEN namespace physx { #endif class PxGeometry; class PxTriangleMesh; class PxTriangleMeshGeometry; class PxHeightFieldGeometry; /** \brief Utility class to find mesh triangles touched by a specified geometry object. This class is a helper calling PxMeshQuery::findOverlapTriangleMesh or PxMeshQuery::findOverlapHeightField under the hood, while taking care of necessary memory management issues. PxMeshQuery::findOverlapTriangleMesh and PxMeshQuery::findOverlapHeightField are the "raw" functions operating on user-provided fixed-size buffers. These functions abort with an error code in case of buffer overflow. PxMeshOverlapUtil is a convenient helper function checking this error code, and resizing buffers appropriately, until the desired call succeeds. Returned triangle indices are stored within the class, and can be used with PxMeshQuery::getTriangle() to retrieve the triangle properties. */ class PxMeshOverlapUtil { public: PxMeshOverlapUtil(); ~PxMeshOverlapUtil(); /** \brief Find the mesh triangles which touch the specified geometry object. \param[in] geom The geometry object to test for mesh triangle overlaps. Supported geometries are #PxSphereGeometry, #PxCapsuleGeometry and #PxBoxGeometry \param[in] geomPose Pose of the geometry object \param[in] meshGeom The triangle mesh geometry to check overlap against \param[in] meshPose Pose of the triangle mesh \return Number of overlaps found. Triangle indices can then be accessed through the #getResults() function. @see PxGeometry PxTransform PxTriangleMeshGeometry PxMeshQuery::findOverlapTriangleMesh */ PxU32 findOverlap(const PxGeometry& geom, const PxTransform& geomPose, const PxTriangleMeshGeometry& meshGeom, const PxTransform& meshPose); /** \brief Find the height field triangles which touch the specified geometry object. \param[in] geom The geometry object to test for height field overlaps. Supported geometries are #PxSphereGeometry, #PxCapsuleGeometry and #PxBoxGeometry. The sphere and capsule queries are currently conservative estimates. \param[in] geomPose Pose of the geometry object \param[in] hfGeom The height field geometry to check overlap against \param[in] hfPose Pose of the height field \return Number of overlaps found. Triangle indices can then be accessed through the #getResults() function. @see PxGeometry PxTransform PxHeightFieldGeometry PxMeshQuery::findOverlapHeightField */ PxU32 findOverlap(const PxGeometry& geom, const PxTransform& geomPose, const PxHeightFieldGeometry& hfGeom, const PxTransform& hfPose); /** \brief Retrieves array of triangle indices after a findOverlap call. \return Indices of touched triangles */ PX_FORCE_INLINE const PxU32* getResults() const { return mResultsMemory; } /** \brief Retrieves number of triangle indices after a findOverlap call. \return Number of touched triangles */ PX_FORCE_INLINE PxU32 getNbResults() const { return mNbResults; } private: PxU32* mResultsMemory; PxU32 mResults[256]; PxU32 mNbResults; PxU32 mMaxNbResults; }; /** \brief Computes an approximate minimum translational distance (MTD) between a geometry object and a mesh. This iterative function computes an approximate vector that can be used to depenetrate a geom object from a triangle mesh. Returned depenetration vector should be applied to 'geom', to get out of the mesh. The function works best when the amount of overlap between the geom object and the mesh is small. If the geom object's center goes inside the mesh, backface culling usually kicks in, no overlap is detected, and the function does not compute an MTD vector. The function early exits if no overlap is detected after a depenetration attempt. This means that if maxIter = N, the code will attempt at most N iterations but it might exit earlier if depenetration has been successful. Usually N = 4 gives good results. \param[out] direction Computed MTD unit direction \param[out] depth Penetration depth. Always positive or zero. \param[in] geom The geometry object \param[in] geomPose Pose for the geometry object \param[in] meshGeom The mesh geometry \param[in] meshPose Pose for the mesh \param[in] maxIter Max number of iterations before returning. \param[out] usedIter Number of depenetrations attempts performed during the call. Will not be returned if the pointer is NULL. \return True if the MTD has successfully been computed, i.e. if objects do overlap. @see PxGeometry PxTransform PxTriangleMeshGeometry */ bool PxComputeTriangleMeshPenetration(PxVec3& direction, PxReal& depth, const PxGeometry& geom, const PxTransform& geomPose, const PxTriangleMeshGeometry& meshGeom, const PxTransform& meshPose, PxU32 maxIter, PxU32* usedIter = NULL); /** \brief Computes an approximate minimum translational distance (MTD) between a geometry object and a heightfield. This iterative function computes an approximate vector that can be used to depenetrate a geom object from a heightfield. Returned depenetration vector should be applied to 'geom', to get out of the heightfield. The function works best when the amount of overlap between the geom object and the mesh is small. If the geom object's center goes inside the heightfield, backface culling usually kicks in, no overlap is detected, and the function does not compute an MTD vector. The function early exits if no overlap is detected after a depenetration attempt. This means that if maxIter = N, the code will attempt at most N iterations but it might exit earlier if depenetration has been successful. Usually N = 4 gives good results. \param[out] direction Computed MTD unit direction \param[out] depth Penetration depth. Always positive or zero. \param[in] geom The geometry object \param[in] geomPose Pose for the geometry object \param[in] heightFieldGeom The heightfield geometry \param[in] heightFieldPose Pose for the heightfield \param[in] maxIter Max number of iterations before returning. \param[out] usedIter Number of depenetrations attempts performed during the call. Will not be returned if the pointer is NULL. \return True if the MTD has successfully been computed, i.e. if objects do overlap. @see PxGeometry PxTransform PxHeightFieldGeometry */ bool PxComputeHeightFieldPenetration(PxVec3& direction, PxReal& depth, const PxGeometry& geom, const PxTransform& geomPose, const PxHeightFieldGeometry& heightFieldGeom, const PxTransform& heightFieldPose, PxU32 maxIter, PxU32* usedIter = NULL); /** \brief Extracts an isosurface from the SDF of a mesh if it the SDF is available. \param[in] triangleMesh The triangle mesh \param[out] isosurfaceVertices The vertices of the extracted isosurface \param[out] isosurfaceTriangleIndices The triangles of the extracted isosurface */ bool PxExtractIsosurfaceFromSDF(const PxTriangleMesh& triangleMesh, PxArray<PxVec3>& isosurfaceVertices, PxArray<PxU32>& isosurfaceTriangleIndices); #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
9,134
C
45.136363
223
0.768448
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxJointLimit.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_JOINT_LIMIT_H #define PX_JOINT_LIMIT_H /** \addtogroup extensions @{ */ #include "foundation/PxMath.h" #include "common/PxTolerancesScale.h" #include "extensions/PxJoint.h" #include "PxPhysXConfig.h" #if !PX_DOXYGEN namespace physx { #endif /** \brief Describes the parameters for a joint limit. Limits are enabled or disabled by setting flags or other configuration parameters joints, see the documentation for specific joint types for details. */ class PxJointLimitParameters { public: /** \brief Controls the amount of bounce when the joint hits a limit. A restitution value of 1.0 causes the joint to bounce back with the velocity which it hit the limit. A value of zero causes the joint to stop dead. In situations where the joint has many locked DOFs (e.g. 5) the restitution may not be applied correctly. This is due to a limitation in the solver which causes the restitution velocity to become zero as the solver enforces constraints on the other DOFs. This limitation applies to both angular and linear limits, however it is generally most apparent with limited angular DOFs. Disabling joint projection and increasing the solver iteration count may improve this behavior to some extent. Also, combining soft joint limits with joint drives driving against those limits may affect stability. <b>Range:</b> [0,1]<br> <b>Default:</b> 0.0 */ PxReal restitution; /** determines the minimum impact velocity which will cause the joint to bounce */ PxReal bounceThreshold; /** \brief if greater than zero, the limit is soft, i.e. a spring pulls the joint back to the limit <b>Range:</b> [0, PX_MAX_F32)<br> <b>Default:</b> 0.0 */ PxReal stiffness; /** \brief if spring is greater than zero, this is the damping of the limit spring <b>Range:</b> [0, PX_MAX_F32)<br> <b>Default:</b> 0.0 */ PxReal damping; PxJointLimitParameters() : restitution (0.0f), bounceThreshold (0.0f), stiffness (0.0f), damping (0.0f) { } PxJointLimitParameters(const PxJointLimitParameters& p) : restitution (p.restitution), bounceThreshold (p.bounceThreshold), stiffness (p.stiffness), damping (p.damping) { } /** \brief Returns true if the current settings are valid. \return true if the current settings are valid */ PX_INLINE bool isValid() const { return PxIsFinite(restitution) && restitution >= 0 && restitution <= 1 && PxIsFinite(stiffness) && stiffness >= 0 && PxIsFinite(damping) && damping >= 0 && PxIsFinite(bounceThreshold) && bounceThreshold >= 0; } PX_INLINE bool isSoft() const { return damping>0 || stiffness>0; } protected: ~PxJointLimitParameters() {} }; /** \brief Describes a one-sided linear limit. */ class PxJointLinearLimit : public PxJointLimitParameters { public: /** \brief the extent of the limit. <b>Range:</b> (0, PX_MAX_F32) <br> <b>Default:</b> PX_MAX_F32 */ PxReal value; /** \brief construct a linear hard limit \param[in] extent The extent of the limit @see PxJointLimitParameters */ PxJointLinearLimit(PxReal extent) : value(extent) { } /** \brief construct a linear soft limit \param[in] extent the extent of the limit \param[in] spring the stiffness and damping parameters for the limit spring @see PxJointLimitParameters */ PxJointLinearLimit(PxReal extent, const PxSpring& spring) : value(extent) { stiffness = spring.stiffness; damping = spring.damping; } /** \brief Returns true if the limit is valid \return true if the current settings are valid */ PX_INLINE bool isValid() const { return PxJointLimitParameters::isValid() && PxIsFinite(value) && value > 0.0f; } }; /** \brief Describes a two-sided limit. */ class PxJointLinearLimitPair : public PxJointLimitParameters { public: /** \brief the range of the limit. The upper limit must be no lower than the lower limit, and if they are equal the limited degree of freedom will be treated as locked. <b>Range:</b> See the joint on which the limit is used for details<br> <b>Default:</b> lower = -PX_MAX_F32/3, upper = PX_MAX_F32/3 */ PxReal upper, lower; /** \brief Construct a linear hard limit pair. The lower distance value must be less than the upper distance value. \param[in] scale A PxTolerancesScale struct. Should be the same as used when creating the PxPhysics object. \param[in] lowerLimit The lower distance of the limit \param[in] upperLimit The upper distance of the limit @see PxJointLimitParameters PxTolerancesScale */ PxJointLinearLimitPair(const PxTolerancesScale& scale, PxReal lowerLimit = -PX_MAX_F32/3.0f, PxReal upperLimit = PX_MAX_F32/3.0f) : upper(upperLimit), lower(lowerLimit) { bounceThreshold = 2.0f*scale.length; } /** \brief construct a linear soft limit pair \param[in] lowerLimit The lower distance of the limit \param[in] upperLimit The upper distance of the limit \param[in] spring The stiffness and damping parameters of the limit spring @see PxJointLimitParameters */ PxJointLinearLimitPair(PxReal lowerLimit, PxReal upperLimit, const PxSpring& spring) : upper(upperLimit), lower(lowerLimit) { stiffness = spring.stiffness; damping = spring.damping; } /** \brief Returns true if the limit is valid. \return true if the current settings are valid */ PX_INLINE bool isValid() const { return PxJointLimitParameters::isValid() && PxIsFinite(upper) && PxIsFinite(lower) && upper >= lower && PxIsFinite(upper - lower); } }; class PxJointAngularLimitPair : public PxJointLimitParameters { public: /** \brief the range of the limit. The upper limit must be no lower than the lower limit. <b>Unit:</b> Angular: Radians <b>Range:</b> See the joint on which the limit is used for details<br> <b>Default:</b> lower = -PI/2, upper = PI/2 */ PxReal upper, lower; /** \brief construct an angular hard limit pair. The lower value must be less than the upper value. \param[in] lowerLimit The lower angle of the limit \param[in] upperLimit The upper angle of the limit @see PxJointLimitParameters */ PxJointAngularLimitPair(PxReal lowerLimit, PxReal upperLimit) : upper(upperLimit), lower(lowerLimit) { bounceThreshold = 0.5f; } /** \brief construct an angular soft limit pair. The lower value must be less than the upper value. \param[in] lowerLimit The lower angle of the limit \param[in] upperLimit The upper angle of the limit \param[in] spring The stiffness and damping of the limit spring @see PxJointLimitParameters */ PxJointAngularLimitPair(PxReal lowerLimit, PxReal upperLimit, const PxSpring& spring) : upper(upperLimit), lower(lowerLimit) { stiffness = spring.stiffness; damping = spring.damping; } /** \brief Returns true if the limit is valid. \return true if the current settings are valid */ PX_INLINE bool isValid() const { return PxJointLimitParameters::isValid() && PxIsFinite(upper) && PxIsFinite(lower) && upper >= lower; } }; /** \brief Describes an elliptical conical joint limit. Note that very small or highly elliptical limit cones may result in jitter. @see PxD6Joint PxSphericalJoint */ class PxJointLimitCone : public PxJointLimitParameters { public: /** \brief the maximum angle from the Y axis of the constraint frame. <b>Unit:</b> Angular: Radians <b>Range:</b> Angular: (0,PI)<br> <b>Default:</b> PI/2 */ PxReal yAngle; /** \brief the maximum angle from the Z-axis of the constraint frame. <b>Unit:</b> Angular: Radians <b>Range:</b> Angular: (0,PI)<br> <b>Default:</b> PI/2 */ PxReal zAngle; /** \brief Construct a cone hard limit. \param[in] yLimitAngle The limit angle from the Y-axis of the constraint frame \param[in] zLimitAngle The limit angle from the Z-axis of the constraint frame @see PxJointLimitParameters */ PxJointLimitCone(PxReal yLimitAngle, PxReal zLimitAngle) : yAngle(yLimitAngle), zAngle(zLimitAngle) { bounceThreshold = 0.5f; } /** \brief Construct a cone soft limit. \param[in] yLimitAngle The limit angle from the Y-axis of the constraint frame \param[in] zLimitAngle The limit angle from the Z-axis of the constraint frame \param[in] spring The stiffness and damping of the limit spring @see PxJointLimitParameters */ PxJointLimitCone(PxReal yLimitAngle, PxReal zLimitAngle, const PxSpring& spring) : yAngle(yLimitAngle), zAngle(zLimitAngle) { stiffness = spring.stiffness; damping = spring.damping; } /** \brief Returns true if the limit is valid. \return true if the current settings are valid */ PX_INLINE bool isValid() const { return PxJointLimitParameters::isValid() && PxIsFinite(yAngle) && yAngle>0 && yAngle<PxPi && PxIsFinite(zAngle) && zAngle>0 && zAngle<PxPi; } }; /** \brief Describes a pyramidal joint limit. @see PxD6Joint */ class PxJointLimitPyramid : public PxJointLimitParameters { public: /** \brief the minimum angle from the Y axis of the constraint frame. <b>Unit:</b> Angular: Radians <b>Range:</b> Angular: (-PI,PI)<br> <b>Default:</b> -PI/2 */ PxReal yAngleMin; /** \brief the maximum angle from the Y axis of the constraint frame. <b>Unit:</b> Angular: Radians <b>Range:</b> Angular: (-PI,PI)<br> <b>Default:</b> PI/2 */ PxReal yAngleMax; /** \brief the minimum angle from the Z-axis of the constraint frame. <b>Unit:</b> Angular: Radians <b>Range:</b> Angular: (-PI,PI)<br> <b>Default:</b> -PI/2 */ PxReal zAngleMin; /** \brief the maximum angle from the Z-axis of the constraint frame. <b>Unit:</b> Angular: Radians <b>Range:</b> Angular: (-PI,PI)<br> <b>Default:</b> PI/2 */ PxReal zAngleMax; /** \brief Construct a pyramid hard limit. \param[in] yLimitAngleMin The minimum limit angle from the Y-axis of the constraint frame \param[in] yLimitAngleMax The maximum limit angle from the Y-axis of the constraint frame \param[in] zLimitAngleMin The minimum limit angle from the Z-axis of the constraint frame \param[in] zLimitAngleMax The maximum limit angle from the Z-axis of the constraint frame @see PxJointLimitParameters */ PxJointLimitPyramid(PxReal yLimitAngleMin, PxReal yLimitAngleMax, PxReal zLimitAngleMin, PxReal zLimitAngleMax) : yAngleMin(yLimitAngleMin), yAngleMax(yLimitAngleMax), zAngleMin(zLimitAngleMin), zAngleMax(zLimitAngleMax) { bounceThreshold = 0.5f; } /** \brief Construct a pyramid soft limit. \param[in] yLimitAngleMin The minimum limit angle from the Y-axis of the constraint frame \param[in] yLimitAngleMax The maximum limit angle from the Y-axis of the constraint frame \param[in] zLimitAngleMin The minimum limit angle from the Z-axis of the constraint frame \param[in] zLimitAngleMax The maximum limit angle from the Z-axis of the constraint frame \param[in] spring The stiffness and damping of the limit spring @see PxJointLimitParameters */ PxJointLimitPyramid(PxReal yLimitAngleMin, PxReal yLimitAngleMax, PxReal zLimitAngleMin, PxReal zLimitAngleMax, const PxSpring& spring) : yAngleMin(yLimitAngleMin), yAngleMax(yLimitAngleMax), zAngleMin(zLimitAngleMin), zAngleMax(zLimitAngleMax) { stiffness = spring.stiffness; damping = spring.damping; } /** \brief Returns true if the limit is valid. \return true if the current settings are valid */ PX_INLINE bool isValid() const { return PxJointLimitParameters::isValid() && PxIsFinite(yAngleMin) && yAngleMin>-PxPi && yAngleMin<PxPi && PxIsFinite(yAngleMax) && yAngleMax>-PxPi && yAngleMax<PxPi && PxIsFinite(zAngleMin) && zAngleMin>-PxPi && zAngleMin<PxPi && PxIsFinite(zAngleMax) && zAngleMax>-PxPi && zAngleMax<PxPi && yAngleMax>=yAngleMin && zAngleMax>=zAngleMin; } }; #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
13,452
C
26.567623
138
0.726881
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxSoftBodyExt.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_SOFT_BODY_EXT_H #define PX_SOFT_BODY_EXT_H /** \addtogroup extensions @{ */ #include "foundation/PxTransform.h" #include "foundation/PxUserAllocated.h" #include "PxSoftBody.h" #include "PxSoftBodyFlag.h" #include "cudamanager/PxCudaContextManager.h" #include "cudamanager/PxCudaTypes.h" #if !PX_DOXYGEN namespace physx { #endif struct PxCookingParams; class PxSimpleTriangleMesh; class PxInsertionCallback; class PxSoftBodyMesh; /** \brief Utility functions for use with PxSoftBody and subclasses */ class PxSoftBodyExt { public: /** \brief Computes the SoftBody's vertex masses from the provided density and the volume of the tetrahedra The buffers affected by this operation can be obtained from the SoftBody using the methods getSimPositionInvMassBufferD() and getSimVelocityBufferD() The inverse mass is stored in the 4th component (the first three components are x, y, z coordinates) of the simulation mesh's position buffer. \param[in] softBody The soft body which will get its mass updated \param[in] density The density to used to calculate the mass from the body's volume \param[in] maxInvMassRatio Maximum allowed ratio defined as max(vertexMasses) / min(vertexMasses) where vertexMasses is a list of float values with a mass for every vertex in the simulation mesh \param[in] simPositionsPinned A pointer to a pinned host memory buffer containing positions and inverse masses for each vertex of the simulation mesh. @see PxSoftBody PxSoftBody::getSimPositionInvMassBufferD() */ static void updateMass(PxSoftBody& softBody, const PxReal density, const PxReal maxInvMassRatio, PxVec4* simPositionsPinned); /** \brief Computes the SoftBody's vertex masses such that the sum of all masses is equal to the provided mass The buffers affected by this operation can be obtained from the SoftBody using the methods getSimPositionInvMassBufferD()) and getSimVelocityBufferD() The inverse mass is stored in the 4th component (the first three components are x, y, z coordinates) of the simulation mesh's position buffer. \param[in] softBody The soft body which will get its mass updated \param[in] mass The SoftBody's mass \param[in] maxInvMassRatio Maximum allowed ratio defined as max(vertexMasses) / min(vertexMasses) where vertexMasses is a list of float values with a mass for every vertex in the simulation mesh \param[in] simPositionsPinned A pointer to a pinned host memory buffer containing positions and inverse masses for each vertex of the simulation mesh. @see PxSoftBody PxSoftBody::getSimPositionInvMassBufferD() */ static void setMass(PxSoftBody& softBody, const PxReal mass, const PxReal maxInvMassRatio, PxVec4* simPositionsPinned); /** \brief Transforms a SoftBody The buffers affected by this operation can be obtained from the SoftBody using the methods getSimPositionInvMassBufferD() and getSimVelocityBufferD() Applies a transformation to the simulation mesh's positions an velocities. Velocities only get rotated and scaled (translation is not applicable to direction vectors). It does not modify the body's mass. If the method is called multiple times, the transformation will compound with the ones previously applied. \param[in] softBody The soft body which is transformed \param[in] transform The transform to apply \param[in] scale A scaling factor \param[in] simPositionsPinned A pointer to a pinned host memory buffer containing positions and inverse masses for each vertex of the simulation mesh. \param[in] simVelocitiesPinned A pointer to a pinned host memory buffer containing velocities for each vertex of the simulation mesh. \param[in] collPositionsPinned A pointer to a pinned host memory buffer containing positions and inverse masses for each vertex of the collision mesh. \param[in] restPositionsPinned A pointer to a pinned host memory buffer containing rest positions of the collision mesh. @see PxSoftBody */ static void transform(PxSoftBody& softBody, const PxTransform& transform, const PxReal scale, PxVec4* simPositionsPinned, PxVec4* simVelocitiesPinned, PxVec4* collPositionsPinned, PxVec4* restPositionsPinned); /** \brief Updates the collision mesh's vertex positions to match the simulation mesh's transformation and scale. The buffer affected by this operation can be obtained from the SoftBody using the method getPositionInvMassBufferD() \param[in] softBody The soft body which will get its collision mesh vertices updated \param[in] simPositionsPinned A pointer to a pinned host memory buffer containing positions and inverse masses for each vertex of the simulation mesh. \param[in] collPositionsPinned A pointer to a pinned host memory buffer containing positions and inverse masses for each vertex of the collision mesh. @see PxSoftBody */ static void updateEmbeddedCollisionMesh(PxSoftBody& softBody, PxVec4* simPositionsPinned, PxVec4* collPositionsPinned); /** \brief Uploads prepared SoftBody data to the GPU. It ensures that the embedded collision mesh matches the simulation mesh's transformation and scale. \param[in] softBody The soft body which will perform the data upload \param[in] flags Specifies which buffers the data transfer should include \param[in] simPositionsPinned A pointer to a pinned host memory buffer containing positions and inverse masses for each vertex of the simulation mesh. \param[in] simVelocitiesPinned A pointer to a pinned host memory buffer containing velocities for each vertex of the simulation mesh. \param[in] collPositionsPinned A pointer to a pinned host memory buffer containing positions and inverse masses for each vertex of the collision mesh. \param[in] restPositionsPinned A pointer to a pinned host memory buffer containing rest positions of the collision mesh. \param[in] stream A cuda stream to perform the copies. @see PxSoftBody @deprecated Use copyToDevice() instead. */ PX_DEPRECATED static void commit(PxSoftBody& softBody, PxSoftBodyDataFlags flags, PxVec4* simPositionsPinned, PxVec4* simVelocitiesPinned, PxVec4* collPositionsPinned, PxVec4* restPositionsPinned, CUstream stream = CUstream(0)); /** \brief Uploads prepared SoftBody data to the GPU. It ensures that the embedded collision mesh matches the simulation mesh's transformation and scale. \param[in] softBody The soft body which will perform the data upload \param[in] flags Specifies which buffers the data transfer should include \param[in] simPositionsPinned A pointer to a pinned host memory buffer containing positions and inverse masses for each vertex of the simulation mesh. \param[in] simVelocitiesPinned A pointer to a pinned host memory buffer containing velocities for each vertex of the simulation mesh. \param[in] collPositionsPinned A pointer to a pinned host memory buffer containing positions and inverse masses for each vertex of the collision mesh. \param[in] restPositionsPinned A pointer to a pinned host memory buffer containing rest positions of the collision mesh. \param[in] stream A cuda stream to perform the copies. @see PxSoftBody */ static void copyToDevice(PxSoftBody& softBody, PxSoftBodyDataFlags flags, PxVec4* simPositionsPinned, PxVec4* simVelocitiesPinned, PxVec4* collPositionsPinned, PxVec4* restPositionsPinned, CUstream stream = CUstream(0)); /** \brief Creates a full SoftBody mesh matching the shape given as input. Uses a voxel mesh for FEM simulation and a surface-matching mesh for collision detection. \param[in] params Cooking params instance required for mesh processing \param[in] surfaceMesh Input triangle mesh that represents the surface of the SoftBody \param[in] numVoxelsAlongLongestAABBAxis The number of voxels along the longest bounding box axis \param[in] insertionCallback The insertion interface from PxPhysics \param[in] validate If set to true the input triangle mesh will get analyzed to find possible deficiencies \return SoftBody mesh if cooking was successful, NULL otherwise @see PxSoftBodyMesh */ static PxSoftBodyMesh* createSoftBodyMesh(const PxCookingParams& params, const PxSimpleTriangleMesh& surfaceMesh, PxU32 numVoxelsAlongLongestAABBAxis, PxInsertionCallback& insertionCallback, const bool validate = true); /** \brief Creates a full SoftBody mesh matching the shape given as input. Uses the same surface-matching mesh for collision detection and FEM simulation. \param[in] params Cooking params instance required for mesh processing \param[in] surfaceMesh Input triangle mesh that represents the surface of the SoftBody \param[in] insertionCallback The insertion interface from PxPhysics \param[in] maxWeightRatioInTet Upper limit for the ratio of node weights that are adjacent to the same tetrahedron. The closer to one (while remaining larger than one), the more stable the simulation. \param[in] validate If set to true the input triangle mesh will get analyzed to find possible deficiencies \return SoftBody mesh if cooking was successful, NULL otherwise @see PxSoftBodyMesh */ static PxSoftBodyMesh* createSoftBodyMeshNoVoxels(const PxCookingParams& params, const PxSimpleTriangleMesh& surfaceMesh, PxInsertionCallback& insertionCallback, PxReal maxWeightRatioInTet = 1.5f, const bool validate = true); /** \brief Creates a SoftBody instance from a SoftBody mesh \param[in] softBodyMesh The SoftBody mesh \param[in] transform The transform that defines initial position and orientation of the SoftBody \param[in] material The material \param[in] cudaContextManager A cuda context manager \param[in] density The density used to compute the mass properties \param[in] solverIterationCount The number of iterations the solver should apply during simulation \param[in] femParams Additional parameters to specify e. g. damping \param[in] scale The scaling of the SoftBody \return SoftBody instance @see PxSoftBodyMesh, PxSoftBody */ static PxSoftBody* createSoftBodyFromMesh(PxSoftBodyMesh* softBodyMesh, const PxTransform& transform, const PxFEMSoftBodyMaterial& material, PxCudaContextManager& cudaContextManager, PxReal density = 100.0f, PxU32 solverIterationCount = 30, const PxFEMParameters& femParams = PxFEMParameters(), PxReal scale = 1.0f); /** \brief Creates a SoftBody instance with a box shape \param[in] transform The transform that defines initial position and orientation of the SoftBody \param[in] boxDimensions The dimensions (side lengths) of the box shape \param[in] material The material \param[in] cudaContextManager A cuda context manager \param[in] maxEdgeLength The maximal length of a triangle edge. Subdivision will get applied until the edge length criteria is matched. -1 means no subdivision is applied. \param[in] density The density used to compute the mass properties \param[in] solverIterationCount The number of iterations the solver should apply during simulation \param[in] femParams Additional parameters to specify e. g. damping \param[in] numVoxelsAlongLongestAABBAxis The number of voxels to use for the simulation mesh along the longest bounding box dimension \param[in] scale The scaling of the SoftBody \return SoftBody instance @see PxSoftBodyMesh, PxSoftBody */ static PxSoftBody* createSoftBodyBox(const PxTransform& transform, const PxVec3& boxDimensions, const PxFEMSoftBodyMaterial& material, PxCudaContextManager& cudaContextManager, PxReal maxEdgeLength = -1.0f, PxReal density = 100.0f, PxU32 solverIterationCount = 30, const PxFEMParameters& femParams = PxFEMParameters(), PxU32 numVoxelsAlongLongestAABBAxis = 10, PxReal scale = 1.0f); /** \brief allocates and initializes pinned host memory buffers from an actor with shape. \param[in] softBody A PxSoftBody that has a valid shape attached to it. \param[in] cudaContextManager The PxCudaContextManager of the scene this soft body will be simulated in \param[in] simPositionInvMassPinned A reference to a pointer for the return value of the simPositionInvMassPinned buffer, will be set by this function. \param[in] simVelocityPinned A reference to a pointer for the return value of the simVelocityPinned buffer, will be set by this function. \param[in] collPositionInvMassPinned A reference to a pointer for the return value of the collPositionInvMassPinned buffer, will be set by this function. \param[in] restPositionPinned A reference to a pointer for the return value of the restPositionPinned buffer, will be set by this function. @see PxSoftBody */ static void allocateAndInitializeHostMirror(PxSoftBody& softBody, PxCudaContextManager* cudaContextManager, PxVec4*& simPositionInvMassPinned, PxVec4*& simVelocityPinned, PxVec4*& collPositionInvMassPinned, PxVec4*& restPositionPinned); /** \brief Given a set of points and a set of tetrahedra, it finds the equilibrium state of the softbody. Every input point is either fixed or can move freely. \param[in] verticesOriginal Mesh vertex positions in undeformed original state. \param[in] verticesDeformed Mesh vertex positions in new deformed state. Only fixed vertices must have their final location, all other locations will get updated by the method. \param[in] nbVertices The number of vertices. \param[in] tetrahedra The tetrahedra. \param[in] nbTetraheda The number of tetrahedra. \param[in] vertexIsFixed Optional input that specifies which vertex is fixed and which one can move to relax the tension. If not provided, vertices from verticesOriginal which have a .w value of 0 will be considered fixed. \param[in] numIterations The number of stress relaxation iterations to run. */ static void relaxSoftBodyMesh(const PxVec4* verticesOriginal, PxVec4* verticesDeformed, PxU32 nbVertices, const PxU32* tetrahedra, PxU32 nbTetraheda, const bool* vertexIsFixed = NULL, PxU32 numIterations = 200); }; #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
15,522
C
59.87451
237
0.799575
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxDefaultCpuDispatcher.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_DEFAULT_CPU_DISPATCHER_H #define PX_DEFAULT_CPU_DISPATCHER_H /** \addtogroup extensions @{ */ #include "common/PxPhysXCommonConfig.h" #include "task/PxCpuDispatcher.h" #if !PX_DOXYGEN namespace physx { #endif /** \brief A default implementation for a CPU task dispatcher. @see PxDefaultCpuDispatcherCreate() PxCpuDispatcher */ class PxDefaultCpuDispatcher : public PxCpuDispatcher { public: /** \brief Deletes the dispatcher. Do not keep a reference to the deleted instance. @see PxDefaultCpuDispatcherCreate() */ virtual void release() = 0; /** \brief Enables profiling at task level. \note By default enabled only in profiling builds. \param[in] runProfiled True if tasks should be profiled. */ virtual void setRunProfiled(bool runProfiled) = 0; /** \brief Checks if profiling is enabled at task level. \return True if tasks should be profiled. */ virtual bool getRunProfiled() const = 0; }; /** \brief If a thread ends up waiting for work it will find itself in a spin-wait loop until work becomes available. Three strategies are available to limit wasted cycles. The strategies are as follows: a) wait until a work task signals the end of the spin-wait period. b) yield the thread by providing a hint to reschedule thread execution, thereby allowing other threads to run. c) yield the processor by informing it that it is waiting for work and requesting it to more efficiently use compute resources. */ struct PxDefaultCpuDispatcherWaitForWorkMode { enum Enum { eWAIT_FOR_WORK, eYIELD_THREAD, eYIELD_PROCESSOR }; }; /** \brief Create default dispatcher, extensions SDK needs to be initialized first. \param[in] numThreads Number of worker threads the dispatcher should use. \param[in] affinityMasks Array with affinity mask for each thread. If not defined, default masks will be used. \param[in] mode is the strategy employed when a busy-wait is encountered. \param[in] yieldProcessorCount specifies the number of times a OS-specific yield processor command will be executed during each cycle of a busy-wait in the event that the specified mode is eYIELD_PROCESSOR \note numThreads may be zero in which case no worker thread are initialized and simulation tasks will be executed on the thread that calls PxScene::simulate() \note yieldProcessorCount must be greater than zero if eYIELD_PROCESSOR is the chosen mode and equal to zero for all other modes. \note eYIELD_THREAD and eYIELD_PROCESSOR modes will use compute resources even if the simulation is not running. It is left to users to keep threads inactive, if so desired, when no simulation is running. @see PxDefaultCpuDispatcher */ PxDefaultCpuDispatcher* PxDefaultCpuDispatcherCreate(PxU32 numThreads, PxU32* affinityMasks = NULL, PxDefaultCpuDispatcherWaitForWorkMode::Enum mode = PxDefaultCpuDispatcherWaitForWorkMode::eWAIT_FOR_WORK, PxU32 yieldProcessorCount = 0); #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
4,656
C
36.556451
237
0.773196
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxRepXSerializer.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_REPX_SERIALIZER_H #define PX_REPX_SERIALIZER_H /** \addtogroup Serializers @{ */ #include "common/PxBase.h" #include "extensions/PxRepXSimpleType.h" #if !PX_DOXYGEN namespace physx { #endif class XmlMemoryAllocator; class XmlWriter; class XmlReader; class MemoryBuffer; /** \brief Serializer interface for RepX (Xml) serialization. \deprecated Xml serialization is deprecated. An alternative serialization system is provided through USD Physics. In order to serialize a class to RepX both a PxSerializer and a PxRepXSerializer implementation are needed. A repx Serializer provides the ability to capture a live object to a descriptor or static state and the ability to write that state out to a file. Objects allocated by the Serializer using the allocator are freed when the collection itself is freed. SnRepXCoreSerializers.cpp implements a set of Serializers for the core PhysX types. \note Implementing a PxRepXSerializer is currently not practical without including the internal PhysXExtension header "SnRepXSerializerImpl.h". @see PxSerializer, PX_NEW_REPX_SERIALIZER, PxSerializationRegistry::registerRepXSerializer */ class PX_DEPRECATED PxRepXSerializer { protected: virtual ~PxRepXSerializer(){} public: /** \brief The type this Serializer is meant to operate on. @see PxRepXObject::typeName */ virtual const char* getTypeName() = 0; /** \brief Convert from a RepX object to a key-value pair hierarchy \param[in] inLiveObject The object to convert to the passed in descriptor. \param[in] inCollection The collection to use to find ids of references of this object. \param[in] inWriter Interface to write data to. \param[in] inTempBuffer used to for temporary allocations. \param[in] inArgs The arguments used in create resources and objects. */ virtual void objectToFile( const PxRepXObject& inLiveObject, PxCollection* inCollection, XmlWriter& inWriter, MemoryBuffer& inTempBuffer, PxRepXInstantiationArgs& inArgs ) = 0; /** \brief Convert from a descriptor to a live object. Must be an object of this Serializer type. \param[in] inReader The inverse of the writer, a key-value pair database. \param[in] inAllocator An allocator to use for temporary allocations. These will be freed after instantiation completes. \param[in] inArgs The arguments used in create resources and objects. \param[in] inCollection The collection used to find references. \return The new live object. It can be an invalid object if the instantiation cannot take place. */ virtual PxRepXObject fileToObject( XmlReader& inReader, XmlMemoryAllocator& inAllocator, PxRepXInstantiationArgs& inArgs, PxCollection* inCollection ) = 0; }; #if !PX_DOXYGEN } // namespace physx #endif /** \brief Inline helper template function to create PxRepXObject from TDataType type supporting PxTypeInfo<TDataType>::name. \deprecated Xml serialization is deprecated. An alternative serialization system is provided through USD Physics. */ template<typename TDataType> PX_DEPRECATED PX_INLINE physx::PxRepXObject PxCreateRepXObject(const TDataType* inType, const physx::PxSerialObjectId inId) { return physx::PxRepXObject(physx::PxTypeInfo<TDataType>::name(), inType, inId); } /** \brief Inline helper function to create PxRepXObject from a PxBase instance. \deprecated Xml serialization is deprecated. An alternative serialization system is provided through USD Physics. */ PX_DEPRECATED PX_INLINE physx::PxRepXObject PxCreateRepXObject(const physx::PxBase* inType, const physx::PxSerialObjectId inId) { PX_ASSERT(inType); return physx::PxRepXObject(inType->getConcreteTypeName(), inType, inId); } /** \brief Inline helper template function to create PxRepXObject form TDataType type using inType pointer as a PxSerialObjectId id. \deprecated Xml serialization is deprecated. An alternative serialization system is provided through USD Physics. */ template<typename TDataType> PX_DEPRECATED PX_INLINE physx::PxRepXObject PxCreateRepXObject(const TDataType* inType) { return PxCreateRepXObject(inType, static_cast<physx::PxSerialObjectId>(size_t(inType))); } /** \brief Preprocessor macro for RepX serializer creation. \deprecated Xml serialization is deprecated. An alternative serialization system is provided through USD Physics. */ #define PX_NEW_REPX_SERIALIZER(T) \ *PX_PLACEMENT_NEW(PxGetAllocatorCallback()->allocate(sizeof(T), "PxRepXSerializer", PX_FL ), T)(*PxGetAllocatorCallback()) /** \brief Preprocessor Macro to simplify RepX serializer delete. \deprecated Xml serialization is deprecated. An alternative serialization system is provided through USD Physics. */ #define PX_DELETE_REPX_SERIALIZER(x) \ { PxRepXSerializer* s = x; if (s) { PxGetAllocatorCallback()->deallocate(s); } } /** @} */ #endif
6,513
C
40.490446
178
0.775986
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxRigidBodyExt.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_RIGID_BODY_EXT_H #define PX_RIGID_BODY_EXT_H /** \addtogroup extensions @{ */ #include "PxPhysXConfig.h" #include "PxRigidBody.h" #include "PxQueryReport.h" #include "PxQueryFiltering.h" #include "extensions/PxMassProperties.h" #if !PX_DOXYGEN namespace physx { #endif class PxScene; struct PxQueryCache; class PxShape; /** \brief utility functions for use with PxRigidBody and subclasses @see PxRigidBody PxRigidDynamic PxArticulationLink */ class PxRigidBodyExt { public: /** \brief Computation of mass properties for a rigid body actor To simulate a dynamic rigid actor, the SDK needs a mass and an inertia tensor. This method offers functionality to compute the necessary mass and inertia properties based on the shapes declared in the PxRigidBody descriptor and some additionally specified parameters. For each shape, the shape geometry, the shape positioning within the actor and the specified shape density are used to compute the body's mass and inertia properties. <ul> <li>Shapes without PxShapeFlag::eSIMULATION_SHAPE set are ignored unless includeNonSimShapes is true.</li> <li>Shapes with plane, triangle mesh or heightfield geometry and PxShapeFlag::eSIMULATION_SHAPE set are not allowed for PxRigidBody collision.</li> </ul> This method will set the mass, center of mass, and inertia tensor if no collision shapes are found, the inertia tensor is set to (1,1,1) and the mass to 1 if massLocalPose is non-NULL, the rigid body's center of mass parameter will be set to the user provided value (massLocalPose) and the inertia tensor will be resolved at that point. \note If all shapes of the actor have the same density then the overloaded method updateMassAndInertia() with a single density parameter can be used instead. \param[in,out] body The rigid body. \param[in] shapeDensities The per shape densities. There must be one entry for each shape which has the PxShapeFlag::eSIMULATION_SHAPE set (or for all shapes if includeNonSimShapes is set to true). Other shapes are ignored. The density values must be greater than 0. \param[in] shapeDensityCount The number of provided density values. \param[in] massLocalPose The center of mass relative to the actor frame. If set to null then (0,0,0) is assumed. \param[in] includeNonSimShapes True if all kind of shapes (PxShapeFlag::eSCENE_QUERY_SHAPE, PxShapeFlag::eTRIGGER_SHAPE) should be taken into account. \return Boolean. True on success else false. @see PxRigidBody::setMassLocalPose PxRigidBody::setMassSpaceInertiaTensor PxRigidBody::setMass */ static bool updateMassAndInertia(PxRigidBody& body, const PxReal* shapeDensities, PxU32 shapeDensityCount, const PxVec3* massLocalPose = NULL, bool includeNonSimShapes = false); /** \brief Computation of mass properties for a rigid body actor See previous method for details. \param[in,out] body The rigid body. \param[in] density The density of the body. Used to compute the mass of the body. The density must be greater than 0. \param[in] massLocalPose The center of mass relative to the actor frame. If set to null then (0,0,0) is assumed. \param[in] includeNonSimShapes True if all kind of shapes (PxShapeFlag::eSCENE_QUERY_SHAPE, PxShapeFlag::eTRIGGER_SHAPE) should be taken into account. \return Boolean. True on success else false. @see PxRigidBody::setMassLocalPose PxRigidBody::setMassSpaceInertiaTensor PxRigidBody::setMass */ static bool updateMassAndInertia(PxRigidBody& body, PxReal density, const PxVec3* massLocalPose = NULL, bool includeNonSimShapes = false); /** \brief Computation of mass properties for a rigid body actor This method sets the mass, inertia and center of mass of a rigid body. The mass is set to the sum of all user-supplied shape mass values, and the inertia and center of mass are computed according to the rigid body's shapes and the per shape mass input values. If no collision shapes are found, the inertia tensor is set to (1,1,1) \note If a single mass value should be used for the actor as a whole then the overloaded method setMassAndUpdateInertia() with a single mass parameter can be used instead. @see updateMassAndInertia for more details. \param[in,out] body The rigid body for which to set the mass and centre of mass local pose properties. \param[in] shapeMasses The per shape mass values. There must be one entry for each shape which has the PxShapeFlag::eSIMULATION_SHAPE set. Other shapes are ignored. The mass values must be greater than 0. \param[in] shapeMassCount The number of provided mass values. \param[in] massLocalPose The center of mass relative to the actor frame. If set to null then (0,0,0) is assumed. \param[in] includeNonSimShapes True if all kind of shapes (PxShapeFlag::eSCENE_QUERY_SHAPE, PxShapeFlag::eTRIGGER_SHAPE) should be taken into account. \return Boolean. True on success else false. @see PxRigidBody::setCMassLocalPose PxRigidBody::setMassSpaceInertiaTensor PxRigidBody::setMass */ static bool setMassAndUpdateInertia(PxRigidBody& body, const PxReal* shapeMasses, PxU32 shapeMassCount, const PxVec3* massLocalPose = NULL, bool includeNonSimShapes = false); /** \brief Computation of mass properties for a rigid body actor This method sets the mass, inertia and center of mass of a rigid body. The mass is set to the user-supplied value, and the inertia and center of mass are computed according to the rigid body's shapes and the input mass. If no collision shapes are found, the inertia tensor is set to (1,1,1) @see updateMassAndInertia for more details. \param[in,out] body The rigid body for which to set the mass and centre of mass local pose properties. \param[in] mass The mass of the body. Must be greater than 0. \param[in] massLocalPose The center of mass relative to the actor frame. If set to null then (0,0,0) is assumed. \param[in] includeNonSimShapes True if all kind of shapes (PxShapeFlag::eSCENE_QUERY_SHAPE, PxShapeFlag::eTRIGGER_SHAPE) should be taken into account. \return Boolean. True on success else false. @see PxRigidBody::setCMassLocalPose PxRigidBody::setMassSpaceInertiaTensor PxRigidBody::setMass */ static bool setMassAndUpdateInertia(PxRigidBody& body, PxReal mass, const PxVec3* massLocalPose = NULL, bool includeNonSimShapes = false); /** \brief Compute the mass, inertia tensor and center of mass from a list of shapes. \param[in] shapes The shapes to compute the mass properties from. \param[in] shapeCount The number of provided shapes. \return The mass properties from the combined shapes. @see PxRigidBody::setCMassLocalPose PxRigidBody::setMassSpaceInertiaTensor PxRigidBody::setMass */ static PxMassProperties computeMassPropertiesFromShapes(const PxShape* const* shapes, PxU32 shapeCount); /** \brief Applies a force (or impulse) defined in the global coordinate frame, acting at a particular point in global coordinates, to the actor. Note that if the force does not act along the center of mass of the actor, this will also add the corresponding torque. Because forces are reset at the end of every timestep, you can maintain a total external force on an object by calling this once every frame. \note if this call is used to apply a force or impulse to an articulation link, only the link is updated, not the entire articulation ::PxForceMode determines if the force is to be conventional or impulsive. Only eFORCE and eIMPULSE are supported, as the force required to produce a given velocity change or acceleration is underdetermined given only the desired change at a given point. <b>Sleeping:</b> This call wakes the actor if it is sleeping and the wakeup parameter is true (default). \param[in] body The rigid body to apply the force to. \param[in] force Force/impulse to add, defined in the global frame. <b>Range:</b> force vector \param[in] pos Position in the global frame to add the force at. <b>Range:</b> position vector \param[in] mode The mode to use when applying the force/impulse(see #PxForceMode). \param[in] wakeup Specify if the call should wake up the actor. @see PxForceMode @see addForceAtLocalPos() addLocalForceAtPos() addLocalForceAtLocalPos() */ static void addForceAtPos(PxRigidBody& body, const PxVec3& force, const PxVec3& pos, PxForceMode::Enum mode = PxForceMode::eFORCE, bool wakeup = true); /** \brief Applies a force (or impulse) defined in the global coordinate frame, acting at a particular point in local coordinates, to the actor. Note that if the force does not act along the center of mass of the actor, this will also add the corresponding torque. Because forces are reset at the end of every timestep, you can maintain a total external force on an object by calling this once every frame. \note if this call is used to apply a force or impulse to an articulation link, only the link is updated, not the entire articulation ::PxForceMode determines if the force is to be conventional or impulsive. Only eFORCE and eIMPULSE are supported, as the force required to produce a given velocity change or acceleration is underdetermined given only the desired change at a given point. <b>Sleeping:</b> This call wakes the actor if it is sleeping and the wakeup parameter is true (default). \param[in] body The rigid body to apply the force to. \param[in] force Force/impulse to add, defined in the global frame. <b>Range:</b> force vector \param[in] pos Position in the local frame to add the force at. <b>Range:</b> position vector \param[in] mode The mode to use when applying the force/impulse(see #PxForceMode). \param[in] wakeup Specify if the call should wake up the actor. @see PxForceMode @see addForceAtPos() addLocalForceAtPos() addLocalForceAtLocalPos() */ static void addForceAtLocalPos(PxRigidBody& body, const PxVec3& force, const PxVec3& pos, PxForceMode::Enum mode = PxForceMode::eFORCE, bool wakeup = true); /** \brief Applies a force (or impulse) defined in the actor local coordinate frame, acting at a particular point in global coordinates, to the actor. Note that if the force does not act along the center of mass of the actor, this will also add the corresponding torque. Because forces are reset at the end of every timestep, you can maintain a total external force on an object by calling this once every frame. \note if this call is used to apply a force or impulse to an articulation link, only the link is updated, not the entire articulation ::PxForceMode determines if the force is to be conventional or impulsive. Only eFORCE and eIMPULSE are supported, as the force required to produce a given velocity change or acceleration is underdetermined given only the desired change at a given point. <b>Sleeping:</b> This call wakes the actor if it is sleeping and the wakeup parameter is true (default). \param[in] body The rigid body to apply the force to. \param[in] force Force/impulse to add, defined in the local frame. <b>Range:</b> force vector \param[in] pos Position in the global frame to add the force at. <b>Range:</b> position vector \param[in] mode The mode to use when applying the force/impulse(see #PxForceMode). \param[in] wakeup Specify if the call should wake up the actor. @see PxForceMode @see addForceAtPos() addForceAtLocalPos() addLocalForceAtLocalPos() */ static void addLocalForceAtPos(PxRigidBody& body, const PxVec3& force, const PxVec3& pos, PxForceMode::Enum mode = PxForceMode::eFORCE, bool wakeup = true); /** \brief Applies a force (or impulse) defined in the actor local coordinate frame, acting at a particular point in local coordinates, to the actor. Note that if the force does not act along the center of mass of the actor, this will also add the corresponding torque. Because forces are reset at the end of every timestep, you can maintain a total external force on an object by calling this once every frame. \note if this call is used to apply a force or impulse to an articulation link, only the link is updated, not the entire articulation ::PxForceMode determines if the force is to be conventional or impulsive. Only eFORCE and eIMPULSE are supported, as the force required to produce a given velocity change or acceleration is underdetermined given only the desired change at a given point. <b>Sleeping:</b> This call wakes the actor if it is sleeping and the wakeup parameter is true (default). \param[in] body The rigid body to apply the force to. \param[in] force Force/impulse to add, defined in the local frame. <b>Range:</b> force vector \param[in] pos Position in the local frame to add the force at. <b>Range:</b> position vector \param[in] mode The mode to use when applying the force/impulse(see #PxForceMode). \param[in] wakeup Specify if the call should wake up the actor. @see PxForceMode @see addForceAtPos() addForceAtLocalPos() addLocalForceAtPos() */ static void addLocalForceAtLocalPos(PxRigidBody& body, const PxVec3& force, const PxVec3& pos, PxForceMode::Enum mode = PxForceMode::eFORCE, bool wakeup = true); /** \brief Computes the velocity of a point given in world coordinates if it were attached to the specified body and moving with it. \param[in] body The rigid body the point is attached to. \param[in] pos Position we wish to determine the velocity for, defined in the global frame. <b>Range:</b> position vector \return The velocity of point in the global frame. @see getLocalPointVelocity() */ static PxVec3 getVelocityAtPos(const PxRigidBody& body, const PxVec3& pos); /** \brief Computes the velocity of a point given in local coordinates if it were attached to the specified body and moving with it. \param[in] body The rigid body the point is attached to. \param[in] pos Position we wish to determine the velocity for, defined in the local frame. <b>Range:</b> position vector \return The velocity of point in the local frame. @see getLocalPointVelocity() */ static PxVec3 getLocalVelocityAtLocalPos(const PxRigidBody& body, const PxVec3& pos); /** \brief Computes the velocity of a point (offset from the origin of the body) given in world coordinates if it were attached to the specified body and moving with it. \param[in] body The rigid body the point is attached to. \param[in] pos Position (offset from the origin of the body) we wish to determine the velocity for, defined in the global frame. <b>Range:</b> position vector \return The velocity of point (offset from the origin of the body) in the global frame. @see getLocalPointVelocity() */ static PxVec3 getVelocityAtOffset(const PxRigidBody& body, const PxVec3& pos); /** \brief Compute the change to linear and angular velocity that would occur if an impulsive force and torque were to be applied to a specified rigid body. The rigid body is left unaffected unless a subsequent independent call is executed that actually applies the computed changes to velocity and angular velocity. \note if this call is used to determine the velocity delta for an articulation link, only the mass properties of the link are taken into account. @see PxRigidBody::getLinearVelocity, PxRigidBody::setLinearVelocity, PxRigidBody::getAngularVelocity, PxRigidBody::setAngularVelocity \param[in] body The body under consideration. \param[in] impulsiveForce The impulsive force that would be applied to the specified rigid body. \param[in] impulsiveTorque The impulsive torque that would be applied to the specified rigid body. \param[out] deltaLinearVelocity The change in linear velocity that would arise if impulsiveForce was to be applied to the specified rigid body. \param[out] deltaAngularVelocity The change in angular velocity that would arise if impulsiveTorque was to be applied to the specified rigid body. */ static void computeVelocityDeltaFromImpulse(const PxRigidBody& body, const PxVec3& impulsiveForce, const PxVec3& impulsiveTorque, PxVec3& deltaLinearVelocity, PxVec3& deltaAngularVelocity); /** \brief Computes the linear and angular velocity change vectors for a given impulse at a world space position taking a mass and inertia scale into account This function is useful for extracting the respective linear and angular velocity changes from a contact or joint when the mass/inertia ratios have been adjusted. \note if this call is used to determine the velocity delta for an articulation link, only the mass properties of the link are taken into account. \param[in] body The rigid body \param[in] globalPose The body's world space transform \param[in] point The point in world space where the impulse is applied \param[in] impulse The impulse vector in world space \param[in] invMassScale The inverse mass scale \param[in] invInertiaScale The inverse inertia scale \param[out] deltaLinearVelocity The linear velocity change \param[out] deltaAngularVelocity The angular velocity change */ static void computeVelocityDeltaFromImpulse(const PxRigidBody& body, const PxTransform& globalPose, const PxVec3& point, const PxVec3& impulse, const PxReal invMassScale, const PxReal invInertiaScale, PxVec3& deltaLinearVelocity, PxVec3& deltaAngularVelocity); /** \brief Computes the linear and angular impulse vectors for a given impulse at a world space position taking a mass and inertia scale into account This function is useful for extracting the respective linear and angular impulses from a contact or joint when the mass/inertia ratios have been adjusted. \param[in] body The rigid body \param[in] globalPose The body's world space transform \param[in] point The point in world space where the impulse is applied \param[in] impulse The impulse vector in world space \param[in] invMassScale The inverse mass scale \param[in] invInertiaScale The inverse inertia scale \param[out] linearImpulse The linear impulse \param[out] angularImpulse The angular impulse */ static void computeLinearAngularImpulse(const PxRigidBody& body, const PxTransform& globalPose, const PxVec3& point, const PxVec3& impulse, const PxReal invMassScale, const PxReal invInertiaScale, PxVec3& linearImpulse, PxVec3& angularImpulse); /** \brief Performs a linear sweep through space with the body's geometry objects. \note Supported geometries are: box, sphere, capsule, convex. Other geometry types will be ignored. \note If eTOUCH is returned from the filter callback, it will trigger an error and the hit will be discarded. The function sweeps all shapes attached to a given rigid body through space and reports the nearest object in the scene which intersects any of of the shapes swept paths. Information about the closest intersection is written to a #PxSweepHit structure. \param[in] body The rigid body to sweep. \param[in] scene The scene object to process the query. \param[in] unitDir Normalized direction of the sweep. \param[in] distance Sweep distance. Needs to be larger than 0. \param[in] outputFlags Specifies which properties should be written to the hit information. \param[out] closestHit Closest hit result. \param[out] shapeIndex Index of the body shape that caused the closest hit. \param[in] filterData If any word in filterData.data is non-zero then filterData.data will be used for filtering, otherwise shape->getQueryFilterData() will be used instead. \param[in] filterCall Custom filtering logic (optional). Only used if the corresponding #PxQueryFlag flags are set. If NULL, all hits are assumed to be blocking. \param[in] cache Cached hit shape (optional). Ray is tested against cached shape first then against the scene. Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit. \param[in] inflation This parameter creates a skin around the swept geometry which increases its extents for sweeping. The sweep will register a hit as soon as the skin touches a shape, and will return the corresponding distance and normal. \return True if a blocking hit was found. @see PxScene PxQueryFlags PxFilterData PxSweepHit */ static bool linearSweepSingle( PxRigidBody& body, PxScene& scene, const PxVec3& unitDir, const PxReal distance, PxHitFlags outputFlags, PxSweepHit& closestHit, PxU32& shapeIndex, const PxQueryFilterData& filterData = PxQueryFilterData(), PxQueryFilterCallback* filterCall = NULL, const PxQueryCache* cache = NULL, const PxReal inflation=0.0f); /** \brief Performs a linear sweep through space with the body's geometry objects, returning all overlaps. \note Supported geometries are: box, sphere, capsule, convex. Other geometry types will be ignored. This function sweeps all shapes attached to a given rigid body through space and reports all objects in the scene that intersect any of the shapes' swept paths until there are no more objects to report or a blocking hit is encountered. \param[in] body The rigid body to sweep. \param[in] scene The scene object to process the query. \param[in] unitDir Normalized direction of the sweep. \param[in] distance Sweep distance. Needs to be larger than 0. \param[in] outputFlags Specifies which properties should be written to the hit information. \param[out] touchHitBuffer Raycast hit information buffer. If the buffer overflows, an arbitrary subset of touch hits is returned (typically the query should be restarted with a larger buffer). \param[out] touchHitShapeIndices After the query is completed, touchHitShapeIndices[i] will contain the body index that caused the hit stored in hitBuffer[i] \param[in] touchHitBufferSize Size of both touch hit buffers in elements. \param[out] block Closest blocking hit is returned via this reference. \param[out] blockingShapeIndex Set to -1 if if a blocking hit was not found, otherwise set to closest blocking hit shape index. The touching hits are reported separately in hitBuffer. \param[out] overflow Set to true if touchHitBuffer didn't have enough space for all results. Touch hits will be incomplete if overflow occurred. Possible solution is to restart the query with a larger buffer. \param[in] filterData If any word in filterData.data is non-zero then filterData.data will be used for filtering, otherwise shape->getQueryFilterData() will be used instead. \param[in] filterCall Custom filtering logic (optional). Only used if the corresponding #PxQueryFlag flags are set. If NULL, all hits are assumed to be blocking. \param[in] cache Cached hit shape (optional). Ray is tested against cached shape first then against the scene. Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit. \param[in] inflation This parameter creates a skin around the swept geometry which increases its extents for sweeping. The sweep will register a hit as soon as the skin touches a shape, and will return the corresponding distance and normal. \return the number of touching hits. If overflow is set to true, the results are incomplete. In case of overflow there are also no guarantees that all touching hits returned are closer than the blocking hit. @see PxScene PxQueryFlags PxFilterData PxSweepHit */ static PxU32 linearSweepMultiple( PxRigidBody& body, PxScene& scene, const PxVec3& unitDir, const PxReal distance, PxHitFlags outputFlags, PxSweepHit* touchHitBuffer, PxU32* touchHitShapeIndices, PxU32 touchHitBufferSize, PxSweepHit& block, PxI32& blockingShapeIndex, bool& overflow, const PxQueryFilterData& filterData = PxQueryFilterData(), PxQueryFilterCallback* filterCall = NULL, const PxQueryCache* cache = NULL, const PxReal inflation = 0.0f); }; #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
25,577
C
55.966592
267
0.77382
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxGearJoint.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_GEAR_JOINT_H #define PX_GEAR_JOINT_H /** \addtogroup extensions @{ */ #include "extensions/PxJoint.h" #if !PX_DOXYGEN namespace physx { #endif class PxGearJoint; /** \brief Create a gear Joint. \param[in] physics The physics SDK \param[in] actor0 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame \param[in] localFrame0 The position and orientation of the joint relative to actor0 \param[in] actor1 An actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame \param[in] localFrame1 The position and orientation of the joint relative to actor1 @see PxGearJoint */ PxGearJoint* PxGearJointCreate(PxPhysics& physics, PxRigidActor* actor0, const PxTransform& localFrame0, PxRigidActor* actor1, const PxTransform& localFrame1); /** \brief A joint that connects two existing revolute joints and constrains their relative angular velocity and position with respect to each other. @see PxGearJointCreate PxJoint */ class PxGearJoint : public PxJoint { public: /** \brief Set the hinge/revolute joints connected by the gear joint. The passed joints can be either PxRevoluteJoint, PxD6Joint or PxArticulationJointReducedCoordinate. The joints must define degrees of freedom around the twist axis. Note that these joints are only used to compute the positional error correction term, used to adjust potential drift between jointed actors. The gear joint can run without calling this function, but in that case some visible overlap may develop over time between the teeth of the gear meshes. \note Calling this function resets the internal positional error correction term. \param[in] hinge0 The first hinge joint \param[in] hinge1 The second hinge joint \return true if success */ virtual bool setHinges(const PxBase* hinge0, const PxBase* hinge1) = 0; /** \brief Get the hinge/revolute joints connected by the gear joint. \param[out] hinge0 The first hinge joint \param[out] hinge1 The second hinge joint */ virtual void getHinges(const PxBase*& hinge0, const PxBase*& hinge1) const = 0; /** \brief Set the desired gear ratio. For two gears with n0 and n1 teeth respectively, the gear ratio is n0/n1. \note You may need to use a negative gear ratio if the joint frames of involved actors are not oriented in the same direction. \note Calling this function resets the internal positional error correction term. \param[in] ratio Desired ratio between the two hinges. */ virtual void setGearRatio(float ratio) = 0; /** \brief Get the gear ratio. \return Current ratio */ virtual float getGearRatio() const = 0; virtual const char* getConcreteTypeName() const { return "PxGearJoint"; } protected: PX_INLINE PxGearJoint(PxType concreteType, PxBaseFlags baseFlags) : PxJoint(concreteType, baseFlags) {} PX_INLINE PxGearJoint(PxBaseFlags baseFlags) : PxJoint(baseFlags) {} virtual bool isKindOf(const char* name) const { PX_IS_KIND_OF(name, "PxGearJoint", PxJoint); } }; #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
4,893
C
36.646154
160
0.752708
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxBinaryConverter.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_BINARY_CONVERTER_H #define PX_BINARY_CONVERTER_H /** \addtogroup extensions @{ */ #include "common/PxPhysXCommonConfig.h" #if !PX_DOXYGEN namespace physx { #endif struct PX_DEPRECATED PxConverterReportMode { enum Enum { eNONE, //!< Silent mode. If enabled, no information is sent to the error stream. eNORMAL, //!< Normal mode. If enabled, only important information is sent to the error stream. eVERBOSE //!< Verbose mode. If enabled, detailed information is sent to the error stream. }; }; /** \brief Binary converter for serialized streams. \deprecated Binary conversion and binary meta data are deprecated. The binary converter class is targeted at converting binary streams from authoring platforms, such as windows, osx or linux to any game runtime platform supported by PhysX. Particularly it is currently not supported to run the converter on a platforms that has an endian mismatch with the platform corresponding to the source binary file and source meta data. If you want to use multiple threads for batch conversions, please create one instance of this class for each thread. @see PxSerialization.createBinaryConverter */ class PX_DEPRECATED PxBinaryConverter { public: /** \brief Releases binary converter */ virtual void release() = 0; /** \brief Sets desired report mode. \param[in] mode Report mode */ virtual void setReportMode(PxConverterReportMode::Enum mode) = 0; /** \brief Setups source and target meta-data streams The source meta data provided needs to have the same endianness as the platform the converter is run on. The meta data needs to be set before calling the conversion method. \param[in] srcMetaData Source platform's meta-data stream \param[in] dstMetaData Target platform's meta-data stream \return True if success @see PxSerialization::dumpBinaryMetaData */ virtual bool setMetaData(PxInputStream& srcMetaData, PxInputStream& dstMetaData) = 0; /** \brief Test utility function to compare two sets of meta data. The meta data needs to be set before calling the compareMetaData method. This method will issue PxErrorCode::eDEBUG_INFO messages if mismatches are encountered. \return True if meta data is equivalend */ virtual bool compareMetaData() const = 0; /** \brief Converts binary stream from source platform to target platform The converter needs to be configured with source and destination meta data before calling the conversion method. The source meta data needs to correspond to the same platform as the source binary data. \param[in] srcStream Source stream \param[in] srcSize Number of bytes to convert \param[in] targetStream Target stream \return True if success */ virtual bool convert(PxInputStream& srcStream, PxU32 srcSize, PxOutputStream& targetStream) = 0; protected: PxBinaryConverter() {} virtual ~PxBinaryConverter() {} }; #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
4,680
C
33.674074
114
0.75812
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxSimpleFactory.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_SIMPLE_FACTORY_H #define PX_SIMPLE_FACTORY_H /** \addtogroup extensions @{ */ #include "common/PxPhysXCommonConfig.h" #include "foundation/PxTransform.h" #include "foundation/PxPlane.h" #if !PX_DOXYGEN namespace physx { #endif class PxPhysics; class PxMaterial; class PxRigidActor; class PxRigidDynamic; class PxRigidStatic; class PxGeometry; class PxShape; /** \brief simple method to create a PxRigidDynamic actor with a single PxShape. \param[in] sdk the PxPhysics object \param[in] transform the global pose of the new object \param[in] geometry the geometry of the new object's shape, which must be a sphere, capsule, box or convex \param[in] material the material for the new object's shape \param[in] density the density of the new object. Must be greater than zero. \param[in] shapeOffset an optional offset for the new shape, defaults to identity \return a new dynamic actor with the PxRigidBodyFlag, or NULL if it could not be constructed @see PxRigidDynamic PxShapeFlag */ PxRigidDynamic* PxCreateDynamic(PxPhysics& sdk, const PxTransform& transform, const PxGeometry& geometry, PxMaterial& material, PxReal density, const PxTransform& shapeOffset = PxTransform(PxIdentity)); /** \brief simple method to create a PxRigidDynamic actor with a single PxShape. \param[in] sdk the PxPhysics object \param[in] transform the transform of the new object \param[in] shape the shape of the new object \param[in] density the density of the new object. Must be greater than zero. \return a new dynamic actor with the PxRigidBodyFlag, or NULL if it could not be constructed @see PxRigidDynamic PxShapeFlag */ PxRigidDynamic* PxCreateDynamic(PxPhysics& sdk, const PxTransform& transform, PxShape& shape, PxReal density); /** \brief simple method to create a kinematic PxRigidDynamic actor with a single PxShape. \param[in] sdk the PxPhysics object \param[in] transform the global pose of the new object \param[in] geometry the geometry of the new object's shape \param[in] material the material for the new object's shape \param[in] density the density of the new object. Must be greater than zero if the object is to participate in simulation. \param[in] shapeOffset an optional offset for the new shape, defaults to identity \note unlike PxCreateDynamic, the geometry is not restricted to box, capsule, sphere or convex. However, kinematics of other geometry types may not participate in simulation collision and may be used only for triggers or scene queries of moving objects under animation control. In this case the density parameter will be ignored and the created shape will be set up as a scene query only shape (see #PxShapeFlag::eSCENE_QUERY_SHAPE) \return a new dynamic actor with the PxRigidBodyFlag::eKINEMATIC set, or NULL if it could not be constructed @see PxRigidDynamic PxShapeFlag */ PxRigidDynamic* PxCreateKinematic(PxPhysics& sdk, const PxTransform& transform, const PxGeometry& geometry, PxMaterial& material, PxReal density, const PxTransform& shapeOffset = PxTransform(PxIdentity)); /** \brief simple method to create a kinematic PxRigidDynamic actor with a single PxShape. \param[in] sdk the PxPhysics object \param[in] transform the global pose of the new object \param[in] density the density of the new object. Must be greater than zero if the object is to participate in simulation. \param[in] shape the shape of the new object \note unlike PxCreateDynamic, the geometry is not restricted to box, capsule, sphere or convex. However, kinematics of other geometry types may not participate in simulation collision and may be used only for triggers or scene queries of moving objects under animation control. In this case the density parameter will be ignored and the created shape will be set up as a scene query only shape (see #PxShapeFlag::eSCENE_QUERY_SHAPE) \return a new dynamic actor with the PxRigidBodyFlag::eKINEMATIC set, or NULL if it could not be constructed @see PxRigidDynamic PxShapeFlag */ PxRigidDynamic* PxCreateKinematic(PxPhysics& sdk, const PxTransform& transform, PxShape& shape, PxReal density); /** \brief simple method to create a PxRigidStatic actor with a single PxShape. \param[in] sdk the PxPhysics object \param[in] transform the global pose of the new object \param[in] geometry the geometry of the new object's shape \param[in] material the material for the new object's shape \param[in] shapeOffset an optional offset for the new shape, defaults to identity \return a new static actor, or NULL if it could not be constructed @see PxRigidStatic */ PxRigidStatic* PxCreateStatic(PxPhysics& sdk, const PxTransform& transform, const PxGeometry& geometry, PxMaterial& material, const PxTransform& shapeOffset = PxTransform(PxIdentity)); /** \brief simple method to create a PxRigidStatic actor with a single PxShape. \param[in] sdk the PxPhysics object \param[in] transform the global pose of the new object \param[in] shape the new object's shape \return a new static actor, or NULL if it could not be constructed @see PxRigidStatic */ PxRigidStatic* PxCreateStatic(PxPhysics& sdk, const PxTransform& transform, PxShape& shape); /** \brief create a shape by copying attributes from another shape The function clones a PxShape. The following properties are copied: - geometry - flags - materials - actor-local pose - contact offset - rest offset - simulation filter data - query filter data - torsional patch radius - minimum torsional patch radius The following are not copied and retain their default values: - name - user data \param[in] physicsSDK - the physics SDK used to allocate the shape \param[in] shape the shape from which to take the attributes. \param[in] isExclusive whether the new shape should be an exclusive or shared shape. \return the newly-created rigid static */ PxShape* PxCloneShape(PxPhysics& physicsSDK, const PxShape& shape, bool isExclusive); /** \brief create a static body by copying attributes from another rigid actor The function clones a PxRigidDynamic or PxRigidStatic as a PxRigidStatic. A uniform scale is applied. The following properties are copied: - shapes - actor flags - owner client and client behavior bits - dominance group The following are not copied and retain their default values: - name - joints or observers - aggregate or scene membership - user data \note Transforms are not copied with bit-exact accuracy. \param[in] physicsSDK - the physics SDK used to allocate the rigid static \param[in] actor the rigid actor from which to take the attributes. \param[in] transform the transform of the new static. \return the newly-created rigid static */ PxRigidStatic* PxCloneStatic(PxPhysics& physicsSDK, const PxTransform& transform, const PxRigidActor& actor); /** \brief create a dynamic body by copying attributes from an existing body The following properties are copied: - shapes - actor flags, rigidDynamic flags and rigidDynamic lock flags - mass, moment of inertia, and center of mass frame - linear and angular velocity - linear and angular damping - maximum linear velocity - maximum angular velocity - position and velocity solver iterations - maximum depenetration velocity - sleep threshold - contact report threshold - dominance group - owner client and client behavior bits - name pointer - kinematic target The following are not copied and retain their default values: - name - joints or observers - aggregate or scene membership - sleep timer - user data \note Transforms are not copied with bit-exact accuracy. \param[in] physicsSDK PxPhysics - the physics SDK used to allocate the rigid static \param[in] body the rigid dynamic to clone. \param[in] transform the transform of the new dynamic \return the newly-created rigid static */ PxRigidDynamic* PxCloneDynamic(PxPhysics& physicsSDK, const PxTransform& transform, const PxRigidDynamic& body); /** \brief create a plane actor. The plane equation is n.x + d = 0 \param[in] sdk the PxPhysics object \param[in] plane a plane of the form n.x + d = 0 \param[in] material the material for the new object's shape \return a new static actor, or NULL if it could not be constructed @see PxRigidStatic */ PxRigidStatic* PxCreatePlane(PxPhysics& sdk, const PxPlane& plane, PxMaterial& material); /** \brief scale a rigid actor by a uniform scale The geometry and relative positions of the actor are multiplied by the given scale value. If the actor is a rigid body or an articulation link and the scaleMassProps value is true, the mass properties are scaled assuming the density is constant: the center of mass is linearly scaled, the mass is multiplied by the cube of the scale, and the inertia tensor by the fifth power of the scale. \param[in] actor a rigid actor \param[in] scale the scale by which to multiply the actor. Must be >0. \param[in] scaleMassProps whether to scale the mass properties */ void PxScaleRigidActor(PxRigidActor& actor, PxReal scale, bool scaleMassProps = true); #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
11,038
C
36.043624
140
0.758108
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxRigidActorExt.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_RIGID_ACTOR_EXT_H #define PX_RIGID_ACTOR_EXT_H /** \addtogroup extensions @{ */ #include "PxPhysXConfig.h" #include "PxPhysics.h" #include "PxRigidActor.h" #if !PX_DOXYGEN namespace physx { #endif class PxBVH; /** \brief utility functions for use with PxRigidActor and subclasses @see PxRigidActor PxRigidStatic PxRigidBody PxRigidDynamic PxArticulationLink */ class PxRigidActorExt { public: /** \brief Creates a new shape with default properties and a list of materials and adds it to the list of shapes of this actor. This is equivalent to the following PxShape* shape(...) = PxGetPhysics().createShape(...); // reference count is 1 actor->attachShape(shape); // increments reference count shape->release(); // releases user reference, leaving reference count at 1 As a consequence, detachShape() will result in the release of the last reference, and the shape will be deleted. \note The default shape flags to be set are: eVISUALIZATION, eSIMULATION_SHAPE, eSCENE_QUERY_SHAPE (see #PxShapeFlag). Triangle mesh, heightfield or plane geometry shapes configured as eSIMULATION_SHAPE are not supported for non-kinematic PxRigidDynamic instances. \note Creating compounds with a very large number of shapes may adversely affect performance and stability. <b>Sleeping:</b> Does <b>NOT</b> wake the actor up automatically. \param[in] actor the actor to which to attach the shape \param[in] geometry the geometry of the shape \param[in] materials a pointer to an array of material pointers \param[in] materialCount the count of materials \param[in] shapeFlags optional PxShapeFlags \return The newly created shape. @see PxShape PxShape::release(), PxPhysics::createShape(), PxRigidActor::attachShape() */ static PxShape* createExclusiveShape(PxRigidActor& actor, const PxGeometry& geometry, PxMaterial*const* materials, PxU16 materialCount, PxShapeFlags shapeFlags = PxShapeFlag::eVISUALIZATION | PxShapeFlag::eSCENE_QUERY_SHAPE | PxShapeFlag::eSIMULATION_SHAPE) { PxShape* shape = PxGetPhysics().createShape(geometry, materials, materialCount, true, shapeFlags); if(shape) { bool status = actor.attachShape(*shape); // attach can fail, if e.g. we try and attach a trimesh simulation shape to a dynamic actor shape->release(); // if attach fails, we hold the only counted reference, and so this cleans up properly if(!status) shape = NULL; } return shape; } /** \brief Creates a new shape with default properties and a single material adds it to the list of shapes of this actor. This is equivalent to the following PxShape* shape(...) = PxGetPhysics().createShape(...); // reference count is 1 actor->attachShape(shape); // increments reference count shape->release(); // releases user reference, leaving reference count at 1 As a consequence, detachShape() will result in the release of the last reference, and the shape will be deleted. \note The default shape flags to be set are: eVISUALIZATION, eSIMULATION_SHAPE, eSCENE_QUERY_SHAPE (see #PxShapeFlag). Triangle mesh, heightfield or plane geometry shapes configured as eSIMULATION_SHAPE are not supported for non-kinematic PxRigidDynamic instances. \note Creating compounds with a very large number of shapes may adversely affect performance and stability. <b>Sleeping:</b> Does <b>NOT</b> wake the actor up automatically. \param[in] actor the actor to which to attach the shape \param[in] geometry the geometry of the shape \param[in] material the material for the shape \param[in] shapeFlags optional PxShapeFlags \return The newly created shape. @see PxShape PxShape::release(), PxPhysics::createShape(), PxRigidActor::attachShape() */ static PX_FORCE_INLINE PxShape* createExclusiveShape(PxRigidActor& actor, const PxGeometry& geometry, const PxMaterial& material, PxShapeFlags shapeFlags = PxShapeFlag::eVISUALIZATION | PxShapeFlag::eSCENE_QUERY_SHAPE | PxShapeFlag::eSIMULATION_SHAPE) { PxMaterial* materialPtr = const_cast<PxMaterial*>(&material); return createExclusiveShape(actor, geometry, &materialPtr, 1, shapeFlags); } /** \brief Gets a list of bounds based on shapes in rigid actor. This list can be used to cook/create bounding volume hierarchy though PxCooking API. \param[in] actor The actor from which the bounds list is retrieved. \param[out] numBounds Number of bounds in returned list. @see PxShape PxBVH PxCooking::createBVH PxCooking::cookBVH */ static PxBounds3* getRigidActorShapeLocalBoundsList(const PxRigidActor& actor, PxU32& numBounds); /** \brief Convenience function to create a PxBVH object from a PxRigidActor. The computed PxBVH can then be used in PxScene::addActor() or PxAggregate::addActor(). After adding the actor & BVH to the scene/aggregate, release the PxBVH object by calling PxBVH::release(). \param[in] physics The physics object. The function will retrieve the insertion callback from it. \param[in] actor The actor to compute a PxBVH for. \return The PxBVH for this actor. @see PxBVH PxScene::addActor PxAggregate::addActor */ static PxBVH* createBVHFromActor(PxPhysics& physics, const PxRigidActor& actor); }; #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
6,988
C
40.850299
143
0.75601
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxSerialization.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_SERIALIZATION_H #define PX_SERIALIZATION_H /** \addtogroup extensions @{ */ #include "PxPhysXConfig.h" #include "common/PxBase.h" #include "cooking/PxCooking.h" #include "foundation/PxIO.h" #include "common/PxTolerancesScale.h" #include "common/PxTypeInfo.h" #include "common/PxStringTable.h" /** PX_BINARY_SERIAL_VERSION is used to version the PhysX binary data and meta data. The global unique identifier of the PhysX SDK needs to match the one in the data and meta data, otherwise they are considered incompatible. A 32 character wide GUID can be generated with https://www.guidgenerator.com/ for example. */ #define PX_BINARY_SERIAL_VERSION "F57A6B4570DF49E38116AB1E0284A98B" #if !PX_DOXYGEN namespace physx { #endif class PxBinaryConverter; /** \brief Utility functions for serialization @see PxCollection, PxSerializationRegistry */ class PxSerialization { public: /** \brief Additional PxScene and PxPhysics options stored in XML serialized data. \deprecated Xml serialization is deprecated. An alternative serialization system is provided through USD Physics. The PxXmlMiscParameter parameter can be serialized and deserialized along with PxCollection instances (XML only). This is for application use only and has no impact on how objects are serialized or deserialized. @see PxSerialization::createCollectionFromXml, PxSerialization::serializeCollectionToXml */ struct PX_DEPRECATED PxXmlMiscParameter { /** \brief Up vector for the scene reference coordinate system. */ PxVec3 upVector; /** \brief Tolerances scale to be used for the scene. */ PxTolerancesScale scale; PxXmlMiscParameter() : upVector(0) {} PxXmlMiscParameter(PxVec3& inUpVector, PxTolerancesScale inScale) : upVector(inUpVector), scale(inScale) {} }; /** \brief Returns whether the collection is serializable with the externalReferences collection. Some definitions to explain whether a collection can be serialized or not: For definitions of <b>requires</b> and <b>complete</b> see #PxSerialization::complete A serializable object is <b>subordinate</b> if it cannot be serialized on its own The following objects are subordinate: - articulation links - articulation joints - joints A collection C can be serialized with external references collection D iff - C is complete relative to D (no dangling references) - Every object in D required by an object in C has a valid ID (no unnamed references) - Every subordinate object in C is required by another object in C (no orphans) \param[in] collection Collection to be checked \param[in] sr PxSerializationRegistry instance with information about registered classes. \param[in] externalReferences the external References collection \return Whether the collection is serializable @see PxSerialization::complete, PxSerialization::serializeCollectionToBinary, PxSerialization::serializeCollectionToXml, PxSerializationRegistry */ static bool isSerializable(PxCollection& collection, PxSerializationRegistry& sr, const PxCollection* externalReferences = NULL); /** \brief Adds to a collection all objects such that it can be successfully serialized. A collection C is complete relative to an other collection D if every object required by C is either in C or D. This function adds objects to a collection, such that it becomes complete with respect to the exceptFor collection. Completeness is needed for serialization. See #PxSerialization::serializeCollectionToBinary, #PxSerialization::serializeCollectionToXml. Sdk objects require other sdk object according to the following rules: - joints require their actors and constraint - rigid actors require their shapes - shapes require their material(s) and mesh (triangle mesh, convex mesh or height field), if any - articulations require their links and joints - aggregates require their actors If followJoints is specified another rule is added: - actors require their joints Specifying followJoints will make whole jointed actor chains being added to the collection. Following chains is interrupted whenever a object in exceptFor is encountered. \param[in,out] collection Collection which is completed \param[in] sr PxSerializationRegistry instance with information about registered classes. \param[in] exceptFor Optional exemption collection \param[in] followJoints Specifies whether joints should be added for jointed actors @see PxCollection, PxSerialization::serializeCollectionToBinary, PxSerialization::serializeCollectionToXml, PxSerializationRegistry */ static void complete(PxCollection& collection, PxSerializationRegistry& sr, const PxCollection* exceptFor = NULL, bool followJoints = false); /** \brief Creates PxSerialObjectId values for unnamed objects in a collection. Creates PxSerialObjectId names for unnamed objects in a collection starting at a base value and incrementing, skipping values that are already assigned to objects in the collection. \param[in,out] collection Collection for which names are created \param[in] base Start address for PxSerialObjectId names @see PxCollection */ static void createSerialObjectIds(PxCollection& collection, const PxSerialObjectId base); /** \brief Creates a PxCollection from XML data. \deprecated Xml serialization is deprecated. An alternative serialization system is provided through USD Physics. \param inputData The input data containing the XML collection. \param params Cooking parameters used for sdk object instantiation. \param sr PxSerializationRegistry instance with information about registered classes. \param externalRefs PxCollection used to resolve external references. \param stringTable PxStringTable instance used for storing object names. \param outArgs Optional parameters of physics and scene deserialized from XML. See #PxSerialization::PxXmlMiscParameter \return a pointer to a PxCollection if successful or NULL if it failed. @see PxCollection, PxSerializationRegistry, PxInputData, PxStringTable, PxCooking, PxSerialization::PxXmlMiscParameter */ PX_DEPRECATED static PxCollection* createCollectionFromXml(PxInputData& inputData, const PxCookingParams& params, PxSerializationRegistry& sr, const PxCollection* externalRefs = NULL, PxStringTable* stringTable = NULL, PxXmlMiscParameter* outArgs = NULL); /** \brief Deserializes a PxCollection from memory. Creates a collection from memory. If the collection has external dependencies another collection can be provided to resolve these. The memory block provided has to be 128 bytes aligned and contain a contiguous serialized collection as written by PxSerialization::serializeCollectionToBinary. The contained binary data needs to be compatible with the current binary format version which is defined by "PX_PHYSICS_VERSION_MAJOR.PX_PHYSICS_VERSION_MINOR.PX_PHYSICS_VERSION_BUGFIX-PX_BINARY_SERIAL_VERSION". For a list of compatible sdk releases refer to the documentation of PX_BINARY_SERIAL_VERSION. \param[in] memBlock Pointer to memory block containing the serialized collection \param[in] sr PxSerializationRegistry instance with information about registered classes. \param[in] externalRefs Collection to resolve external dependencies @see PxCollection, PxSerialization::complete, PxSerialization::serializeCollectionToBinary, PxSerializationRegistry, PX_BINARY_SERIAL_VERSION */ static PxCollection* createCollectionFromBinary(void* memBlock, PxSerializationRegistry& sr, const PxCollection* externalRefs = NULL); /** \brief Serializes a physics collection to an XML output stream. \deprecated Xml serialization is deprecated. An alternative serialization system is provided through USD Physics. The collection to be serialized needs to be complete @see PxSerialization.complete. Optionally the XML may contain meshes in binary cooked format for fast loading. It does this when providing a valid non-null PxCooking pointer. \note Serialization of objects in a scene that is simultaneously being simulated is not supported and leads to undefined behavior. \param outputStream Stream to save collection to. \param collection PxCollection instance which is serialized. The collection needs to be complete with respect to the externalRefs collection. \param sr PxSerializationRegistry instance with information about registered classes. \param params Optional pointer to cooking params. If provided, cooked mesh data is cached for fast loading. \param externalRefs Collection containing external references. \param inArgs Optional parameters of physics and scene serialized to XML along with the collection. See #PxSerialization::PxXmlMiscParameter \return true if the collection is successfully serialized. @see PxCollection, PxOutputStream, PxSerializationRegistry, PxCooking, PxSerialization::PxXmlMiscParameter */ PX_DEPRECATED static bool serializeCollectionToXml(PxOutputStream& outputStream, PxCollection& collection, PxSerializationRegistry& sr, const PxCookingParams* params = NULL, const PxCollection* externalRefs = NULL, PxXmlMiscParameter* inArgs = NULL); /** \brief Serializes a collection to a binary stream. Serializes a collection to a stream. In order to resolve external dependencies the externalReferences collection has to be provided. Optionally names of objects that where set for example with #PxActor::setName are serialized along with the objects. The collection can be successfully serialized if isSerializable(collection) returns true. See #isSerializable. The implementation of the output stream needs to fulfill the requirements on the memory block input taken by PxSerialization::createCollectionFromBinary. \note Serialization of objects in a scene that is simultaneously being simulated is not supported and leads to undefined behavior. \param[out] outputStream into which the collection is serialized \param[in] collection Collection to be serialized \param[in] sr PxSerializationRegistry instance with information about registered classes. \param[in] externalRefs Collection used to resolve external dependencies \param[in] exportNames Specifies whether object names are serialized \return Whether serialization was successful @see PxCollection, PxOutputStream, PxSerialization::complete, PxSerialization::createCollectionFromBinary, PxSerializationRegistry */ static bool serializeCollectionToBinary(PxOutputStream& outputStream, PxCollection& collection, PxSerializationRegistry& sr, const PxCollection* externalRefs = NULL, bool exportNames = false ); /** \brief Serializes a collection to a binary stream. \deprecated Deterministic binary serialization is deprecated. PxSerialization::serializeCollectionToBinary might become deterministic in the future. Convenience function that serializes a collection to a stream while rebasing memory addresses and handles to achieve a deterministic output, independent of the PhysX runtime environment the objects have been created in. The same functionality can be achieved by manually - creating a binary data stream with PxSerialization::serializeCollectionToBinary - producing the binary meta data of the current runtime platform with PxSerialization::dumpBinaryMetaData - converting the binary data stream with the PxBinaryConverter, using the binary meta for both source and destination @see PxSerialization::serializeCollectionToBinary, PxSerialization::dumpBinaryMetaData, PxBinaryConverter */ PX_DEPRECATED static bool serializeCollectionToBinaryDeterministic(PxOutputStream& outputStream, PxCollection& collection, PxSerializationRegistry& sr, const PxCollection* externalRefs = NULL, bool exportNames = false); /** \brief Dumps the binary meta-data to a stream. \deprecated Binary conversion and binary meta data are deprecated. A meta-data file contains information about the SDK's internal classes and about custom user types ready for serialization. Such a file is needed to convert binary-serialized data from one platform to another (re-targeting). The converter needs meta-data files for the source and target platforms to perform conversions. Custom user types can be supported with PxSerializationRegistry::registerBinaryMetaDataCallback (see the guide for more information). \param[out] outputStream Stream to write meta data to \param[in] sr PxSerializationRegistry instance with information about registered classes used for conversion. @see PxOutputStream, PxSerializationRegistry */ PX_DEPRECATED static void dumpBinaryMetaData(PxOutputStream& outputStream, PxSerializationRegistry& sr); /** \brief Creates binary converter for re-targeting binary-serialized data. \deprecated Binary conversion and binary meta data are deprecated. \return Binary converter instance. */ PX_DEPRECATED static PxBinaryConverter* createBinaryConverter(); /** \brief Creates an application managed registry for serialization. \param[in] physics Physics SDK to generate create serialization registry \return PxSerializationRegistry instance. @see PxSerializationRegistry */ static PxSerializationRegistry* createSerializationRegistry(PxPhysics& physics); }; #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
14,930
C
48.440397
256
0.804488
NVIDIA-Omniverse/PhysX/physx/include/extensions/PxParticleClothCooker.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_PARTICLE_CLOTH_COOKER_H #define PX_PARTICLE_CLOTH_COOKER_H /** \addtogroup extensions @{ */ #include "foundation/PxSimpleTypes.h" #include "foundation/PxVec4.h" #if !PX_DOXYGEN namespace physx { #endif namespace ExtGpu { /** \brief Holds all the information for a particle cloth constraint used in the PxParticleClothCooker. */ struct PxParticleClothConstraint { enum { eTYPE_INVALID_CONSTRAINT = 0, eTYPE_HORIZONTAL_CONSTRAINT = 1, eTYPE_VERTICAL_CONSTRAINT = 2, eTYPE_DIAGONAL_CONSTRAINT = 4, eTYPE_BENDING_CONSTRAINT = 8, eTYPE_DIAGONAL_BENDING_CONSTRAINT = 16, eTYPE_ALL = eTYPE_HORIZONTAL_CONSTRAINT | eTYPE_VERTICAL_CONSTRAINT | eTYPE_DIAGONAL_CONSTRAINT | eTYPE_BENDING_CONSTRAINT | eTYPE_DIAGONAL_BENDING_CONSTRAINT }; PxU32 particleIndexA; //!< The first particle index of this constraint. PxU32 particleIndexB; //!< The second particle index of this constraint. PxReal length; //!< The distance between particle A and B. PxU32 constraintType; //!< The type of constraint, see the constraint type enum. }; /* \brief Generates PxParticleClothConstraint constraints that connect the individual particles of a particle cloth. */ class PxParticleClothCooker { public: virtual void release() = 0; /** \brief Generate the constraint list and triangle index list. \param[in] constraints A pointer to an array of PxParticleClothConstraint constraints. If NULL, the cooker will generate all the constraints. Otherwise, the user-provided constraints will be added. \param[in] numConstraints The number of user-provided PxParticleClothConstraint s. */ virtual void cookConstraints(const PxParticleClothConstraint* constraints = NULL, const PxU32 numConstraints = 0) = 0; virtual PxU32* getTriangleIndices() = 0; //!< \return A pointer to the triangle indices. virtual PxU32 getTriangleIndicesCount() = 0; //!< \return The number of triangle indices. virtual PxParticleClothConstraint* getConstraints() = 0; //!< \return A pointer to the PxParticleClothConstraint constraints. virtual PxU32 getConstraintCount() = 0; //!< \return The number of constraints. virtual void calculateMeshVolume() = 0; //!< Computes the volume of a closed mesh and the contraintScale. Expects vertices in local space - 'close' to origin. virtual PxReal getMeshVolume() = 0; //!< \return The mesh volume calculated by PxParticleClothCooker::calculateMeshVolume. protected: virtual ~PxParticleClothCooker() {} }; } // namespace ExtGpu /** \brief Creates a PxParticleClothCooker. \param[in] vertexCount The number of vertices of the particle cloth. \param[in] inVertices The vertex positions of the particle cloth. \param[in] triangleIndexCount The number of triangles of the cloth mesh. \param[in] inTriangleIndices The triangle indices of the cloth mesh \param[in] constraintTypeFlags The types of constraints to generate. See PxParticleClothConstraint. \param[in] verticalDirection The vertical direction of the cloth mesh. This is needed to generate the correct horizontal and vertical constraints to model shear stiffness. \param[in] bendingConstraintMaxAngle The maximum angle (in radians) considered in the bending constraints. \return A pointer to the new PxParticleClothCooker. */ ExtGpu::PxParticleClothCooker* PxCreateParticleClothCooker(PxU32 vertexCount, physx::PxVec4* inVertices, PxU32 triangleIndexCount, PxU32* inTriangleIndices, PxU32 constraintTypeFlags = ExtGpu::PxParticleClothConstraint::eTYPE_ALL, PxVec3 verticalDirection = PxVec3(0.0f, 1.0f, 0.0f), PxReal bendingConstraintMaxAngle = 20.0f*PxTwoPi/360.0f ); #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
5,357
C
43.280991
199
0.770581
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/PxVehicleComponentSequence.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "foundation/PxAssert.h" #include "foundation/PxErrors.h" #include "foundation/PxFoundation.h" #include "PxVehicleComponent.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif struct PxVehicleComponentSequenceLimits { enum Enum { eMAX_NB_SUBGROUPS = 16, eMAX_NB_COMPONENTS = 64, eMAX_NB_SUBGROUPELEMENTS = eMAX_NB_SUBGROUPS + eMAX_NB_COMPONENTS }; }; struct PxVehicleComponentSequence { enum { eINVALID_SUBSTEP_GROUP = 0xff }; PxVehicleComponentSequence() : mNbComponents(0), mNbSubgroups(1), mNbSubGroupElements(0), mActiveSubgroup(0) { } /** \brief Add a component to the sequence. \param[in] component The component to add to the sequence. \return True on success, else false (for example due to component count limit being reached). */ PX_FORCE_INLINE bool add(PxVehicleComponent* component); /** \brief Start a substepping group. \note All components added using #add() will be added to the new substepping group until either the group is marked as complete with a call to #endSubstepGroup() or a subsequent substepping group is started with a call to #beginSubstepGroup(). \note Groups can be nested with stacked calls to #beginSubstepGroup(). \note Each group opened by #beginSubstepGroup() must be closed with a complementary #endSubstepGroup() prior to calling #update(). \param[in] nbSubSteps is the number of substeps for the group's sequence. This can be changed with a call to #setSubsteps(). \return Handle for the substepping group on success, else eINVALID_SUBSTEP_GROUP @see setSubsteps() @see endSubstepGroup() */ PX_FORCE_INLINE PxU8 beginSubstepGroup(const PxU8 nbSubSteps = 1); /** \brief End a substepping group \note The group most recently opened with #beginSubstepGroup() will be closed by this call. @see setSubsteps() @see beginSubstepGroup() */ PX_FORCE_INLINE void endSubstepGroup() { mActiveSubgroup = mSubGroups[mActiveSubgroup].parentGroup; } /** \brief Set the number of substeps to perform for a specific substepping group. \param[in] subGroupHandle specifies the substepping group \param[in] nbSteps is the number of times to invoke the sequence of components and groups in the specified substepping group. @see beginSubstepGroup() @see endSubstepGroup() */ void setSubsteps(const PxU8 subGroupHandle, const PxU8 nbSteps) { PX_ASSERT(subGroupHandle < mNbSubgroups); mSubGroups[subGroupHandle].nbSteps = nbSteps; } /** \brief Update each component in the sequence. \note If the update method of a component in the sequence returns false, the update process gets aborted. \param[in] dt is the timestep of the update. The provided value has to be positive. \param[in] context specifies global quantities of the simulation such as gravitational acceleration. */ void update(const PxReal dt, const PxVehicleSimulationContext& context) { PX_ASSERT(0 == mActiveSubgroup); if (dt > 0.0f) { updateSubGroup(dt, context, 0, 1); } else { PxGetFoundation().error(PxErrorCode::eINVALID_PARAMETER, PX_FL, "PxVehicleComponentSequence::update: The timestep must be positive!"); } } private: enum { eINVALID_COMPONENT = 0xff, eINVALID_SUB_GROUP_ELEMENT = 0xff }; //Elements have the form of a linked list to allow traversal over a list of elements. //Each element is either a single component or a subgroup. struct SubGroupElement { SubGroupElement() : childGroup(eINVALID_SUBSTEP_GROUP), component(eINVALID_COMPONENT), nextElement(eINVALID_SUB_GROUP_ELEMENT) { } PxU8 childGroup; PxU8 component; PxU8 nextElement; }; //A group is a linked list of elements to be processed in sequence. //Each group stores the first element in the sequence. //Each element in the sequence stores the next element in the sequence //to allow traversal over the list of elements in the group. struct Group { Group() : parentGroup(eINVALID_SUBSTEP_GROUP), firstElement(eINVALID_SUB_GROUP_ELEMENT), nbSteps(1) { } PxU8 parentGroup; PxU8 firstElement; PxU8 nbSteps; }; PxVehicleComponent* mComponents[PxVehicleComponentSequenceLimits::eMAX_NB_COMPONENTS]; PxU8 mNbComponents; Group mSubGroups[PxVehicleComponentSequenceLimits::eMAX_NB_SUBGROUPS]; PxU8 mNbSubgroups; SubGroupElement mSubGroupElements[PxVehicleComponentSequenceLimits::eMAX_NB_SUBGROUPELEMENTS]; PxU8 mNbSubGroupElements; PxU8 mActiveSubgroup; bool updateSubGroup(const PxReal dt, const PxVehicleSimulationContext& context, const PxU8 groupId, const PxU8 parentSepMultiplier) { const PxU8 nbSteps = mSubGroups[groupId].nbSteps; const PxU8 stepMultiplier = parentSepMultiplier * nbSteps; const PxReal timestepForGroup = dt / PxReal(stepMultiplier); for (PxU8 k = 0; k < nbSteps; k++) { PxU8 nextElement = mSubGroups[groupId].firstElement; while (eINVALID_SUB_GROUP_ELEMENT != nextElement) { const SubGroupElement& e = mSubGroupElements[nextElement]; PX_ASSERT(e.component != eINVALID_COMPONENT || e.childGroup != eINVALID_SUBSTEP_GROUP); if (eINVALID_COMPONENT != e.component) { PxVehicleComponent* c = mComponents[e.component]; if (!c->update(timestepForGroup, context)) return false; } else { PX_ASSERT(eINVALID_SUBSTEP_GROUP != e.childGroup); if (!updateSubGroup(dt, context, e.childGroup, stepMultiplier)) return false; } nextElement = e.nextElement; } } return true; } PxU8 getLastKnownElementInGroup(const PxU8 groupId) const { PxU8 currElement = mSubGroups[groupId].firstElement; PxU8 nextElement = mSubGroups[groupId].firstElement; while (nextElement != eINVALID_SUB_GROUP_ELEMENT) { currElement = nextElement; nextElement = mSubGroupElements[nextElement].nextElement; } return currElement; } }; bool PxVehicleComponentSequence::add(PxVehicleComponent* c) { if (PxVehicleComponentSequenceLimits::eMAX_NB_COMPONENTS == mNbComponents) return false; if (PxVehicleComponentSequenceLimits::eMAX_NB_SUBGROUPELEMENTS == mNbSubGroupElements) return false; //Create a new element and point it at the component. SubGroupElement& nextElementInGroup = mSubGroupElements[mNbSubGroupElements]; nextElementInGroup.childGroup = eINVALID_SUBSTEP_GROUP; nextElementInGroup.component = mNbComponents; nextElementInGroup.nextElement = eINVALID_SUB_GROUP_ELEMENT; if (eINVALID_SUB_GROUP_ELEMENT == mSubGroups[mActiveSubgroup].firstElement) { //The group is empty so add the first element to it. //Point the group at the new element because this will //be the first element in the group. mSubGroups[mActiveSubgroup].firstElement = mNbSubGroupElements; } else { //We are extending the sequence of element of the group. //Add the new element to the end of the group's sequence. mSubGroupElements[getLastKnownElementInGroup(mActiveSubgroup)].nextElement = mNbSubGroupElements; } //Increment the number of elements. mNbSubGroupElements++; //Record the component and increment the number of components. mComponents[mNbComponents] = c; mNbComponents++; return true; } PxU8 PxVehicleComponentSequence::beginSubstepGroup(const PxU8 nbSubSteps) { if (mNbSubgroups == PxVehicleComponentSequenceLimits::eMAX_NB_SUBGROUPS) return eINVALID_SUBSTEP_GROUP; if (mNbSubGroupElements == PxVehicleComponentSequenceLimits::eMAX_NB_SUBGROUPELEMENTS) return eINVALID_SUBSTEP_GROUP; //We have a parent and child group relationship. const PxU8 parentGroup = mActiveSubgroup; const PxU8 childGroup = mNbSubgroups; //Set up the child group. mSubGroups[childGroup].parentGroup = parentGroup; mSubGroups[childGroup].firstElement = eINVALID_SUB_GROUP_ELEMENT; mSubGroups[childGroup].nbSteps = nbSubSteps; //Create a new element to add to the parent group and point it at the child group. SubGroupElement& nextElementIInGroup = mSubGroupElements[mNbSubGroupElements]; nextElementIInGroup.childGroup = childGroup; nextElementIInGroup.nextElement = eINVALID_SUB_GROUP_ELEMENT; nextElementIInGroup.component = eINVALID_COMPONENT; //Add the new element to the parent group. if (eINVALID_SUB_GROUP_ELEMENT == mSubGroups[parentGroup].firstElement) { //The parent group is empty so add the first element to it. //Point the parent group at the new element because this will //be the first element in the group. mSubGroups[parentGroup].firstElement = mNbSubGroupElements; } else { //We are extending the sequence of elements of the parent group. //Add the new element to the end of the group's sequence. mSubGroupElements[getLastKnownElementInGroup(parentGroup)].nextElement = mNbSubGroupElements; } //Push the active group. //All subsequent operations will now address the child group and we push or pop the group. mActiveSubgroup = childGroup; //Increment the number of elements. mNbSubGroupElements++; //Increment the number of groups. mNbSubgroups++; //Return the group id. return mActiveSubgroup; } #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
10,775
C
31.954128
132
0.757865
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/PxVehicleAPI.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "vehicle2/PxVehicleLimits.h" #include "vehicle2/PxVehicleComponent.h" #include "vehicle2/PxVehicleComponentSequence.h" #include "vehicle2/PxVehicleParams.h" #include "vehicle2/PxVehicleFunctions.h" #include "vehicle2/PxVehicleMaths.h" #include "vehicle2/braking/PxVehicleBrakingParams.h" #include "vehicle2/braking/PxVehicleBrakingFunctions.h" #include "vehicle2/commands/PxVehicleCommandParams.h" #include "vehicle2/commands/PxVehicleCommandStates.h" #include "vehicle2/commands/PxVehicleCommandHelpers.h" #include "vehicle2/drivetrain/PxVehicleDrivetrainParams.h" #include "vehicle2/drivetrain/PxVehicleDrivetrainStates.h" #include "vehicle2/drivetrain/PxVehicleDrivetrainHelpers.h" #include "vehicle2/drivetrain/PxVehicleDrivetrainFunctions.h" #include "vehicle2/drivetrain/PxVehicleDrivetrainComponents.h" #include "vehicle2/physxActor/PxVehiclePhysXActorStates.h" #include "vehicle2/physxActor/PxVehiclePhysXActorHelpers.h" #include "vehicle2/physxActor/PxVehiclePhysXActorFunctions.h" #include "vehicle2/physxActor/PxVehiclePhysXActorComponents.h" #include "vehicle2/physxConstraints/PxVehiclePhysXConstraintParams.h" #include "vehicle2/physxConstraints/PxVehiclePhysXConstraintStates.h" #include "vehicle2/physxConstraints/PxVehiclePhysXConstraintHelpers.h" #include "vehicle2/physxConstraints/PxVehiclePhysXConstraintFunctions.h" #include "vehicle2/physxConstraints/PxVehiclePhysXConstraintComponents.h" #include "vehicle2/physxRoadGeometry/PxVehiclePhysXRoadGeometryState.h" #include "vehicle2/physxRoadGeometry/PxVehiclePhysXRoadGeometryParams.h" #include "vehicle2/physxRoadGeometry/PxVehiclePhysXRoadGeometryHelpers.h" #include "vehicle2/physxRoadGeometry/PxVehiclePhysXRoadGeometryFunctions.h" #include "vehicle2/physxRoadGeometry/PxVehiclePhysXRoadGeometryComponents.h" #include "vehicle2/pvd/PxVehiclePvdHelpers.h" #include "vehicle2/pvd/PxVehiclePvdFunctions.h" #include "vehicle2/pvd/PxVehiclePvdComponents.h" #include "vehicle2/rigidBody/PxVehicleRigidBodyParams.h" #include "vehicle2/rigidBody/PxVehicleRigidBodyStates.h" #include "vehicle2/rigidBody/PxVehicleRigidBodyFunctions.h" #include "vehicle2/rigidBody/PxVehicleRigidBodyComponents.h" #include "vehicle2/roadGeometry/PxVehicleRoadGeometryState.h" #include "vehicle2/steering/PxVehicleSteeringParams.h" #include "vehicle2/steering/PxVehicleSteeringFunctions.h" #include "vehicle2/suspension/PxVehicleSuspensionParams.h" #include "vehicle2/suspension/PxVehicleSuspensionStates.h" #include "vehicle2/suspension/PxVehicleSuspensionHelpers.h" #include "vehicle2/suspension/PxVehicleSuspensionFunctions.h" #include "vehicle2/suspension/PxVehicleSuspensionComponents.h" #include "vehicle2/tire/PxVehicleTireParams.h" #include "vehicle2/tire/PxVehicleTireStates.h" #include "vehicle2/tire/PxVehicleTireHelpers.h" #include "vehicle2/tire/PxVehicleTireFunctions.h" #include "vehicle2/tire/PxVehicleTireComponents.h" #include "vehicle2/wheel/PxVehicleWheelParams.h" #include "vehicle2/wheel/PxVehicleWheelStates.h" #include "vehicle2/wheel/PxVehicleWheelHelpers.h" #include "vehicle2/wheel/PxVehicleWheelFunctions.h" #include "vehicle2/wheel/PxVehicleWheelComponents.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif /** \brief Initialize the PhysX Vehicle library. This should be called before calling any functions or methods in extensions which may require allocation. \note This function does not need to be called before creating a PxDefaultAllocator object. \param foundation a PxFoundation object @see PxCloseVehicleExtension PxFoundation */ PX_FORCE_INLINE bool PxInitVehicleExtension(physx::PxFoundation& foundation) { PX_UNUSED(foundation); PX_CHECK_AND_RETURN_VAL(&PxGetFoundation() == &foundation, "Supplied foundation must match the one that will be used to perform allocations", false); PxIncFoundationRefCount(); return true; } /** \brief Shut down the PhysX Vehicle library. This function should be called to cleanly shut down the PhysX Vehicle library before application exit. \note This function is required to be called to release foundation usage. @see PxInitVehicleExtension */ PX_FORCE_INLINE void PxCloseVehicleExtension() { PxDecFoundationRefCount(); } #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
6,044
C
39.844594
151
0.812376
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/PxVehicleFunctions.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "foundation/PxTransform.h" #include "foundation/PxMat33.h" #include "foundation/PxSimpleTypes.h" #include "PxRigidBody.h" #include "PxVehicleParams.h" #include "roadGeometry/PxVehicleRoadGeometryState.h" #include "rigidBody/PxVehicleRigidBodyStates.h" #include "physxRoadGeometry/PxVehiclePhysXRoadGeometryState.h" #include "physxActor/PxVehiclePhysXActorStates.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif PX_FORCE_INLINE PxVec3 PxVehicleTransformFrameToFrame (const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVec3& v) { PxVec3 result = v; if ((srcFrame.lngAxis != trgFrame.lngAxis) || (srcFrame.latAxis != trgFrame.latAxis) || (srcFrame.vrtAxis != trgFrame.vrtAxis)) { const PxMat33 a = srcFrame.getFrame(); const PxMat33 r = trgFrame.getFrame(); result = (r * a.getTranspose() * v); } return result; } PX_FORCE_INLINE PxVec3 PxVehicleTransformFrameToFrame (const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale, const PxVec3& v) { PxVec3 result = PxVehicleTransformFrameToFrame(srcFrame, trgFrame, v); if((srcScale.scale != trgScale.scale)) result *= (trgScale.scale / srcScale.scale); return result; } PX_FORCE_INLINE PxTransform PxVehicleTransformFrameToFrame (const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale, const PxTransform& v) { PxTransform result(PxVehicleTransformFrameToFrame(srcFrame, trgFrame, srcScale, trgScale, v.p), v.q); if ((srcFrame.lngAxis != trgFrame.lngAxis) || (srcFrame.latAxis != trgFrame.latAxis) || (srcFrame.vrtAxis != trgFrame.vrtAxis)) { PxF32 angle; PxVec3 axis; v.q.toRadiansAndUnitAxis(angle, axis); result.q = PxQuat(angle, PxVehicleTransformFrameToFrame(srcFrame, trgFrame, axis)); } return result; } PX_FORCE_INLINE PxVec3 PxVehicleComputeTranslation(const PxVehicleFrame& frame, const PxReal lng, const PxReal lat, const PxReal vrt) { const PxVec3 v = frame.getFrame()*PxVec3(lng, lat, vrt); return v; } PX_FORCE_INLINE PxQuat PxVehicleComputeRotation(const PxVehicleFrame& frame, const PxReal roll, const PxReal pitch, const PxReal yaw) { const PxMat33 m = frame.getFrame(); const PxVec3& lngAxis = m.column0; const PxVec3& latAxis = m.column1; const PxVec3& vrtAxis = m.column2; const PxQuat quatPitch(pitch, latAxis); const PxQuat quatRoll(roll, lngAxis); const PxQuat quatYaw(yaw, vrtAxis); const PxQuat result = quatYaw * quatRoll * quatPitch; return result; } PX_FORCE_INLINE PxF32 PxVehicleComputeSign(const PxReal f) { return physx::intrinsics::fsel(f, physx::intrinsics::fsel(-f, 0.0f, 1.0f), -1.0f); } /** \brief Shift the origin of a vehicle by the specified vector. Call this method to adjust the internal data structures of vehicles to reflect the shifted origin location (the shift vector will get subtracted from all world space spatial data). \param[in] axleDesc is a description of the wheels on the vehicle. \param[in] shift is the translation vector used to shift the origin. \param[in] rigidBodyState stores the current position of the vehicle \param[in] roadGeometryStates stores the hit plane under each wheel. \param[in] physxActor stores the PxRigidActor that is the vehicle's PhysX representation. \param[in] physxQueryStates stores the hit point of the most recent execution of PxVehiclePhysXRoadGeometryQueryUpdate() for each wheel. \note It is the user's responsibility to keep track of the summed total origin shift and adjust all input/output to/from the vehicle accordingly. \note This call will not automatically shift the PhysX scene and its objects. PxScene::shiftOrigin() must be called seperately to keep the systems in sync. \note If there is no associated PxRigidActor then set physxActor to NULL. \note If there is an associated PxRigidActor and it is already in a PxScene then the complementary call to PxScene::shiftOrigin() will take care of shifting the associated PxRigidActor. This being the case, set physxActor to NULL. physxActor should be a non-NULL pointer only when there is an associated PxRigidActor and it is not part of a PxScene. This can occur if the associated PxRigidActor is updated using PhysX immediate mode. \note If scene queries are independent of PhysX geometry then set queryStates to NULL. */ PX_FORCE_INLINE void PxVehicleShiftOrigin (const PxVehicleAxleDescription& axleDesc, const PxVec3& shift, PxVehicleRigidBodyState& rigidBodyState, PxVehicleRoadGeometryState* roadGeometryStates, PxVehiclePhysXActor* physxActor = NULL, PxVehiclePhysXRoadGeometryQueryState* physxQueryStates = NULL) { //Adjust the vehicle's internal pose. rigidBodyState.pose.p -= shift; //Optionally adjust the PxRigidActor pose. if (physxActor && !physxActor->rigidBody->getScene()) { const PxTransform oldPose = physxActor->rigidBody->getGlobalPose(); const PxTransform newPose(oldPose.p - shift, oldPose.q); physxActor->rigidBody->setGlobalPose(newPose); } for (PxU32 i = 0; i < axleDesc.nbWheels; i++) { const PxU32 wheelId = axleDesc.wheelIdsInAxleOrder[i]; //Optionally adjust the hit position. if (physxQueryStates && physxQueryStates[wheelId].actor) physxQueryStates[wheelId].hitPosition -= shift; //Adjust the hit plane. if (roadGeometryStates[wheelId].hitState) { const PxPlane plane = roadGeometryStates[wheelId].plane; PxU32 largestNormalComponentAxis = 0; PxReal largestNormalComponent = 0.0f; const PxF32 normalComponents[3] = { plane.n.x, plane.n.y, plane.n.z }; for (PxU32 k = 0; k < 3; k++) { if (PxAbs(normalComponents[k]) > largestNormalComponent) { largestNormalComponent = PxAbs(normalComponents[k]); largestNormalComponentAxis = k; } } PxVec3 pointInPlane(PxZero); switch (largestNormalComponentAxis) { case 0: pointInPlane.x = -plane.d / plane.n.x; break; case 1: pointInPlane.y = -plane.d / plane.n.y; break; case 2: pointInPlane.z = -plane.d / plane.n.z; break; default: break; } roadGeometryStates[wheelId].plane.d = -plane.n.dot(pointInPlane - shift); } } } #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
7,998
C
38.995
155
0.759565
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/PxVehicleMaths.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "foundation/PxSimpleTypes.h" #include "foundation/PxMemory.h" #include "PxVehicleLimits.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif class PxVehicleVectorN { public: enum { eMAX_SIZE = PxVehicleLimits::eMAX_NB_WHEELS + 3 }; PxVehicleVectorN(const PxU32 size) : mSize(size) { PX_ASSERT(mSize <= PxVehicleVectorN::eMAX_SIZE); PxMemZero(mValues, sizeof(PxReal)*PxVehicleVectorN::eMAX_SIZE); } ~PxVehicleVectorN() { } PxVehicleVectorN(const PxVehicleVectorN& src) { for (PxU32 i = 0; i < src.mSize; i++) { mValues[i] = src.mValues[i]; } mSize = src.mSize; } PX_FORCE_INLINE PxVehicleVectorN& operator=(const PxVehicleVectorN& src) { for (PxU32 i = 0; i < src.mSize; i++) { mValues[i] = src.mValues[i]; } mSize = src.mSize; return *this; } PX_FORCE_INLINE PxReal& operator[] (const PxU32 i) { PX_ASSERT(i < mSize); return (mValues[i]); } PX_FORCE_INLINE const PxReal& operator[] (const PxU32 i) const { //PX_ASSERT(i < mSize); return (mValues[i]); } PX_FORCE_INLINE PxU32 getSize() const { return mSize; } private: PxReal mValues[PxVehicleVectorN::eMAX_SIZE]; PxU32 mSize; }; class PxVehicleMatrixNN { public: PxVehicleMatrixNN() : mSize(0) { } PxVehicleMatrixNN(const PxU32 size) : mSize(size) { PX_ASSERT(mSize <= PxVehicleVectorN::eMAX_SIZE); PxMemZero(mValues, sizeof(PxReal)*PxVehicleVectorN::eMAX_SIZE*PxVehicleVectorN::eMAX_SIZE); } PxVehicleMatrixNN(const PxVehicleMatrixNN& src) { for (PxU32 i = 0; i < src.mSize; i++) { for (PxU32 j = 0; j < src.mSize; j++) { mValues[i][j] = src.mValues[i][j]; } } mSize = src.mSize; } ~PxVehicleMatrixNN() { } PX_FORCE_INLINE PxVehicleMatrixNN& operator=(const PxVehicleMatrixNN& src) { for (PxU32 i = 0; i < src.mSize; i++) { for (PxU32 j = 0; j < src.mSize; j++) { mValues[i][j] = src.mValues[i][j]; } } mSize = src.mSize; return *this; } PX_FORCE_INLINE PxReal get(const PxU32 i, const PxU32 j) const { PX_ASSERT(i < mSize); PX_ASSERT(j < mSize); return mValues[i][j]; } PX_FORCE_INLINE void set(const PxU32 i, const PxU32 j, const PxReal val) { PX_ASSERT(i < mSize); PX_ASSERT(j < mSize); mValues[i][j] = val; } PX_FORCE_INLINE PxU32 getSize() const { return mSize; } PX_FORCE_INLINE void setSize(const PxU32 size) { PX_ASSERT(size <= PxVehicleVectorN::eMAX_SIZE); mSize = size; } public: PxReal mValues[PxVehicleVectorN::eMAX_SIZE][PxVehicleVectorN::eMAX_SIZE]; PxU32 mSize; }; /* LUPQ decomposition Based upon "Outer Product LU with Complete Pivoting," from Matrix Computations (4th Edition), Golub and Van Loan Solve A*x = b using: MatrixNNLUSolver solver; solver.decomposeLU(A); solver.solve(b, x); */ class PxVehicleMatrixNNLUSolver { private: PxVehicleMatrixNN mLU; PxU32 mP[PxVehicleVectorN::eMAX_SIZE - 1]; // Row permutation PxU32 mQ[PxVehicleVectorN::eMAX_SIZE - 1]; // Column permutation PxReal mDetM; public: PxVehicleMatrixNNLUSolver() {} ~PxVehicleMatrixNNLUSolver() {} PxReal getDet() const { return mDetM; } void decomposeLU(const PxVehicleMatrixNN& A); //Given a matrix A and a vector b find x that satisfies Ax = b, where the matrix A is the matrix that was passed to #decomposeLU. //Returns true if the lu decomposition indicates that the matrix has an inverse and x was successfully computed. //Returns false if the lu decomposition resulted in zero determinant ie the matrix has no inverse and no solution exists for x. //Returns false if the size of either b or x doesn't match the size of the matrix passed to #decomposeLU. //If false is returned then each relevant element of x is set to zero. bool solve(const PxVehicleVectorN& b, PxVehicleVectorN& x) const; }; class PxVehicleMatrixNGaussSeidelSolver { public: void solve(const PxU32 maxIterations, const PxReal tolerance, const PxVehicleMatrixNN& A, const PxVehicleVectorN& b, PxVehicleVectorN& result) const; }; class PxVehicleMatrix33Solver { public: bool solve(const PxVehicleMatrixNN& A_, const PxVehicleVectorN& b_, PxVehicleVectorN& result) const; }; #if !PX_DOXYGEN } //namespace vehicle2 } //namespace physx #endif /** @} */
5,957
C
24.033613
150
0.715125
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/PxVehicleParams.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "foundation/PxFoundation.h" #include "foundation/PxAssert.h" #include "foundation/PxMemory.h" #include "foundation/PxVec3.h" #include "foundation/PxMat33.h" #include "PxVehicleLimits.h" class OmniPvdWriter; #if !PX_DOXYGEN namespace physx { class PxConvexMesh; class PxScene; namespace vehicle2 { #endif struct PxVehicleAxleDescription { PX_FORCE_INLINE void setToDefault() { PxMemZero(this, sizeof(PxVehicleAxleDescription)); } /** \brief Add an axle to the vehicle by specifying the number of wheels on the axle and an array of wheel ids specifying each wheel on the axle. \param[in] nbWheelsOnAxle is the number of wheels on the axle to be added. \param[in] wheelIdsOnAxle is an array of wheel ids specifying all the wheels on the axle to be added. */ void addAxle(const PxU32 nbWheelsOnAxle, const PxU32* const wheelIdsOnAxle) { PX_ASSERT((nbWheels + nbWheelsOnAxle) < PxVehicleLimits::eMAX_NB_WHEELS); PX_ASSERT(nbAxles < PxVehicleLimits::eMAX_NB_AXLES); nbWheelsPerAxle[nbAxles] = nbWheelsOnAxle; axleToWheelIds[nbAxles] = nbWheels; for (PxU32 i = 0; i < nbWheelsOnAxle; i++) { wheelIdsInAxleOrder[nbWheels + i] = wheelIdsOnAxle[i]; } nbWheels += nbWheelsOnAxle; nbAxles++; } /** \brief Return the number of axles on the vehicle. \return The number of axles. @see getNbWheelsOnAxle() */ PX_FORCE_INLINE PxU32 getNbAxles() const { return nbAxles; } /** \brief Return the number of wheels on the ith axle. \param[in] i specifies the axle to be queried for its wheel count. \return The number of wheels on the specified axle. @see getWheelOnAxle() */ PX_FORCE_INLINE PxU32 getNbWheelsOnAxle(const PxU32 i) const { return nbWheelsPerAxle[i]; } /** \brief Return the wheel id of the jth wheel on the ith axle. \param[in] j specifies that the wheel id to be returned is the jth wheel in the list of wheels on the specified axle. \param[in] i specifies the axle to be queried. \return The wheel id of the jth wheel on the ith axle. @see getNbWheelsOnAxle() */ PX_FORCE_INLINE PxU32 getWheelOnAxle(const PxU32 j, const PxU32 i) const { return wheelIdsInAxleOrder[axleToWheelIds[i] + j]; } /** \brief Return the number of wheels on the vehicle. \return The number of wheels. */ PX_FORCE_INLINE PxU32 getNbWheels() const { return nbWheels; } /** \brief Return the axle of a specified wheel. \param[in] wheelId is the wheel whose axle is to be queried. \return The axle of the specified wheel. */ PX_FORCE_INLINE PxU32 getAxle(const PxU32 wheelId) const { for (PxU32 i = 0; i < getNbAxles(); i++) { for (PxU32 j = 0; j < getNbWheelsOnAxle(i); j++) { if (getWheelOnAxle(j, i) == wheelId) return i; } } return 0xffffffff; } PX_FORCE_INLINE bool isValid() const { PX_CHECK_AND_RETURN_VAL(nbAxles > 0, "PxVehicleAxleDescription.nbAxles must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(nbWheels > 0, "PxVehicleAxleDescription.nbWheels must be greater than zero", false); return true; } PxU32 nbAxles; //!< The number of axles on the vehicle PxU32 nbWheelsPerAxle[PxVehicleLimits::eMAX_NB_AXLES]; //!< The number of wheels on each axle. PxU32 axleToWheelIds[PxVehicleLimits::eMAX_NB_AXLES]; //!< The list of wheel ids for the ith axle begins at wheelIdsInAxleOrder[axleToWheelIds[i]] PxU32 wheelIdsInAxleOrder[PxVehicleLimits::eMAX_NB_WHEELS]; //!< The list of all wheel ids on the vehicle. PxU32 nbWheels; //!< The number of wheels on the vehicle. PX_COMPILE_TIME_ASSERT(PxVehicleLimits::eMAX_NB_AXLES == PxVehicleLimits::eMAX_NB_WHEELS); // It should be possible to support cases where each wheel is controlled individually and thus // having a wheel per axle for up to the max wheel count. }; struct PxVehicleAxes { enum Enum { ePosX = 0, //!< The +x axis eNegX, //!< The -x axis ePosY, //!< The +y axis eNegY, //!< The -y axis ePosZ, //!< The +z axis eNegZ, //!< The -z axis eMAX_NB_AXES }; }; struct PxVehicleFrame { PxVehicleAxes::Enum lngAxis; //!< The axis defining the longitudinal (forward) direction of the vehicle. PxVehicleAxes::Enum latAxis; //!< The axis defining the lateral (side) direction of the vehicle. PxVehicleAxes::Enum vrtAxis; //!< The axis defining the vertical (up) direction of the vehicle. PX_FORCE_INLINE void setToDefault() { lngAxis = PxVehicleAxes::ePosX; latAxis = PxVehicleAxes::ePosY; vrtAxis = PxVehicleAxes::ePosZ; } PX_FORCE_INLINE PxMat33 getFrame() const { const PxVec3 basisDirs[6] = { PxVec3(1,0,0), PxVec3(-1,0,0), PxVec3(0,1,0), PxVec3(0,-1,0), PxVec3(0,0,1), PxVec3(0,0,-1) }; const PxMat33 mat33(basisDirs[lngAxis], basisDirs[latAxis], basisDirs[vrtAxis]); return mat33; } PX_FORCE_INLINE PxVec3 getLngAxis() const { const PxVec3 basisDirs[6] = { PxVec3(1,0,0), PxVec3(-1,0,0), PxVec3(0,1,0), PxVec3(0,-1,0), PxVec3(0,0,1), PxVec3(0,0,-1) }; return basisDirs[lngAxis]; } PX_FORCE_INLINE PxVec3 getLatAxis() const { const PxVec3 basisDirs[6] = { PxVec3(1,0,0), PxVec3(-1,0,0), PxVec3(0,1,0), PxVec3(0,-1,0), PxVec3(0,0,1), PxVec3(0,0,-1) }; return basisDirs[latAxis]; } PX_FORCE_INLINE PxVec3 getVrtAxis() const { const PxVec3 basisDirs[6] = { PxVec3(1,0,0), PxVec3(-1,0,0), PxVec3(0,1,0), PxVec3(0,-1,0), PxVec3(0,0,1), PxVec3(0,0,-1) }; return basisDirs[vrtAxis]; } PX_FORCE_INLINE bool isValid() const { PX_CHECK_AND_RETURN_VAL(lngAxis < PxVehicleAxes::eMAX_NB_AXES, "PxVehicleFrame.lngAxis is invalid", false); PX_CHECK_AND_RETURN_VAL(latAxis < PxVehicleAxes::eMAX_NB_AXES, "PxVehicleFrame.latAxis is invalid", false); PX_CHECK_AND_RETURN_VAL(vrtAxis < PxVehicleAxes::eMAX_NB_AXES, "PxVehicleFrame.vrtAxis is invalid", false); const PxMat33 frame = getFrame(); const PxQuat quat(frame); PX_CHECK_AND_RETURN_VAL(quat.isFinite() && quat.isUnit() && quat.isSane(), "PxVehicleFrame is not a legal frame", false); return true; } }; struct PxVehicleScale { PxReal scale; //!< The length scale used for the vehicle. For example, if 1.0 is considered meters, then 100.0 would be for centimeters. PX_FORCE_INLINE void setToDefault() { scale = 1.0f; } PX_FORCE_INLINE bool isValid() const { PX_CHECK_AND_RETURN_VAL(scale > 0.0f, "PxVehicleScale.scale must be greater than zero", false); return true; } }; /** \brief Helper struct to pass array type data to vehice components and functions. The Vehicle SDK tries to give the user a certain freedom in how the parameters and states are stored. This helper struct presents a way to either use array of structs or array of pointers to structs to pass data into the provided vehicle components and functions. */ template<typename T> struct PxVehicleArrayData { enum DataFormat { eARRAY_OF_STRUCTS = 0, //!< The data is provided as an array of structs and stored in #arrayOfStructs. eARRAY_OF_POINTERS //!< The data is provided as an array of pointers and stored in #arrayOfPointers. }; /** \brief Set the data as an array of structs. \param[in] data The data as an array of structs. */ PX_FORCE_INLINE void setData(T* data) { arrayOfStructs = data; dataFormat = eARRAY_OF_STRUCTS; } /** \brief Set the data as an array of pointers. \param[in] data The data as an array of pointers. */ PX_FORCE_INLINE void setData(T*const* data) { arrayOfPointers= data; dataFormat = eARRAY_OF_POINTERS; } PX_FORCE_INLINE PxVehicleArrayData() { } PX_FORCE_INLINE explicit PxVehicleArrayData(T* data) { setData(data); } PX_FORCE_INLINE explicit PxVehicleArrayData(T*const* data) { setData(data); } /** \brief Get the data entry at a given index. \param[in] index The index to retrieve the data entry for. \return Reference to the requested data entry. */ PX_FORCE_INLINE T& getData(PxU32 index) { if (dataFormat == eARRAY_OF_STRUCTS) return arrayOfStructs[index]; else return *arrayOfPointers[index]; } PX_FORCE_INLINE T& operator[](PxU32 index) { return getData(index); } /** \brief Get the data entry at a given index. \param[in] index The index to retrieve the data entry for. \return Reference to the requested data entry. */ PX_FORCE_INLINE const T& getData(PxU32 index) const { if (dataFormat == eARRAY_OF_STRUCTS) return arrayOfStructs[index]; else return *arrayOfPointers[index]; } PX_FORCE_INLINE const T& operator[](PxU32 index) const { return getData(index); } /** \brief Set as empty. */ PX_FORCE_INLINE void setEmpty() { arrayOfStructs = NULL; } /** \brief Check if declared as empty. \return True if empty, else false. */ PX_FORCE_INLINE bool isEmpty() const { return (arrayOfStructs == NULL); } /** \brief Get a reference to the array but read only. \return Read only version of the data. */ PX_FORCE_INLINE const PxVehicleArrayData<const T>& getConst() const { return reinterpret_cast<const PxVehicleArrayData<const T>&>(*this); } union { T* arrayOfStructs; //!< The data stored as an array of structs. T*const* arrayOfPointers; //!< The data stored as an array of pointers. }; PxU8 dataFormat; }; template<typename T> struct PxVehicleSizedArrayData : public PxVehicleArrayData<T> { /** \brief Set the data as an array of structs and set the number of data entries. \param[in] data The data as an array of structs. \param[in] count The number of entries in the data array. */ PX_FORCE_INLINE void setDataAndCount(T* data, const PxU32 count) { PxVehicleArrayData<T>::setData(data); size = count; } /** \brief Set the data as an array of pointers and set the number of data entries. \param[in] data The data as an array of pointers. \param[in] count The number of entries in the data array. */ PX_FORCE_INLINE void setDataAndCount(T*const* data, const PxU32 count) { PxVehicleArrayData<T>::setData(data); size = count; } /** \brief Set as empty. */ PX_FORCE_INLINE void setEmpty() { PxVehicleArrayData<T>::setEmpty(); size = 0; } /** \brief Check if declared as empty. \return True if empty, else false. */ PX_FORCE_INLINE bool isEmpty() const { return ((size == 0) || PxVehicleArrayData<T>::isEmpty()); } PxU32 size; }; /** \brief Determine whether the PhysX actor associated with a vehicle is to be updated with a velocity change or an acceleration change. A velocity change will be immediately reflected in linear and angular velocity queries against the vehicle. An acceleration change, on the other hand, will leave the linear and angular velocities unchanged until the next PhysX scene update has applied the acceleration update to the actor's linear and angular velocities. @see PxVehiclePhysXActorEndComponent @see PxVehicleWriteRigidBodyStateToPhysXActor */ struct PxVehiclePhysXActorUpdateMode { enum Enum { eAPPLY_VELOCITY = 0, eAPPLY_ACCELERATION }; }; /** \brief Tire slip values are computed using ratios with potential for divide-by-zero errors. PxVehicleTireSlipParams introduces a minimum value for the denominator of each of these ratios. */ struct PxVehicleTireSlipParams { /** \brief The lateral slip angle is typically computed as a function of the ratio of lateral and longitudinal speeds of the rigid body in the tire's frame. This leads to a divide-by-zero in the event that the longitudinal speed approaches zero. The parameter minLatSlipDenominator sets a minimum denominator for the ratio of speeds used to compute the lateral slip angle. \note Larger timesteps typically require larger values of minLatSlipDenominator. <b>Range:</b> (0, inf)<br> <b>Unit:</b> velocity = length / time */ PxReal minLatSlipDenominator; /** \brief The longitudinal slip represents the difference between the longitudinal speed of the rigid body in the tire's frame and the linear speed arising from the rotation of the wheel. This is typically normalized using the reciprocal of the longitudinal speed of the rigid body in the tire's frame. This leads to a divide-by-zero in the event that the longitudinal speed approaches zero. The parameter minPassiveLongSlipDenominator sets a minimum denominator for the normalized longitudinal slip when the wheel experiences zero drive torque and zero brake torque and zero handbrake torque. The aim is to bring the vehicle to rest without experiencing wheel rotational speeds that oscillate around zero. \note The vehicle will come to rest more smoothly with larger values of minPassiveLongSlipDenominator, particularly with large timesteps that often lead to oscillation in wheel rotation speeds when the wheel rotation speed approaches zero. \note It is recommended that minActiveLongSlipDenominator < minPassiveLongSlipDenominator. <b>Range:</b> (0, inf)<br> <b>Unit:</b> velocity = length / time */ PxReal minPassiveLongSlipDenominator; /** \brief The longitudinal slip represents the difference between the longitudinal speed of the rigid body in the tire's frame and the linear speed arising from the rotation of the wheel. This is typically normalized using the reciprocal of the longitudinal speed of the rigid body in the tire's frame. This leads to a divide-by-zero in the event that the longitudinal speed approaches zero. The parameter minActiveLongSlipDenominator sets a minimum denominator for the normalized longitudinal slip when the wheel experiences either a non-zero drive torque or a non-zero brake torque or a non-zero handbrake torque. \note Larger timesteps typically require larger values of minActiveLongSlipDenominator to avoid instabilities occurring when the vehicle is aggressively throttled from rest. \note It is recommended that minActiveLongSlipDenominator < minPassiveLongSlipDenominator. <b>Range:</b> (0, inf)<br> <b>Unit:</b> velocity = length / time */ PxReal minActiveLongSlipDenominator; PX_FORCE_INLINE void setToDefault() { minLatSlipDenominator = 1.0f; minActiveLongSlipDenominator = 0.1f; minPassiveLongSlipDenominator = 4.0f; } PX_FORCE_INLINE PxVehicleTireSlipParams transformAndScale( const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const { PX_UNUSED(srcFrame); PX_UNUSED(trgFrame); PxVehicleTireSlipParams p = *this; const PxReal scaleRatio = trgScale.scale / srcScale.scale; p.minLatSlipDenominator *= scaleRatio; p.minPassiveLongSlipDenominator *= scaleRatio; p.minActiveLongSlipDenominator *= scaleRatio; return p; } PX_FORCE_INLINE bool isValid() const { PX_CHECK_AND_RETURN_VAL(minLatSlipDenominator > 0.0f, "PxVehicleTireSlipParams.minLatSlipDenominator must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(minPassiveLongSlipDenominator > 0.0f, "PxVehicleTireSlipParams.minPassiveLongSlipDenominator must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(minActiveLongSlipDenominator > 0.0f, "PxVehicleTireSlipParams.minActiveLongSlipDenominator must be greater than zero", false); return true; } }; /** \brief Tires have two important directions for the purposes of tire force computation: longitudinal and lateral. */ struct PxVehicleTireDirectionModes { enum Enum { eLONGITUDINAL = 0, eLATERAL, eMAX_NB_PLANAR_DIRECTIONS }; }; /** \brief The low speed regime often presents numerical difficulties for the tire model due to the potential for divide-by-zero errors. This particularly affects scenarios where the vehicle is slowing down due to damping and drag. In scenarios where there is no significant brake or drive torque, numerical error begins to dominate and it can be difficult to bring the vehicle to rest. A solution to this problem is to recognise that the vehicle is close to rest and to replace the tire forces with velocity constraints that will bring the vehicle to rest. This regime is known as the "sticky tire" regime. PxVehicleTireAxisStickyParams describes velocity and time thresholds that categorise the "sticky tire" regime. It also describes the rate at which the velocity constraints approach zero speed. */ struct PxVehicleTireAxisStickyParams { /** \brief A tire enters the "sticky tire" regime when it has been below a speed specified by #thresholdSpeed for a continuous time specified by #thresholdTime. <b>Range:</b> [0, inf)<br> <b>Unit:</b> velocity = length / time */ PxReal thresholdSpeed; /** \brief A tire enters the "sticky tire" regime when it has been below a speed specified by #thresholdSpeed for a continuous time specified by #thresholdTime. <b>Range:</b> [0, inf)<br> <b>Unit:</b> time */ PxReal thresholdTime; /** \brief The rate at which the velocity constraint approaches zero is controlled by the damping parameter. \note Larger values of damping lead to faster approaches to zero. Since the damping behaves like a stiffness with respect to the velocity, too large a value can lead to instabilities. <b>Range:</b> [0, inf)<br> <b>Unit:</b> 1 / time (acceleration instead of force based damping, thus not mass/time) */ PxReal damping; PX_FORCE_INLINE PxVehicleTireAxisStickyParams transformAndScale( const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const { PX_UNUSED(srcFrame); PX_UNUSED(trgFrame); PxVehicleTireAxisStickyParams p = *this; const PxReal scaleRatio = trgScale.scale / srcScale.scale; p.thresholdSpeed *= scaleRatio; return p; } PX_FORCE_INLINE bool isValid() const { PX_CHECK_AND_RETURN_VAL(thresholdSpeed >= 0.0f, "PxVehicleTireAxisStickyParams.thresholdSpeed must be greater than or equal to zero", false); PX_CHECK_AND_RETURN_VAL(thresholdTime >= 0.0f, "PxVehicleTireAxisStickyParams.thresholdTime must be greater than or equal to zero", false); PX_CHECK_AND_RETURN_VAL(damping >= 0.0f, "PxVehicleTireAxisStickyParams.damping must be greater than or equal to zero", false); return true; } }; /** \brief For each tire, the forces of the tire model may be replaced by velocity constraints when the tire enters the "sticky tire" regime. The "sticky tire" regime of the lateral and longitudinal directions of the tire are managed separately. */ struct PxVehicleTireStickyParams { /** The "sticky tire" regime of the lateral and longitudinal directions of the tire are managed separately and are individually parameterized. */ PxVehicleTireAxisStickyParams stickyParams[PxVehicleTireDirectionModes::eMAX_NB_PLANAR_DIRECTIONS]; PX_FORCE_INLINE void setToDefault() { stickyParams[PxVehicleTireDirectionModes::eLONGITUDINAL].thresholdSpeed = 0.2f; stickyParams[PxVehicleTireDirectionModes::eLONGITUDINAL].thresholdTime = 1.0f; stickyParams[PxVehicleTireDirectionModes::eLONGITUDINAL].damping = 1.0f; stickyParams[PxVehicleTireDirectionModes::eLATERAL].thresholdSpeed = 0.2f; stickyParams[PxVehicleTireDirectionModes::eLATERAL].thresholdTime = 1.0f; stickyParams[PxVehicleTireDirectionModes::eLATERAL].damping = 0.1f; } PX_FORCE_INLINE PxVehicleTireStickyParams transformAndScale( const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const { PxVehicleTireStickyParams p = *this; p.stickyParams[PxVehicleTireDirectionModes::eLONGITUDINAL] = stickyParams[PxVehicleTireDirectionModes::eLONGITUDINAL].transformAndScale(srcFrame, trgFrame, srcScale, trgScale); p.stickyParams[PxVehicleTireDirectionModes::eLATERAL] = stickyParams[PxVehicleTireDirectionModes::eLATERAL].transformAndScale(srcFrame, trgFrame, srcScale, trgScale); return p; } PX_FORCE_INLINE bool isValid() const { if (!stickyParams[PxVehicleTireDirectionModes::eLONGITUDINAL].isValid()) return false; if (!stickyParams[PxVehicleTireDirectionModes::eLATERAL].isValid()) return false; return true; } }; struct PxVehicleSimulationContextType { enum Enum { eDEFAULT, //!< The simulation context inherits from PxVehicleSimulationContext ePHYSX //!< The simulation context inherits from PxVehiclePhysXSimulationContext }; }; /** \brief Structure to support Omni PVD, the PhysX Visual Debugger. */ struct PxVehiclePvdContext { public: PX_FORCE_INLINE void setToDefault() { attributeHandles = NULL; writer = NULL; } /** \brief The attribute handles used to reflect vehicle parameter and state data in omnipvd. \note A null value will result in no values being reflected in omnipvd. \note #attributeHandles and #writer both need to be non-NULL to reflect vehicle values in omnipvd. @see PxVehiclePvdAttributesCreate @see PxVehiclePvdAttributesRelease @see PxVehiclePVDComponent */ const struct PxVehiclePvdAttributeHandles* attributeHandles; /** \brief An instance of OmniPvdWriter used to write vehicle prameter and state data to omnipvd. \note A null value will result in no values being reflected in omnipvd. \note #attributeHandles and #writer both need to be non-NULL to reflect vehicle values in omnipvd. @see PxVehiclePvdAttributesCreate @see PxVehiclePvdAttributesRelease @see PxVehiclePVDComponent */ OmniPvdWriter* writer; }; struct PxVehicleSimulationContext { PxVehicleSimulationContext() : type(PxVehicleSimulationContextType::eDEFAULT) {} PxVec3 gravity; PxVehicleFrame frame; PxVehicleScale scale; //Tire PxVehicleTireSlipParams tireSlipParams; PxVehicleTireStickyParams tireStickyParams; /** \brief Forward wheel speed below which the wheel rotation speed gets blended with the rolling speed. The blended rotation speed is used to integrate the wheel rotation angle. At low forward wheel speed, the wheel rotation speed can get unstable (depending on the tire model used) and, for example, oscillate. \note If brake or throttle is applied, there will be no blending. <b>Unit:</b> velocity = length / time */ PxReal thresholdForwardSpeedForWheelAngleIntegration; /** \brief Structure to support Omni PVD, the PhysX Visual Debugger. */ PxVehiclePvdContext pvdContext; protected: PxVehicleSimulationContextType::Enum type; public: PX_FORCE_INLINE PxVehicleSimulationContextType::Enum getType() const { return type; } PX_FORCE_INLINE void setToDefault() { frame.setToDefault(); scale.setToDefault(); gravity = frame.getVrtAxis() * (-9.81f * scale.scale); tireSlipParams.setToDefault(); tireStickyParams.setToDefault(); thresholdForwardSpeedForWheelAngleIntegration = 5.0f * scale.scale; pvdContext.setToDefault(); } PX_FORCE_INLINE PxVehicleSimulationContext transformAndScale( const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const { PxVehicleSimulationContext c = *this; const PxReal scaleRatio = trgScale.scale / srcScale.scale; c.gravity = trgFrame.getFrame()*srcFrame.getFrame().getTranspose()*c.gravity; c.gravity *= scaleRatio; c.tireSlipParams = tireSlipParams.transformAndScale(srcFrame, trgFrame, srcScale, trgScale); c.tireStickyParams = tireStickyParams.transformAndScale(srcFrame, trgFrame, srcScale, trgScale); c.thresholdForwardSpeedForWheelAngleIntegration *= scaleRatio; c.frame = trgFrame; c.scale = trgScale; return c; } }; struct PxVehiclePhysXSimulationContext : public PxVehicleSimulationContext { PxVehiclePhysXSimulationContext() : PxVehicleSimulationContext() { type = PxVehicleSimulationContextType::ePHYSX; } //Road geometry queries to find the plane under the wheel. const PxConvexMesh* physxUnitCylinderSweepMesh; const PxScene* physxScene; //PhysX actor update PxVehiclePhysXActorUpdateMode::Enum physxActorUpdateMode; /** \brief Wake counter value to set on the physx actor if a reset is required. Certain vehicle states should keep a physx actor of a vehicle awake. This will be achieved by resetting the wake counter value if needed. The wake counter value is the minimum simulation time that a physx actor will stay awake. <b>Unit:</b> time @see physxActorWakeCounterThreshold PxVehiclePhysxActorKeepAwakeCheck */ PxReal physxActorWakeCounterResetValue; /** \brief Threshold below which to check whether the physx actor wake counter should get reset. <b>Unit:</b> time @see physxActorWakeCounterResetValue PxVehiclePhysxActorKeepAwakeCheck */ PxReal physxActorWakeCounterThreshold; PX_FORCE_INLINE void setToDefault() { PxVehicleSimulationContext::setToDefault(); physxUnitCylinderSweepMesh = NULL; physxScene = NULL; physxActorUpdateMode = PxVehiclePhysXActorUpdateMode::eAPPLY_VELOCITY; physxActorWakeCounterResetValue = 20.0f * 0.02f; // 20 timesteps of size 0.02 physxActorWakeCounterThreshold = 0.5f * physxActorWakeCounterResetValue; } PX_FORCE_INLINE PxVehiclePhysXSimulationContext transformAndScale( const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const { PxVehiclePhysXSimulationContext r = *this; static_cast<PxVehicleSimulationContext&>(r) = PxVehicleSimulationContext::transformAndScale(srcFrame, trgFrame, srcScale, trgScale); return r; } }; /** * \brief Express a function as a sequence of points {(x, y)} that form a piecewise polynomial. */ template <class T, unsigned int NB_ELEMENTS> class PxVehicleFixedSizeLookupTable { public: PxVehicleFixedSizeLookupTable() : nbDataPairs(0) { } PxVehicleFixedSizeLookupTable(const PxVehicleFixedSizeLookupTable& src) { PxMemCopy(xVals, src.xVals, sizeof(PxReal)* src.nbDataPairs); PxMemCopy(yVals, src.yVals, sizeof(T)*src.nbDataPairs); nbDataPairs = src.nbDataPairs; } ~PxVehicleFixedSizeLookupTable() { } PxVehicleFixedSizeLookupTable& operator=(const PxVehicleFixedSizeLookupTable& src) { PxMemCopy(xVals, src.xVals, sizeof(PxReal)*src.nbDataPairs); PxMemCopy(yVals, src.yVals, sizeof(T)*src.nbDataPairs); nbDataPairs = src.nbDataPairs; return *this; } /** \brief Add one more point to create one more polynomial segment of a piecewise polynomial. */ PX_FORCE_INLINE bool addPair(const PxReal x, const T y) { PX_CHECK_AND_RETURN_VAL(nbDataPairs < NB_ELEMENTS, "PxVehicleFixedSizeLookupTable::addPair() exceeded fixed size capacity", false); xVals[nbDataPairs] = x; yVals[nbDataPairs] = y; nbDataPairs++; return true; } /** \brief Identify the segment of the piecewise polynomial that includes x and compute the corresponding y value by linearly interpolating the gradient of the segment. \param[in] x is the value on the x-axis of the piecewise polynomial. \return Returns the y value that corresponds to the input x. */ PX_FORCE_INLINE T interpolate(const PxReal x) const { if (0 == nbDataPairs) { return T(0); } if (1 == nbDataPairs || x < xVals[0]) { return yVals[0]; } PxReal x0 = xVals[0]; T y0 = yVals[0]; for (PxU32 i = 1; i < nbDataPairs; i++) { const PxReal x1 = xVals[i]; const T y1 = yVals[i]; if ((x >= x0) && (x < x1)) { return (y0 + (y1 - y0) * (x - x0) / (x1 - x0)); } x0 = x1; y0 = y1; } PX_ASSERT(x >= xVals[nbDataPairs - 1]); return yVals[nbDataPairs - 1]; } void clear() { PxMemSet(xVals, 0, NB_ELEMENTS * sizeof(PxReal)); PxMemSet(yVals, 0, NB_ELEMENTS * sizeof(T)); nbDataPairs = 0; } PxReal xVals[NB_ELEMENTS]; T yVals[NB_ELEMENTS]; PxU32 nbDataPairs; PX_FORCE_INLINE bool isValid() const { for (PxU32 i = 1; i < nbDataPairs; i++) { PX_CHECK_AND_RETURN_VAL(xVals[i] > xVals[i - 1], "PxVehicleFixedSizeLookupTable:: xVals[i+1] must be greater than xVals[i]", false); } return true; } }; #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
29,370
C
31.099454
165
0.746612
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/PxVehicleComponent.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "foundation/PxSimpleTypes.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif struct PxVehicleSimulationContext; class PxVehicleComponent { public: virtual ~PxVehicleComponent() {} /** \brief Update function for a vehicle component. \param[in] dt The timestep size to use for the update step. \param[in] context Vehicle simulation context holding global data or data that usually applies to a large group of vehicles. \return True if subsequent components in a sequence should get updated, false if the sequence should be aborted. @see PxVehicleComponentSequence */ virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context) = 0; }; #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
2,546
C
34.873239
101
0.752553
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/physxActor/PxVehiclePhysXActorStates.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "foundation/PxPreprocessor.h" #include "foundation/PxMemory.h" #include "PxRigidBody.h" #include "vehicle2/PxVehicleLimits.h" #if !PX_DOXYGEN namespace physx { class PxShape; namespace vehicle2 { #endif /** \brief A description of the PhysX actor and shapes that represent the vehicle in an associated PxScene. */ struct PxVehiclePhysXActor { /** \brief The PhysX rigid body that represents the vehcle in the associated PhysX scene. \note PxActorFlag::eDISABLE_GRAVITY must be set true on the PxRigidBody */ PxRigidBody* rigidBody; /** \brief An array of shapes with one shape pointer (or NULL) for each wheel. */ PxShape* wheelShapes[PxVehicleLimits::eMAX_NB_WHEELS]; PX_FORCE_INLINE void setToDefault() { PxMemZero(this, sizeof(PxVehiclePhysXActor)); } }; #define PX_VEHICLE_UNSPECIFIED_STEER_STATE PX_MAX_F32 /** \brief A description of the previous steer command applied to the vehicle. */ struct PxVehiclePhysXSteerState { /** \brief The steer command that was most previously applied to the vehicle. */ PxReal previousSteerCommand; PX_FORCE_INLINE void setToDefault() { previousSteerCommand = PX_VEHICLE_UNSPECIFIED_STEER_STATE; } }; #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
3,012
C
29.434343
103
0.753984
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/physxActor/PxVehiclePhysXActorHelpers.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "PxFiltering.h" #include "PxShape.h" #if !PX_DOXYGEN namespace physx { class PxGeometry; class PxMaterial; struct PxCookingParams; namespace vehicle2 { #endif struct PxVehicleRigidBodyParams; struct PxVehicleAxleDescription; struct PxVehicleWheelParams; struct PxVehiclePhysXActor; struct PxVehicleFrame; struct PxVehicleSuspensionParams; class PxVehiclePhysXRigidActorParams { PX_NOCOPY(PxVehiclePhysXRigidActorParams) public: PxVehiclePhysXRigidActorParams(const PxVehicleRigidBodyParams& _physxActorRigidBodyParams, const char* _physxActorName) : rigidBodyParams(_physxActorRigidBodyParams), physxActorName(_physxActorName) { } const PxVehicleRigidBodyParams& rigidBodyParams; const char* physxActorName; }; class PxVehiclePhysXRigidActorShapeParams { PX_NOCOPY(PxVehiclePhysXRigidActorShapeParams) public: PxVehiclePhysXRigidActorShapeParams (const PxGeometry& _geometry, const PxTransform& _localPose, const PxMaterial& _material, const PxShapeFlags _flags, const PxFilterData& _simulationFilterData, const PxFilterData& _queryFilterData) : geometry(_geometry), localPose(_localPose), material(_material), flags(_flags), simulationFilterData(_simulationFilterData), queryFilterData(_queryFilterData) { } const PxGeometry& geometry; const PxTransform& localPose; const PxMaterial& material; PxShapeFlags flags; PxFilterData simulationFilterData; PxFilterData queryFilterData; }; class PxVehiclePhysXWheelParams { PX_NOCOPY(PxVehiclePhysXWheelParams) public: PxVehiclePhysXWheelParams(const PxVehicleAxleDescription& _axleDescription, const PxVehicleWheelParams* _wheelParams) : axleDescription(_axleDescription), wheelParams(_wheelParams) { } const PxVehicleAxleDescription& axleDescription; const PxVehicleWheelParams* wheelParams; }; class PxVehiclePhysXWheelShapeParams { PX_NOCOPY(PxVehiclePhysXWheelShapeParams) public: PxVehiclePhysXWheelShapeParams(const PxMaterial& _material, const PxShapeFlags _flags, const PxFilterData _simulationFilterData, const PxFilterData _queryFilterData) : material(_material), flags(_flags), simulationFilterData(_simulationFilterData), queryFilterData(_queryFilterData) { } const PxMaterial& material; PxShapeFlags flags; PxFilterData simulationFilterData; PxFilterData queryFilterData; }; /** \brief Create a PxRigidDynamic instance, instantiate it with desired properties and populate it with PxShape instances. \param[in] vehicleFrame describes the frame of the vehicle. \param[in] rigidActorParams describes the mass and moment of inertia of the rigid body. \param[in] rigidActorCmassLocalPose specifies the mapping between actor and rigid body frame. \param[in] rigidActorShapeParams describes the collision geometry associated with the rigid body. \param[in] wheelParams describes the radius and half-width of the wheels. \param[in] wheelShapeParams describes the PxMaterial and PxShapeFlags to apply to the wheel shapes. \param[in] physics is a PxPhysics instance. \param[in] params is a PxCookingParams instance \param[in] vehiclePhysXActor is a record of the PxRigidDynamic and PxShape instances instantiated. \note This is an alternative to PxVehiclePhysXArticulationLinkCreate. \note PxVehiclePhysXActorCreate primarily serves as an illustration of the instantiation of the PhysX class instances required to simulate a vehicle with a PxRigidDynamic. @see PxVehiclePhysXActorDestroy */ void PxVehiclePhysXActorCreate (const PxVehicleFrame& vehicleFrame, const PxVehiclePhysXRigidActorParams& rigidActorParams, const PxTransform& rigidActorCmassLocalPose, const PxVehiclePhysXRigidActorShapeParams& rigidActorShapeParams, const PxVehiclePhysXWheelParams& wheelParams, const PxVehiclePhysXWheelShapeParams& wheelShapeParams, PxPhysics& physics, const PxCookingParams& params, PxVehiclePhysXActor& vehiclePhysXActor); /** \brief Configure an actor so that it is ready for vehicle simulation. \param[in] rigidActorParams describes the mass and moment of inertia of the rigid body. \param[in] rigidActorCmassLocalPose specifies the mapping between actor and rigid body frame. \param[out] rigidBody is the body to be prepared for simulation. */ void PxVehiclePhysXActorConfigure (const PxVehiclePhysXRigidActorParams& rigidActorParams, const PxTransform& rigidActorCmassLocalPose, PxRigidBody& rigidBody); /** \brief Create a PxArticulationReducedCoordinate and a single PxArticulationLink, instantiate the PxArticulationLink with desired properties and populate it with PxShape instances. \param[in] vehicleFrame describes the frame of the vehicle. \param[in] rigidActorParams describes the mass and moment of inertia of the rigid body. \param[in] rigidActorCmassLocalPose specifies the mapping between actor and rigid body frame. \param[in] rigidActorShapeParams describes the collision geometry associated with the rigid body. \param[in] wheelParams describes the radius and half-width of the wheels. \param[in] wheelShapeParams describes the PxMaterial and PxShapeFlags to apply to the wheel shapes. \param[in] physics is a PxPhysics instance. \param[in] params is a PxCookingParams instance \param[in] vehiclePhysXActor is a record of the PxArticulationReducedCoordinate, PxArticulationLink and PxShape instances instantiated. \note This is an alternative to PxVehiclePhysXActorCreate. \note PxVehiclePhysXArticulationLinkCreate primarily serves as an illustration of the instantiation of the PhysX class instances required to simulate a vehicle as part of an articulated ensemble. @see PxVehiclePhysXActorDestroy */ void PxVehiclePhysXArticulationLinkCreate (const PxVehicleFrame& vehicleFrame, const PxVehiclePhysXRigidActorParams& rigidActorParams, const PxTransform& rigidActorCmassLocalPose, const PxVehiclePhysXRigidActorShapeParams& rigidActorShapeParams, const PxVehiclePhysXWheelParams& wheelParams, const PxVehiclePhysXWheelShapeParams& wheelShapeParams, PxPhysics& physics, const PxCookingParams& params, PxVehiclePhysXActor& vehiclePhysXActor); /** \brief Release the PxRigidDynamic, PxArticulationReducedCoordinate, PxArticulationLink and PxShape instances instantiated by PxVehiclePhysXActorCreate or PxVehiclePhysXArticulationLinkCreate. \param[in] vehiclePhysXActor is a description of the PhysX instances to be released. */ void PxVehiclePhysXActorDestroy(PxVehiclePhysXActor& vehiclePhysXActor); #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
8,225
C
38.171428
166
0.814225
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/physxActor/PxVehiclePhysXActorFunctions.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "foundation/PxSimpleTypes.h" #include "vehicle2/PxVehicleParams.h" #if !PX_DOXYGEN namespace physx { class PxRigidBody; class PxShape; namespace vehicle2 { #endif struct PxVehicleCommandState; struct PxVehicleEngineDriveTransmissionCommandState; struct PxVehicleEngineParams; struct PxVehicleEngineState; struct PxVehicleGearboxParams; struct PxVehicleGearboxState; struct PxVehicleRigidBodyState; struct PxVehiclePhysXConstraints; struct PxVehicleWheelLocalPose; struct PxVehicleWheelParams; struct PxVehicleWheelRigidBody1dState; struct PxVehiclePhysXSteerState; /** \brief Wake up the physx actor if the actor is asleep and the commands signal an intent to change the state of the vehicle. \param[in] commands are the brake, throttle and steer values that will drive the vehicle. \param[in] transmissionCommands are the target gear and clutch values that will control the transmission. If the target gear is different from the current gearbox target gear, then the physx actor will get woken up. Can be set to NULL if the vehicle does not have a gearbox or if this is not a desired behavior. If specified, then gearParams and gearState has to be specifed too. \param[in] gearParams The gearbox parameters. Can be set to NULL if the vehicle does not have a gearbox and transmissionCommands is NULL. \param[in] gearState The state of the gearbox. Can be set to NULL if the vehicle does not have a gearbox and transmissionCommands is NULL. \param[in] physxActor is the PxRigidBody instance associated with the vehicle. \param[in,out] physxSteerState and commands are compared to determine if the steering state has changed since the last call to PxVehiclePhysxActorWakeup(). \note If the steering has changed, the actor will be woken up. \note On exit from PxVehiclePhysxActorWakeup, physxSteerState.previousSteerCommand is assigned to the value of commands.steer so that the steer state may be propagated to the subsequent call to PxVehiclePhysxActorWakeup(). \note If physxSteerState.previousSteerCommand has value PX_VEHICLE_UNSPECIFIED_STEER_STATE, the steering state is treated as though it has not changed. */ void PxVehiclePhysxActorWakeup( const PxVehicleCommandState& commands, const PxVehicleEngineDriveTransmissionCommandState* transmissionCommands, const PxVehicleGearboxParams* gearParams, const PxVehicleGearboxState* gearState, PxRigidBody& physxActor, PxVehiclePhysXSteerState& physxSteerState); /** \brief Check if the physx actor is sleeping and clear certain vehicle states if it is. \param[in] axleDescription identifies the wheels on each axle. \param[in] physxActor is the PxRigidBody instance associated with the vehicle. \param[in] engineParams The engine parameters. Can be set to NULL if the vehicle does not have an engine. Must be specified, if engineState is specified. \param[in,out] rigidBodyState is the state of the rigid body used by the Vehicle SDK. \param[in,out] physxConstraints The state of the suspension limit and low speed tire constraints. If the vehicle actor is sleeping and constraints are active, they will be deactivated and marked as dirty. \param[in,out] wheelRigidBody1dStates describes the angular speed of the wheels. \param[out] engineState The engine state. Can be set to NULL if the vehicle does not have an engine. If specified, then engineParams has to be specifed too. The engine rotation speed will get set to the idle rotation speed if the actor is sleeping. \return True if the actor was sleeping, else false. */ bool PxVehiclePhysxActorSleepCheck (const PxVehicleAxleDescription& axleDescription, const PxRigidBody& physxActor, const PxVehicleEngineParams* engineParams, PxVehicleRigidBodyState& rigidBodyState, PxVehiclePhysXConstraints& physxConstraints, PxVehicleArrayData<PxVehicleWheelRigidBody1dState>& wheelRigidBody1dStates, PxVehicleEngineState* engineState); /** \brief Check if the physx actor has to be kept awake. Certain criteria should keep the vehicle physx actor awake, for example, if the (mass normalized) rotational kinetic energy of the wheels is above a certain threshold or if a gear change is pending or if throttle is applied. This method will reset the wake counter of the physx actor to a specified value, if any of the mentioned criteria are met. \note The physx actor's sleep threshold will be used as threshold to test against for the energy criteria. \param[in] axleDescription identifies the wheels on each axle. \param[in] wheelParams describes the radius, mass etc. of the wheels. \param[in] wheelRigidBody1dStates describes the angular speed of the wheels. \param[in] wakeCounterThreshold Once the wake counter of the physx actor falls below this threshold, the method will start testing if the wake counter needs to be reset. \param[in] wakeCounterResetValue The value to set the physx actor wake counter to, if any of the criteria to do so are met. \param[in] gearState The gear state. Can be set to NULL if the vehicle does not have gears or if the mentioned behavior is not desired. \param[in] throttle The throttle command state (see #PxVehicleCommandState). Can be set to NULL if the vehicle is not controlled through PxVehicleCommandState or if the mentioned behavior is not desired. \param[in] physxActor is the PxRigidBody instance associated with the vehicle. */ void PxVehiclePhysxActorKeepAwakeCheck (const PxVehicleAxleDescription& axleDescription, const PxVehicleArrayData<const PxVehicleWheelParams>& wheelParams, const PxVehicleArrayData<const PxVehicleWheelRigidBody1dState>& wheelRigidBody1dStates, const PxReal wakeCounterThreshold, const PxReal wakeCounterResetValue, const PxVehicleGearboxState* gearState, const PxReal* throttle, PxRigidBody& physxActor); /** \brief Read the rigid body state from a PhysX actor. \param[in] physxActor is a reference to a PhysX actor. \param[out] rigidBodyState is the state of the rigid body used by the Vehicle SDK. */ void PxVehicleReadRigidBodyStateFromPhysXActor (const PxRigidBody& physxActor, PxVehicleRigidBodyState& rigidBodyState); /** \brief Update the local pose of a PxShape that is associated with a wheel. \param[in] wheelLocalPose describes the local pose of each wheel in the rigid body frame. \param[in] wheelShapeLocalPose describes the local pose to apply to the PxShape instance in the wheel's frame. \param[in] shape is the target PxShape. */ void PxVehicleWriteWheelLocalPoseToPhysXWheelShape (const PxTransform& wheelLocalPose, const PxTransform& wheelShapeLocalPose, PxShape* shape); /** \brief Write the rigid body state to a PhysX actor. \param[in] physxActorUpdateMode controls whether the PhysX actor is to be updated with instantaneous velocity changes or with accumulated accelerations to be applied in the next simulation step of the associated PxScene. \param[in] rigidBodyState is the state of the rigid body. \param[in] dt is the simulation time that has elapsed since the last call to PxVehicleWriteRigidBodyStateToPhysXActor(). \param[out] physXActor is a reference to the PhysX actor. */ void PxVehicleWriteRigidBodyStateToPhysXActor (const PxVehiclePhysXActorUpdateMode::Enum physxActorUpdateMode, const PxVehicleRigidBodyState& rigidBodyState, const PxReal dt, PxRigidBody& physXActor); #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
9,175
C
44.88
114
0.795095
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/physxActor/PxVehiclePhysXActorComponents.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "vehicle2/PxVehicleParams.h" #include "vehicle2/PxVehicleComponent.h" #include "vehicle2/wheel/PxVehicleWheelStates.h" #include "PxVehiclePhysXActorFunctions.h" #include "PxVehiclePhysXActorStates.h" #include "common/PxProfileZone.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif /** \brief Work items at the beginning of an update step for a PhysX actor based vehicle. Includes: - Waking the actor up if it is sleeping and a throttle or steer command is issued. - Clearing certain states if the actor is sleeping. - Reading the state from the PhysX actor and copy to the vehicle internal state. @see PxVehiclePhysxActorWakeup PxVehiclePhysxActorSleepCheck PxVehicleReadRigidBodyStateFromPhysXActor */ class PxVehiclePhysXActorBeginComponent : public PxVehicleComponent { public: PxVehiclePhysXActorBeginComponent() : PxVehicleComponent() {} virtual ~PxVehiclePhysXActorBeginComponent() {} /** \brief Provide vehicle data items for this component. \param[out] axleDescription identifies the wheels on each axle. \param[out] commands are the brake, throttle and steer values that will drive the vehicle. \param[out] transmissionCommands are the target gear and clutch values that will control the transmission. Can be set to NULL if the vehicle does not have a gearbox. If specified, then gearParams and gearState has to be specifed too. \param[out] gearParams The gearbox parameters. Can be set to NULL if the vehicle does not have a gearbox and transmissionCommands is NULL. \param[out] gearState The state of the gearbox. Can be set to NULL if the vehicle does not have a gearbox and transmissionCommands is NULL. \param[out] engineParams The engine parameters. Can be set to NULL if the vehicle does not have an engine. Must be specified, if engineState is specified. \param[out] physxActor is the PxRigidBody instance associated with the vehicle. \param[out] physxSteerState is the previous state of the steer and is used to determine if the steering wheel has changed by comparing with PxVehicleCommandState::steer. \param[out] physxConstraints The state of the suspension limit and low speed tire constraints. If the vehicle actor is sleeping and constraints are active, they will be deactivated and marked as dirty. \param[out] rigidBodyState is the state of the rigid body used by the Vehicle SDK. \param[out] wheelRigidBody1dStates describes the angular speed of each wheel. \param[out] engineState The engine state. Can be set to NULL if the vehicle does not have an engine. If specified, then engineParams has to be specifed too. */ virtual void getDataForPhysXActorBeginComponent( const PxVehicleAxleDescription*& axleDescription, const PxVehicleCommandState*& commands, const PxVehicleEngineDriveTransmissionCommandState*& transmissionCommands, const PxVehicleGearboxParams*& gearParams, const PxVehicleGearboxState*& gearState, const PxVehicleEngineParams*& engineParams, PxVehiclePhysXActor*& physxActor, PxVehiclePhysXSteerState*& physxSteerState, PxVehiclePhysXConstraints*& physxConstraints, PxVehicleRigidBodyState*& rigidBodyState, PxVehicleArrayData<PxVehicleWheelRigidBody1dState>& wheelRigidBody1dStates, PxVehicleEngineState*& engineState) = 0; virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context) { PX_UNUSED(dt); PX_UNUSED(context); PX_PROFILE_ZONE("PxVehiclePhysXActorBeginComponent::update", 0); const PxVehicleAxleDescription* axleDescription; const PxVehicleCommandState* commands; const PxVehicleEngineDriveTransmissionCommandState* transmissionCommands; const PxVehicleGearboxParams* gearParams; const PxVehicleGearboxState* gearState; const PxVehicleEngineParams* engineParams; PxVehiclePhysXActor* physxActor; PxVehiclePhysXSteerState* physxSteerState; PxVehiclePhysXConstraints* physxConstraints; PxVehicleRigidBodyState* rigidBodyState; PxVehicleArrayData<PxVehicleWheelRigidBody1dState> wheelRigidBody1dStates; PxVehicleEngineState* engineState; getDataForPhysXActorBeginComponent(axleDescription, commands, transmissionCommands, gearParams, gearState, engineParams, physxActor, physxSteerState, physxConstraints, rigidBodyState, wheelRigidBody1dStates, engineState); if (physxActor->rigidBody->getScene()) // Considering case where actor is not in a scene and constraints get solved via immediate mode { PxVehiclePhysxActorWakeup(*commands, transmissionCommands, gearParams, gearState, *physxActor->rigidBody, *physxSteerState); if (PxVehiclePhysxActorSleepCheck(*axleDescription, *physxActor->rigidBody, engineParams, *rigidBodyState, *physxConstraints, wheelRigidBody1dStates, engineState)) { return false; } } PxVehicleReadRigidBodyStateFromPhysXActor(*physxActor->rigidBody, *rigidBodyState); return true; } }; /** \brief Work items at the end of an update step for a PhysX actor based vehicle. Includes: - Writing vehicle internal state to the PhysX actor. - Keeping the vehicle awake if certain criteria are met. */ class PxVehiclePhysXActorEndComponent : public PxVehicleComponent { public: PxVehiclePhysXActorEndComponent() : PxVehicleComponent() {} virtual ~PxVehiclePhysXActorEndComponent() {} /** \brief Provide vehicle data items for this component. \param[out] axleDescription identifies the wheels on each axle. \param[out] rigidBodyState is the state of the rigid body used by the Vehicle SDK. \param[out] wheelParams describes the radius, mass etc. of the wheels. \param[out] wheelShapeLocalPoses are the local poses in the wheel's frame to apply to the PxShape instances that represent the wheel \param[out] wheelRigidBody1dStates describes the angular speed of the wheels. \param[out] wheelLocalPoses describes the local poses of the wheels in the rigid body frame. \param[out] gearState The gear state. Can be set to NULL if the vehicle does not have gears. \param[out] throttle The throttle command state (see #PxVehicleCommandState). Can be set to NULL if the vehicle is not controlled through PxVehicleCommandState. \param[out] physxActor is the PxRigidBody instance associated with the vehicle. */ virtual void getDataForPhysXActorEndComponent( const PxVehicleAxleDescription*& axleDescription, const PxVehicleRigidBodyState*& rigidBodyState, PxVehicleArrayData<const PxVehicleWheelParams>& wheelParams, PxVehicleArrayData<const PxTransform>& wheelShapeLocalPoses, PxVehicleArrayData<const PxVehicleWheelRigidBody1dState>& wheelRigidBody1dStates, PxVehicleArrayData<const PxVehicleWheelLocalPose>& wheelLocalPoses, const PxVehicleGearboxState*& gearState, const PxReal*& throttle, PxVehiclePhysXActor*& physxActor) = 0; virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context) { PX_UNUSED(dt); PX_PROFILE_ZONE("PxVehiclePhysXActorEndComponent::update", 0); const PxVehicleAxleDescription* axleDescription; const PxVehicleRigidBodyState* rigidBodyState; PxVehicleArrayData<const PxVehicleWheelParams> wheelParams; PxVehicleArrayData<const PxTransform> wheelShapeLocalPoses; PxVehicleArrayData<const PxVehicleWheelRigidBody1dState> wheelRigidBody1dStates; PxVehicleArrayData<const PxVehicleWheelLocalPose> wheelLocalPoses; const PxVehicleGearboxState* gearState; const PxReal* throttle; PxVehiclePhysXActor* physxActor; getDataForPhysXActorEndComponent(axleDescription, rigidBodyState, wheelParams, wheelShapeLocalPoses, wheelRigidBody1dStates, wheelLocalPoses, gearState, throttle, physxActor); for (PxU32 i = 0; i < axleDescription->nbWheels; i++) { const PxU32 wheelId = axleDescription->wheelIdsInAxleOrder[i]; PxVehicleWriteWheelLocalPoseToPhysXWheelShape(wheelLocalPoses[wheelId].localPose, wheelShapeLocalPoses[wheelId], physxActor->wheelShapes[wheelId]); } if (context.getType() == PxVehicleSimulationContextType::ePHYSX) { const PxVehiclePhysXSimulationContext& physxContext = static_cast<const PxVehiclePhysXSimulationContext&>(context); PxVehicleWriteRigidBodyStateToPhysXActor(physxContext.physxActorUpdateMode, *rigidBodyState, dt, *physxActor->rigidBody); PxVehiclePhysxActorKeepAwakeCheck(*axleDescription, wheelParams, wheelRigidBody1dStates, physxContext.physxActorWakeCounterThreshold, physxContext.physxActorWakeCounterResetValue, gearState, throttle, *physxActor->rigidBody); } else { PX_ALWAYS_ASSERT(); } return true; } }; #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
10,366
C
41.487705
137
0.791434
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/rigidBody/PxVehicleRigidBodyStates.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "foundation/PxTransform.h" #include "foundation/PxVec3.h" #include "vehicle2/PxVehicleParams.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif struct PxVehicleRigidBodyState { PxTransform pose; //!< the body's pose (in world space) PxVec3 linearVelocity; //!< the body's linear velocity (in world space) PxVec3 angularVelocity; //!< the body's angular velocity (in world space) PxVec3 previousLinearVelocity; //!< the previous linear velocity of the body (in world space) PxVec3 previousAngularVelocity; //!< the previous angular velocity of the body (in world space) PxVec3 externalForce; //!< external force (in world space) affecting the rigid body (usually excluding gravitational force) PxVec3 externalTorque; //!< external torque (in world space) affecting the rigid body PX_FORCE_INLINE void setToDefault() { pose = PxTransform(PxIdentity); linearVelocity = PxVec3(PxZero); angularVelocity = PxVec3(PxZero); externalForce = PxVec3(PxZero); externalTorque = PxVec3(PxZero); } /** \brief Compute the vertical speed of the rigid body transformed to the world frame. \param[in] frame describes the axes of the vehicle */ PX_FORCE_INLINE PxReal getVerticalSpeed(const PxVehicleFrame& frame) const { return linearVelocity.dot(pose.q.rotate(frame.getVrtAxis())); } /** \param[in] frame describes the axes of the vehicle \brief Compute the lateral speed of the rigid body transformed to the world frame. */ PX_FORCE_INLINE PxReal getLateralSpeed(const PxVehicleFrame& frame) const { return linearVelocity.dot(pose.q.rotate(frame.getLatAxis())); } /** \brief Compute the longitudinal speed of the rigid body transformed to the world frame. \param[in] frame describes the axes of the vehicle */ PX_FORCE_INLINE PxReal getLongitudinalSpeed(const PxVehicleFrame& frame) const { return linearVelocity.dot(pose.q.rotate(frame.getLngAxis())); } }; #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
3,754
C
36.929293
126
0.75333
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/rigidBody/PxVehicleRigidBodyComponents.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "vehicle2/PxVehicleParams.h" #include "vehicle2/PxVehicleComponent.h" #include "PxVehicleRigidBodyFunctions.h" #include "common/PxProfileZone.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif /** \brief Forward integrate the momentum and pose of the vehicle's rigid body after applying forces and torques from the suspension, tires and anti-roll bars. */ class PxVehicleRigidBodyComponent : public PxVehicleComponent { public: PxVehicleRigidBodyComponent() : PxVehicleComponent() {} virtual ~PxVehicleRigidBodyComponent() {} /** \brief Retrieve pointers to the parameter and state data required to update the dynamic state of a rigid body. \param[out] axleDescription must be returned as a non-null pointer to a single PxVehicleAxleDescription instance that describes the wheels and axles of the vehicle. \param[out] rigidBodyParams must be returned as a non-null pointer to a single PxVehicleRigidBodyParams instance that describes the mass and moment of inertia of the rigid body. \param[out] suspensionForces must be returned as a non-null pointer to an array of suspension forces and torques in the world frame. The suspension forces and torques will be applied to the rigid body to update *rigidBodyState*. \param[out] tireForces must be returned as a non-null pointer to an array of tire forces and torques in the world frame. The tire forces and torques will be applied to the rigid body to update *rigidBodyState*. \param[out] antiRollTorque may be returned an optionally non-null pointer to a single PxVehicleAntiRollTorque instance that contains the accumulated anti-roll torque to apply to the rigid body. \param[out] rigidBodyState imust be returned as a non-null pointer to a single PxVehicleRigidBodyState instance that is to be forward integrated. \note The suspensionForces array must contain an entry for each wheel listed as an active wheel in axleDescription. \note The tireForces array must contain an entry for each wheel listed as an active wheel in axleDescription. \note If antiRollTorque is returned as a null pointer then zero anti-roll torque will be applied to the rigid body. */ virtual void getDataForRigidBodyComponent( const PxVehicleAxleDescription*& axleDescription, const PxVehicleRigidBodyParams*& rigidBodyParams, PxVehicleArrayData<const PxVehicleSuspensionForce>& suspensionForces, PxVehicleArrayData<const PxVehicleTireForce>& tireForces, const PxVehicleAntiRollTorque*& antiRollTorque, PxVehicleRigidBodyState*& rigidBodyState) = 0; virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context) { PX_PROFILE_ZONE("PxVehicleRigidBodyComponent::update", 0); const PxVehicleAxleDescription* axleDescription; const PxVehicleRigidBodyParams* rigidBodyParams; PxVehicleArrayData<const PxVehicleSuspensionForce> suspensionForces; PxVehicleArrayData<const PxVehicleTireForce> tireForces; const PxVehicleAntiRollTorque* antiRollTorque; PxVehicleRigidBodyState* rigidBodyState; getDataForRigidBodyComponent(axleDescription, rigidBodyParams, suspensionForces, tireForces, antiRollTorque, rigidBodyState); PxVehicleRigidBodyUpdate( *axleDescription, *rigidBodyParams, suspensionForces, tireForces, antiRollTorque, dt, context.gravity, *rigidBodyState); return true; } }; #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
5,162
C
43.895652
159
0.78826
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/rigidBody/PxVehicleRigidBodyFunctions.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "foundation/PxVec3.h" #include "foundation/PxSimpleTypes.h" #include "vehicle2/PxVehicleParams.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif struct PxVehicleRigidBodyParams; struct PxVehicleSuspensionForce; struct PxVehicleTireForce; struct PxVehicleAntiRollTorque; struct PxVehicleRigidBodyState; /** \brief Forward integrate rigid body state. \param[in] axleDescription is a description of the axles of the vehicle and the wheels on each axle. \param[in] rigidBodyParams is a description of rigid body mass and moment of inertia. \param[in] suspensionForces is an array of suspension forces and torques in the world frame to be applied to the rigid body. \param[in] tireForces is an array of tire forces and torques in the world frame to be applied to the rigid body. \param[in] antiRollTorque is an optional pointer to a single PxVehicleAntiRollTorque instance that contains the accumulated anti-roll torque to apply to the rigid body. \param[in] dt is the timestep of the forward integration. \param[in] gravity is gravitational acceleration. \param[in,out] rigidBodyState is the rigid body state that is to be updated. \note The suspensionForces array must contain an entry for each wheel listed as an active wheel in axleDescription. \note The tireForces array must contain an entry for each wheel listed as an active wheel in axleDescription. \note If antiRollTorque is a null pointer then zero anti-roll torque will be applied to the rigid body. */ void PxVehicleRigidBodyUpdate (const PxVehicleAxleDescription& axleDescription, const PxVehicleRigidBodyParams& rigidBodyParams, const PxVehicleArrayData<const PxVehicleSuspensionForce>& suspensionForces, const PxVehicleArrayData<const PxVehicleTireForce>& tireForces, const PxVehicleAntiRollTorque* antiRollTorque, const PxReal dt, const PxVec3& gravity, PxVehicleRigidBodyState& rigidBodyState); #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
3,720
C
44.938271
133
0.787366
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/braking/PxVehicleBrakingFunctions.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "foundation/PxPreprocessor.h" #include "foundation/PxMath.h" #include "PxVehicleBrakingParams.h" #include "../commands/PxVehicleCommandStates.h" #include "../commands/PxVehicleCommandHelpers.h" #include "../drivetrain/PxVehicleDrivetrainParams.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif /** \brief Compute the brake torque response to an array of brake commands. \param[in] brakeCommands is the array of input brake commands to be applied to the vehicle. \param[in] nbBrakeCommands is the number of input brake commands to be applied to the vehicle. \param[in] longitudinalSpeed is the longitudinal speed of the vehicle. \param[in] wheelId specifies the wheel that is to have its brake response computed. \param[in] brakeResponseParams specifies the per wheel brake torque response to each brake command as a nonlinear function of brake command and longitudinal speed. \param[out] brakeResponseState is the brake torque response to the input brake command. \note commands.brakes[i] and brakeResponseParams[i] are treated as pairs of brake command and brake command response. */ PX_FORCE_INLINE void PxVehicleBrakeCommandResponseUpdate (const PxReal* brakeCommands, const PxU32 nbBrakeCommands, const PxReal longitudinalSpeed, const PxU32 wheelId, const PxVehicleSizedArrayData<const PxVehicleBrakeCommandResponseParams>& brakeResponseParams, PxReal& brakeResponseState) { PX_CHECK_AND_RETURN(nbBrakeCommands <= brakeResponseParams.size, "PxVehicleBrakeCommandLinearUpdate: nbBrakes must be less than or equal to brakeResponseParams.size"); PxReal sum = 0.0f; for (PxU32 i = 0; i < nbBrakeCommands; i++) { sum += PxVehicleNonLinearResponseCompute(brakeCommands[i], longitudinalSpeed, wheelId, brakeResponseParams[i]); } brakeResponseState = sum; } #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
3,618
C
44.237499
168
0.778883
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/wheel/PxVehicleWheelFunctions.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "foundation/PxSimpleTypes.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif struct PxVehicleWheelParams; struct PxVehicleWheelActuationState; struct PxVehicleSuspensionState; struct PxVehicleTireSpeedState; struct PxVehicleScale; struct PxVehicleWheelRigidBody1dState; /** \brief Forward integrate the rotation angle of a wheel \note The rotation angle of the wheel plays no role in simulation but is important to compute the pose of the wheel for rendering. \param[in] wheelParams describes the radius and half-width of the wheel \param[in] actuationState describes whether the wheel has drive or brake torque applied to it. \param[in] suspensionState describes whether the wheel touches the ground. \param[in] tireSpeedState describes the components of rigid body velocity at the ground contact point along the tire's lateral and longitudinal directions. \param[in] thresholdForwardSpeedForWheelAngleIntegration Forward wheel speed below which the wheel rotation speed gets blended with the rolling speed (based on the forward wheel speed) which is then used to integrate the wheel rotation angle. At low forward wheel speed, the wheel rotation speed can get unstable (depending on the tire model used) and, for example, oscillate. If brake or throttle is applied, there will be no blending. \param[in] dt is the simulation time that has lapsed since the last call to PxVehicleWheelRotationAngleUpdate \param[in,out] wheelRigidBody1dState describes the current angular speed and angle of the wheel. \note At low speeds and large timesteps, wheel rotation speed can become noisy due to singularities in the tire slip computations. At low speeds, therefore, the wheel speed used for integrating the angle is a blend of current angular speed and rolling angular speed if the wheel experiences neither brake nor drive torque and can be placed on the ground. The blended rotation speed gets stored in PxVehicleWheelRigidBody1dState::correctedRotationSpeed. */ void PxVehicleWheelRotationAngleUpdate (const PxVehicleWheelParams& wheelParams, const PxVehicleWheelActuationState& actuationState, const PxVehicleSuspensionState& suspensionState, const PxVehicleTireSpeedState& tireSpeedState, const PxReal thresholdForwardSpeedForWheelAngleIntegration, const PxReal dt, PxVehicleWheelRigidBody1dState& wheelRigidBody1dState); #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
4,201
C
50.243902
155
0.794335
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/wheel/PxVehicleWheelStates.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "foundation/PxSimpleTypes.h" #include "foundation/PxTransform.h" #include "foundation/PxMemory.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif /** \brief It is useful to know if a brake or drive torque is to be applied to a wheel. */ struct PxVehicleWheelActuationState { bool isBrakeApplied; //!< True if a brake torque is applied, false if not. bool isDriveApplied; //!< True if a drive torque is applied, false if not. PX_FORCE_INLINE void setToDefault() { PxMemZero(this, sizeof(PxVehicleWheelActuationState)); } }; struct PxVehicleWheelRigidBody1dState { /** \brief The rotation speed of the wheel around the lateral axis. <b>Unit:</b> radians / time */ PxReal rotationSpeed; /** \brief The corrected rotation speed of the wheel around the lateral axis in radians per second. At low forward wheel speed, the wheel rotation speed can get unstable (depending on the tire model used) and, for example, oscillate. To integrate the wheel rotation angle, a (potentially) blended rotation speed is used which gets stored in #correctedRotationSpeed. <b>Unit:</b> radians / time @see PxVehicleSimulationContext::thresholdForwardSpeedForWheelAngleIntegration */ PxReal correctedRotationSpeed; /** \brief The accumulated angle of the wheel around the lateral axis in radians in range (-2*Pi,2*Pi) */ PxReal rotationAngle; PX_FORCE_INLINE void setToDefault() { PxMemZero(this, sizeof(PxVehicleWheelRigidBody1dState)); } }; struct PxVehicleWheelLocalPose { PxTransform localPose; //!< The pose of the wheel in the rigid body frame. PX_FORCE_INLINE void setToDefault() { localPose = PxTransform(PxIdentity); } }; #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
3,511
C
31.220183
99
0.753062
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/wheel/PxVehicleWheelParams.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "foundation/PxFoundation.h" #include "vehicle2/PxVehicleParams.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif struct PxVehicleWheelParams { /** \brief Radius of unit that includes metal wheel plus rubber tire. <b>Range:</b> (0, inf)<br> <b>Unit:</b> length */ PxReal radius; /** \brief Half-width of unit that includes wheel plus tire. <b>Range:</b> (0, inf)<br> <b>Unit:</b> length */ PxReal halfWidth; /** \brief Mass of unit that includes wheel plus tire. <b>Range:</b> (0, inf)<br> <b>Unit:</b> mass */ PxReal mass; /** \brief Moment of inertia of unit that includes wheel plus tire about the rolling axis. <b>Range:</b> (0, inf)<br> <b>Unit:</b> mass * (length^2) */ PxReal moi; /** \brief Damping rate applied to wheel. <b>Range:</b> [0, inf)<br> <b>Unit:</b> torque * time = mass * (length^2) / time */ PxReal dampingRate; PX_FORCE_INLINE PxVehicleWheelParams transformAndScale( const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const { PX_UNUSED(srcFrame); PX_UNUSED(trgFrame); PxVehicleWheelParams r = *this; const PxReal scale = trgScale.scale/srcScale.scale; r.radius *= scale; r.halfWidth *= scale; r.moi *= (scale*scale); r.dampingRate *= (scale*scale); return r; } PX_FORCE_INLINE bool isValid() const { PX_CHECK_AND_RETURN_VAL(radius > 0.0f, "PxVehicleWheelParams.radius must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(halfWidth > 0.0f, "PxVehicleWheelParams.halfWidth must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(mass > 0.0f, "PxVehicleWheelParams.mass must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(moi > 0.0f, "PxVehicleWheelParams.moi must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(dampingRate >= 0.0f, "PxVehicleWheelParams.dampingRate must be greater than or equal to zero", false); return true; } }; #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
3,789
C
30.583333
135
0.724202
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/wheel/PxVehicleWheelComponents.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "vehicle2/PxVehicleParams.h" #include "vehicle2/PxVehicleComponent.h" #include "vehicle2/commands/PxVehicleCommandHelpers.h" #include "vehicle2/tire/PxVehicleTireStates.h" #include "PxVehicleWheelFunctions.h" #include "PxVehicleWheelHelpers.h" #include "common/PxProfileZone.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif class PxVehicleWheelComponent : public PxVehicleComponent { public: PxVehicleWheelComponent() : PxVehicleComponent() {} virtual ~PxVehicleWheelComponent() {} virtual void getDataForWheelComponent( const PxVehicleAxleDescription*& axleDescription, PxVehicleArrayData<const PxReal>& steerResponseStates, PxVehicleArrayData<const PxVehicleWheelParams>& wheelParams, PxVehicleArrayData<const PxVehicleSuspensionParams>& suspensionParams, PxVehicleArrayData<const PxVehicleWheelActuationState>& actuationStates, PxVehicleArrayData<const PxVehicleSuspensionState>& suspensionStates, PxVehicleArrayData<const PxVehicleSuspensionComplianceState>& suspensionComplianceStates, PxVehicleArrayData<const PxVehicleTireSpeedState>& tireSpeedStates, PxVehicleArrayData<PxVehicleWheelRigidBody1dState>& wheelRigidBody1dStates, PxVehicleArrayData<PxVehicleWheelLocalPose>& wheelLocalPoses) = 0; virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context) { PX_PROFILE_ZONE("PxVehicleWheelComponent::update", 0); const PxVehicleAxleDescription* axleDescription; PxVehicleArrayData<const PxReal> steerResponseStates; PxVehicleArrayData<const PxVehicleWheelParams> wheelParams; PxVehicleArrayData<const PxVehicleSuspensionParams> suspensionParams; PxVehicleArrayData<const PxVehicleWheelActuationState> actuationStates; PxVehicleArrayData<const PxVehicleSuspensionState> suspensionStates; PxVehicleArrayData<const PxVehicleSuspensionComplianceState> suspensionComplianceStates; PxVehicleArrayData<const PxVehicleTireSpeedState> tireSpeedStates; PxVehicleArrayData<PxVehicleWheelRigidBody1dState> wheelRigidBody1dStates; PxVehicleArrayData<PxVehicleWheelLocalPose> wheelLocalPoses; getDataForWheelComponent(axleDescription, steerResponseStates, wheelParams, suspensionParams, actuationStates, suspensionStates, suspensionComplianceStates, tireSpeedStates, wheelRigidBody1dStates, wheelLocalPoses); for (PxU32 i = 0; i < axleDescription->nbWheels; i++) { const PxU32 wheelId = axleDescription->wheelIdsInAxleOrder[i]; PxVehicleWheelRotationAngleUpdate( wheelParams[wheelId], actuationStates[wheelId], suspensionStates[wheelId], tireSpeedStates[wheelId], context.thresholdForwardSpeedForWheelAngleIntegration, dt, wheelRigidBody1dStates[wheelId]); wheelLocalPoses[wheelId].localPose = PxVehicleComputeWheelLocalPose(context.frame, suspensionParams[wheelId], suspensionStates[wheelId], suspensionComplianceStates[wheelId], steerResponseStates[wheelId], wheelRigidBody1dStates[wheelId]); } return true; } }; #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
4,819
C
38.83471
91
0.799751
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/wheel/PxVehicleWheelHelpers.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "vehicle2/PxVehicleFunctions.h" #include "vehicle2/suspension/PxVehicleSuspensionParams.h" #include "vehicle2/suspension/PxVehicleSuspensionStates.h" #include "PxVehicleWheelParams.h" #include "PxVehicleWheelStates.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif /** \brief Compute the quaternion of a wheel in the rigid body frame. \param[in] frame describes the longitudinal and lateral axes of the vehicle. \param[in] suspensionParams describes the suspension and wheel frames. \param[in] camberAngle is the camber angle in radian sinduced by suspension compliance. \param[in] toeAngle is the toe angle in radians induced by suspension compliance. \param[in] steerAngle is the steer angle in radians applied to the wheel. \param[in] rotationAngle is the angle around the wheel's lateral axis. \return The quaterion of the wheel in the rigid body frame. @see PxVehicleComputeWheelOrientation */ PX_FORCE_INLINE PxQuat PxVehicleComputeWheelLocalOrientation (const PxVehicleFrame& frame, const PxVehicleSuspensionParams& suspensionParams, const PxReal camberAngle, const PxReal toeAngle, const PxReal steerAngle, const PxReal rotationAngle) { const PxQuat wheelLocalOrientation = (suspensionParams.suspensionAttachment.q * PxVehicleComputeRotation(frame, camberAngle, 0.0f, steerAngle + toeAngle))* (suspensionParams.wheelAttachment.q * PxVehicleComputeRotation(frame, 0.0f, rotationAngle, 0.0f)); return wheelLocalOrientation; } /** \brief Compute the quaternion of a wheel in the world frame. \param[in] frame describes the longitudinal and lateral axes of the vehicle. \param[in] suspensionParams describes the suspension and wheel frames. \param[in] camberAngle is the camber angle in radian induced by suspension compliance. \param[in] toeAngle is the toe angle in radians induced by suspension compliance. \param[in] steerAngle is the steer angle in radians applied to the wheel. \param[in] rigidBodyOrientation is the quaterion of the rigid body in the world frame. \param[in] rotationAngle is the angle around the wheel's lateral axis. \return The quaterion of the wheel in the world frame. @see PxVehicleComputeWheelLocalOrientation */ PX_FORCE_INLINE PxQuat PxVehicleComputeWheelOrientation (const PxVehicleFrame& frame, const PxVehicleSuspensionParams& suspensionParams, const PxReal camberAngle, const PxReal toeAngle, const PxReal steerAngle, const PxQuat& rigidBodyOrientation, const PxReal rotationAngle) { const PxQuat wheelOrientation = rigidBodyOrientation * PxVehicleComputeWheelLocalOrientation(frame, suspensionParams, camberAngle, toeAngle, steerAngle, rotationAngle); return wheelOrientation; } /** \brief Compute the pose of the wheel in the rigid body frame. \param[in] frame describes the longitudinal and lateral axes of the vehicle. \param[in] suspensionParams describes the suspension and wheel frames. \param[in] suspensionState is the compression state of the suspenson. \param[in] camberAngle is the camber angle in radian induced by suspension compliance. \param[in] toeAngle is the toe angle in radians induced by suspension compliance. \param[in] steerAngle is the steer angle in radians applied to the wheel. \param[in] rotationAngle is the angle around the wheel's lateral axis. \return The pose of the wheel in the rigid body frame. */ PX_FORCE_INLINE PxTransform PxVehicleComputeWheelLocalPose (const PxVehicleFrame& frame, const PxVehicleSuspensionParams& suspensionParams, const PxVehicleSuspensionState& suspensionState, const PxReal camberAngle, const PxReal toeAngle, const PxReal steerAngle, const PxReal rotationAngle) { //Full equation: //PxTransform(suspAttachment.p + suspParams.suspensionTravelDir*suspDist, suspAttachment.q) * //PxTransform(PxVec3(0), PxQuat(camber, 0, steer+toe)) * //wheelAttachment * //PxTransform(PxVec3(0), PxQuat(0, rotation, 0)) //Reduces to: //PxTransform(suspAttachment.p + suspParams.suspensionTravelDir*suspDist, suspAttachment.q * PxQuat(camber, 0, steer+toe)) * //PxTranfsorm(wheelAttachment.p, wheelAttachment.q * PxQuat(0, rotation, 0)) const PxF32 suspDist = (suspensionState.jounce != PX_VEHICLE_UNSPECIFIED_JOUNCE) ? (suspensionParams.suspensionTravelDist - suspensionState.jounce) : 0.0f; const PxTransform wheelLocalPose = PxTransform( suspensionParams.suspensionAttachment.p + suspensionParams.suspensionTravelDir*suspDist, suspensionParams.suspensionAttachment.q*PxVehicleComputeRotation(frame, camberAngle, 0.0f, steerAngle + toeAngle))* PxTransform( suspensionParams.wheelAttachment.p, suspensionParams.wheelAttachment.q*PxVehicleComputeRotation(frame, 0.0f, rotationAngle, 0.0f)); return wheelLocalPose; } /** \brief Compute the pose of the wheel in the rigid body frame. \param[in] frame describes the longitudinal and lateral axes of the vehicle. \param[in] suspensionParams describes the suspension and wheel frames. \param[in] suspensionState is the compression state of the suspenson. \param[in] suspensionComplianceState is the camber and toe angles induced by suspension compliance. \param[in] steerAngle is the steer angle in radians applied to the wheel. \param[in] wheelState is angle around the wheel's lateral axis. \return The pose of the wheel in the rigid body frame. */ PX_FORCE_INLINE PxTransform PxVehicleComputeWheelLocalPose (const PxVehicleFrame& frame, const PxVehicleSuspensionParams& suspensionParams, const PxVehicleSuspensionState& suspensionState, const PxVehicleSuspensionComplianceState& suspensionComplianceState, const PxReal steerAngle, const PxVehicleWheelRigidBody1dState& wheelState) { return PxVehicleComputeWheelLocalPose(frame, suspensionParams, suspensionState, suspensionComplianceState.camber, suspensionComplianceState.toe, steerAngle, wheelState.rotationAngle); } /** \brief Compute the pose of the wheel in the world frame. \param[in] frame describes the longitudinal and lateral axes of the vehicle. \param[in] suspensionParams describes the suspension and wheel frames. \param[in] suspensionState is the compression state of the suspenson. \param[in] camberAngle is the camber angle in radian induced by suspension compliance. \param[in] toeAngle is the toe angle in radians induced by suspension compliance. \param[in] steerAngle is the steer angle in radians applied to the wheel. \param[in] rigidBodyPose is the pose of the rigid body in the world frame. \param[in] rotationAngle is the angle around the wheel's lateral axis. \return The pose of the wheel in the world frame. */ PX_FORCE_INLINE PxTransform PxVehicleComputeWheelPose (const PxVehicleFrame& frame, const PxVehicleSuspensionParams& suspensionParams, const PxVehicleSuspensionState& suspensionState, const PxReal camberAngle, const PxReal toeAngle, const PxReal steerAngle, const PxTransform& rigidBodyPose, const PxReal rotationAngle) { const PxTransform wheelPose = rigidBodyPose * PxVehicleComputeWheelLocalPose(frame, suspensionParams, suspensionState, camberAngle, toeAngle, steerAngle, rotationAngle); return wheelPose; } /** \brief Compute the pose of the wheel in the world frame. \param[in] frame describes the longitudinal and lateral axes of the vehicle. \param[in] suspensionParams describes the suspension and wheel frames. \param[in] suspensionState is the compression state of the suspenson. \param[in] suspensionComplianceState is the camber and toe angles induced by suspension compliance. \param[in] steerAngle is the steer angle in radians applied to the wheel. \param[in] rigidBodyPose is the pose of the rigid body in the world frame. \param[in] wheelState is angle around the wheel's lateral axis. \return The pose of the wheel in the world frame. */ PX_FORCE_INLINE PxTransform PxVehicleComputeWheelPose (const PxVehicleFrame& frame, const PxVehicleSuspensionParams& suspensionParams, const PxVehicleSuspensionState& suspensionState, const PxVehicleSuspensionComplianceState& suspensionComplianceState, const PxReal steerAngle, const PxTransform& rigidBodyPose, const PxVehicleWheelRigidBody1dState& wheelState) { return PxVehicleComputeWheelPose(frame, suspensionParams, suspensionState, suspensionComplianceState.camber, suspensionComplianceState.toe, steerAngle, rigidBodyPose, wheelState.rotationAngle); } /** \brief Check if the suspension could place the wheel on the ground or not. \param[in] suspState The state of the suspension to check. \return True if the wheel connects to the ground, else false. @see PxVehicleSuspensionState */ PX_FORCE_INLINE bool PxVehicleIsWheelOnGround(const PxVehicleSuspensionState& suspState) { return (suspState.separation <= 0.0f); } #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
10,451
C
46.081081
156
0.80155
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/suspension/PxVehicleSuspensionHelpers.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "foundation/PxTransform.h" #include "vehicle2/wheel/PxVehicleWheelParams.h" #include "vehicle2/wheel/PxVehicleWheelHelpers.h" #include "PxVehicleSuspensionParams.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif /** \brief Compute suspension travel direction in the world frame. \param[in] suspensionParams is a description of the suspension frame. \param[in] rigidBodyPose is the current pose of the vehicle's rigid body. \return The return value is the suspension travel direction in the world frame. \note The suspension travel direction is used to perform queries against the road geometry. */ PX_FORCE_INLINE PxVec3 PxVehicleComputeSuspensionDirection(const PxVehicleSuspensionParams& suspensionParams, const PxTransform& rigidBodyPose) { const PxVec3 suspDir = rigidBodyPose.rotate(suspensionParams.suspensionTravelDir); return suspDir; } /** \brief Compute the start pose of a suspension query. \param[in] frame is a description of the longitudinal, lateral and vertical axes. \param[in] suspensionParams is a description of the suspension frame. \param[in] steerAngle is the yaw angle of the wheel in radians. \param[in] rigidBodyPose is the pose of the rigid body in the world frame. */ PX_FORCE_INLINE PxTransform PxVehicleComputeWheelPoseForSuspensionQuery(const PxVehicleFrame& frame, const PxVehicleSuspensionParams& suspensionParams, const PxReal steerAngle, const PxTransform& rigidBodyPose) { //Compute the wheel pose with zero travel from attachment point, zero compliance, //zero wheel pitch (ignore due to radial symmetry). //Zero travel from attachment point (we want the wheel pose at the top of the suspension, i.e., at max compression) PxVehicleSuspensionState suspState; suspState.setToDefault(); //Compute the wheel pose. const PxTransform wheelPose = PxVehicleComputeWheelPose(frame, suspensionParams, suspState, 0.0f, 0.0f, steerAngle, rigidBodyPose, 0.0f); return wheelPose; } /** \brief Compute the start point, direction and length of a suspension scene raycast. \param[in] frame is a description of the longitudinal, lateral and vertical axes. \param[in] wheelParams describes the radius and halfwidth of the wheel. \param[in] suspensionParams describes the suspension frame and the maximum suspension travel. \param[in] steerAngle is the yaw angle of the wheel in radians. \param[in] rigidBodyPose is the pose of the rigid body in the world frame. \param[out] start is the starting point of the raycast in the world frame. \param[out] dir is the direction of the raycast in the world frame. \param[out] dist is the length of the raycast. \note start, dir and dist together describe a raycast that begins at the top of wheel at maximum compression and ends at the bottom of wheel at maximum droop. */ PX_FORCE_INLINE void PxVehicleComputeSuspensionRaycast (const PxVehicleFrame& frame, const PxVehicleWheelParams& wheelParams, const PxVehicleSuspensionParams& suspensionParams, const PxF32 steerAngle, const PxTransform& rigidBodyPose, PxVec3& start, PxVec3& dir, PxReal& dist) { const PxTransform wheelPose = PxVehicleComputeWheelPoseForSuspensionQuery(frame, suspensionParams, steerAngle, rigidBodyPose); //Raycast from top of wheel at max compression to bottom of wheel at max droop. dir = PxVehicleComputeSuspensionDirection(suspensionParams, rigidBodyPose); start = wheelPose.p - dir * wheelParams.radius; dist = suspensionParams.suspensionTravelDist + 2.0f*wheelParams.radius; } /** \brief Compute the start pose, direction and length of a suspension scene sweep. \param[in] frame is a description of the longitudinal, lateral and vertical axes. \param[in] suspensionParams describes the suspension frame and the maximum suspension travel. \param[in] steerAngle is the yaw angle of the wheel in radians. \param[in] rigidBodyPose is the pose of the rigid body in the world frame. \param[out] start is the start pose of the sweep in the world frame. \param[out] dir is the direction of the sweep in the world frame. \param[out] dist is the length of the sweep. \note start, dir and dist together describe a sweep that begins with the wheel placed at maximum compression and ends at the maximum droop pose. */ PX_FORCE_INLINE void PxVehicleComputeSuspensionSweep (const PxVehicleFrame& frame, const PxVehicleSuspensionParams& suspensionParams, const PxReal steerAngle, const PxTransform& rigidBodyPose, PxTransform& start, PxVec3& dir, PxReal& dist) { start = PxVehicleComputeWheelPoseForSuspensionQuery(frame, suspensionParams, steerAngle, rigidBodyPose); dir = PxVehicleComputeSuspensionDirection(suspensionParams, rigidBodyPose); dist = suspensionParams.suspensionTravelDist; } /** \brief Compute the sprung masses of the suspension springs given (i) the number of sprung masses, (ii) coordinates of the sprung masses in the rigid body frame, (iii) the center of mass offset of the rigid body, (iv) the total mass of the rigid body, and (v) the direction of gravity \param[in] nbSprungMasses is the number of sprung masses of the vehicle. This value corresponds to the number of wheels on the vehicle. \param[in] sprungMassCoordinates are the coordinates of the sprung masses in the rigid body frame. The array sprungMassCoordinates must be of length nbSprungMasses or greater. \param[in] totalMass is the total mass of all the sprung masses. \param[in] gravityDirection describes the direction of gravitational acceleration. \param[out] sprungMasses are the masses to set in the associated suspension data with PxVehicleSuspensionData::mSprungMass. The sprungMasses array must be of length nbSprungMasses or greater. Each element in the sprungMasses array corresponds to the suspension located at the same array element in sprungMassCoordinates. The center of mass of the masses in sprungMasses with the coordinates in sprungMassCoordinates satisfy the specified centerOfMass. \return True if the sprung masses were successfully computed, false if the sprung masses were not successfully computed. */ bool PxVehicleComputeSprungMasses(const PxU32 nbSprungMasses, const PxVec3* sprungMassCoordinates, const PxReal totalMass, const PxVehicleAxes::Enum gravityDirection, PxReal* sprungMasses); #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
8,021
C
50.754838
189
0.794539
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/suspension/PxVehicleSuspensionComponents.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "vehicle2/PxVehicleParams.h" #include "vehicle2/PxVehicleComponent.h" #include "vehicle2/commands/PxVehicleCommandStates.h" #include "vehicle2/commands/PxVehicleCommandHelpers.h" #include "vehicle2/rigidBody/PxVehicleRigidBodyParams.h" #include "vehicle2/roadGeometry/PxVehicleRoadGeometryState.h" #include "vehicle2/wheel/PxVehicleWheelParams.h" #include "PxVehicleSuspensionParams.h" #include "PxVehicleSuspensionStates.h" #include "PxVehicleSuspensionFunctions.h" #include "common/PxProfileZone.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif class PxVehicleSuspensionComponent : public PxVehicleComponent { public: PxVehicleSuspensionComponent() : PxVehicleComponent() {} virtual ~PxVehicleSuspensionComponent() {} /** \brief Retrieve pointers to the parameter and state data required to compute the suspension state and the forces/torques that arise from the suspension state. \param[out] axleDescription must be returned as a non-null pointer to a single PxVehicleAxleDescription instance that describes the wheels and axles of the vehicle. \param[out] rigidBodyParams must be returned as a a non-null pointer to a single PxVehicleRigidBodyParams instance that describes the mass and moment of inertia of the vehicle's rigid body. \param[out] suspensionStateCalculationParams must be returned as a non-null pointer to a single PxVehicleSuspensionStateCalculationParams instance that describes the jounce computation type etc. \param[out] steerResponseStates must be returned as a non-null pointer to a single PxVehicleSteerCommandResponseStates instance that describes the steer state of the wheels. \param[out] rigidBodyState must be returned as a non-null pointer to a single PxVehicleRigidBodyState instance that describes the pose and momentum of the vehicle's rigid body. \param[out] wheelParams must be set to a non-null pointer to an array of PxVehicleWheelParams containing per-wheel parameters for each wheel referenced by axleDescription. \param[out] suspensionParams must be set to a non-null pointer to an array of PxVehicleSuspensionParams containing per-wheel parameters for each wheel referenced by axleDescription. \param[out] suspensionComplianceParams must be set to a non-null pointer to an array of PxVehicleSuspensionComplianceParams containing per-wheel parameters for each wheel referenced by axleDescription. \param[out] suspensionForceParams must be set to a non-null pointer to an array of PxVehicleSuspensionForceParams containing per-wheel parameters for each wheel referenced by axleDescription. \param[out] antiRollForceParams is optionally returned as a non-null pointer to an array of PxVehicleAntiRollForceParams with each element in the array describing a unique anti-roll bar connecting a pair of wheels. \param[out] wheelRoadGeomStates must be set to non-null pointer to an array of PxVehicleRoadGeometryState containing per-wheel road geometry for each wheel referenced by axleDescription. \param[out] suspensionStates must be set to a non-null pointer to an array of PxVehicleSuspensionState containing per-wheel suspension state for each wheel referenced by axleDescription. \param[out] suspensionComplianceStates must be set to a non-null pointer to an array of PxVehicleSuspensionComplianceState containing per-wheel suspension compliance state for each wheel referenced by axleDescription. \param[out] suspensionForces must be set to a non-null pointer to an array of PxVehicleSuspensionForce containing per-wheel suspension forces for each wheel referenced by axleDescription. \param[out] antiRollTorque is optionally returned as a non-null pointer to a single PxVehicleAntiRollTorque instance that will store the accumulated anti-roll torque to be applied to the vheicle's rigid body. \note antiRollForceParams and antiRollTorque should be returned either both non-NULL or both NULL. */ virtual void getDataForSuspensionComponent( const PxVehicleAxleDescription*& axleDescription, const PxVehicleRigidBodyParams*& rigidBodyParams, const PxVehicleSuspensionStateCalculationParams*& suspensionStateCalculationParams, PxVehicleArrayData<const PxReal>& steerResponseStates, const PxVehicleRigidBodyState*& rigidBodyState, PxVehicleArrayData<const PxVehicleWheelParams>& wheelParams, PxVehicleArrayData<const PxVehicleSuspensionParams>& suspensionParams, PxVehicleArrayData<const PxVehicleSuspensionComplianceParams>& suspensionComplianceParams, PxVehicleArrayData<const PxVehicleSuspensionForceParams>& suspensionForceParams, PxVehicleSizedArrayData<const PxVehicleAntiRollForceParams>& antiRollForceParams, PxVehicleArrayData<const PxVehicleRoadGeometryState>& wheelRoadGeomStates, PxVehicleArrayData<PxVehicleSuspensionState>& suspensionStates, PxVehicleArrayData<PxVehicleSuspensionComplianceState>& suspensionComplianceStates, PxVehicleArrayData<PxVehicleSuspensionForce>& suspensionForces, PxVehicleAntiRollTorque*& antiRollTorque) = 0; /** \brief Update the suspension state and suspension compliance state and use those updated states to compute suspension and anti-roll forces/torques to apply to the vehicle's rigid body. \param[in] dt is the simulation time that has passed since the last call to PxVehicleSuspensionComponent::update() \param[in] context describes a variety of global simulation constants such as frame and scale of the simulation and the gravitational acceleration of the simulated environment. \note The suspension and anti-roll forces/torques are computed in the world frame. */ virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context) { PX_PROFILE_ZONE("PxVehicleSuspensionComponent::update", 0); const PxVehicleAxleDescription* axleDescription; const PxVehicleRigidBodyParams* rigidBodyParams; const PxVehicleSuspensionStateCalculationParams* suspensionStateCalculationParams; PxVehicleArrayData<const PxReal> steerResponseStates; const PxVehicleRigidBodyState* rigidBodyState; PxVehicleArrayData<const PxVehicleWheelParams> wheelParams; PxVehicleArrayData<const PxVehicleSuspensionParams> suspensionParams; PxVehicleArrayData<const PxVehicleSuspensionComplianceParams> suspensionComplianceParams; PxVehicleArrayData<const PxVehicleSuspensionForceParams> suspensionForceParams; PxVehicleSizedArrayData<const PxVehicleAntiRollForceParams> antiRollForceParams; PxVehicleArrayData<const PxVehicleRoadGeometryState> wheelRoadGeomStates; PxVehicleArrayData<PxVehicleSuspensionState> suspensionStates; PxVehicleArrayData<PxVehicleSuspensionComplianceState> suspensionComplianceStates; PxVehicleArrayData<PxVehicleSuspensionForce> suspensionForces; PxVehicleAntiRollTorque* antiRollTorque; getDataForSuspensionComponent(axleDescription, rigidBodyParams, suspensionStateCalculationParams, steerResponseStates, rigidBodyState, wheelParams, suspensionParams, suspensionComplianceParams, suspensionForceParams, antiRollForceParams, wheelRoadGeomStates, suspensionStates, suspensionComplianceStates, suspensionForces, antiRollTorque); for (PxU32 i = 0; i < axleDescription->nbWheels; i++) { const PxU32 wheelId = axleDescription->wheelIdsInAxleOrder[i]; //Update the suspension state (jounce, jounce speed) PxVehicleSuspensionStateUpdate( wheelParams[wheelId], suspensionParams[wheelId], *suspensionStateCalculationParams, suspensionForceParams[wheelId].stiffness, suspensionForceParams[wheelId].damping, steerResponseStates[wheelId], wheelRoadGeomStates[wheelId], *rigidBodyState, dt, context.frame, context.gravity, suspensionStates[wheelId]); //Update the compliance from the suspension state. PxVehicleSuspensionComplianceUpdate( suspensionParams[wheelId], suspensionComplianceParams[wheelId], suspensionStates[wheelId], suspensionComplianceStates[wheelId]); //Compute the suspension force from the suspension and compliance states. PxVehicleSuspensionForceUpdate( suspensionParams[wheelId], suspensionForceParams[wheelId], wheelRoadGeomStates[wheelId], suspensionStates[wheelId], suspensionComplianceStates[wheelId], *rigidBodyState, context.gravity, rigidBodyParams->mass, suspensionForces[wheelId]); } if (antiRollForceParams.size>0 && antiRollTorque) { PxVehicleAntiRollForceUpdate( suspensionParams, antiRollForceParams, suspensionStates.getConst(), suspensionComplianceStates.getConst(), *rigidBodyState, *antiRollTorque); } return true; } }; /** * @deprecated */ class PX_DEPRECATED PxVehicleLegacySuspensionComponent : public PxVehicleComponent { public: PxVehicleLegacySuspensionComponent() : PxVehicleComponent() {} virtual ~PxVehicleLegacySuspensionComponent() {} /** \brief Retrieve pointers to the parameter and state data required to compute the suspension state and the forces/torques that arise from the suspension state. \param[out] axleDescription must be returned as a non-null pointer to a single PxVehicleAxleDescription instance that describes the wheels and axles of the vehicle. \param[out] suspensionStateCalculationParams must be returned as a non-null pointer to a single PxVehicleSuspensionStateCalculationParams instance that describes the jounce computation type etc. \param[out] steerResponseStates must be returned as a non-null pointer to a single PxVehicleSteerCommandResponseStates instance that describes the steer state of the wheels. \param[out] rigidBodyState must be returned as a non-null pointer to a single PxVehicleRigidBodyState instance that describes the pose and momentum of the vehicle's rigid body. \param[out] wheelParams must be set to a non-null pointer to an array of PxVehicleWheelParams containing per-wheel parameters for each wheel referenced by axleDescription. \param[out] suspensionParams must be set to a non-null pointer to an array of PxVehicleSuspensionParams containing per-wheel parameters for each wheel referenced by axleDescription. \param[out] suspensionComplianceParams must be set to a non-null pointer to an array of PxVehicleSuspensionComplianceParams containing per-wheel parameters for each wheel referenced by axleDescription. \param[out] suspensionForceParams must be set to a non-null pointer to an array of PxVehicleSuspensionForceLegacyParams containing per-wheel parameters for each wheel referenced by axleDescription. \param[out] antiRollForceParams is optionally returned as a non-null pointer to an array of PxVehicleAntiRollForceParams with each element in the array describing a unique anti-roll bar connecting a pair of wheels. \param[out] wheelRoadGeomStates must be set to non-null pointer to an array of PxVehicleRoadGeometryState containing per-wheel road geometry for each wheel referenced by axleDescription. \param[out] suspensionStates must be set to a non-null pointer to an array of PxVehicleSuspensionState containing per-wheel suspension state for each wheel referenced by axleDescription. \param[out] suspensionComplianceStates must be set to a non-null pointer to an array of PxVehicleSuspensionComplianceState containing per-wheel suspension compliance state for each wheel referenced by axleDescription. \param[out] suspensionForces must be set to a non-null pointer to an array of PxVehicleSuspensionForce containing per-wheel suspension forces for each wheel referenced by axleDescription. \param[out] antiRollTorque is optionally returned as a non-null pointer to a single PxVehicleAntiRollTorque instance that will store the accumulated anti-roll torque to be applied to the vheicle's rigid body. \note antiRollForceParams and antiRollTorque should be returned either both non-NULL or both NULL. */ virtual void getDataForLegacySuspensionComponent( const PxVehicleAxleDescription*& axleDescription, const PxVehicleSuspensionStateCalculationParams*& suspensionStateCalculationParams, PxVehicleArrayData<const PxReal>& steerResponseStates, const PxVehicleRigidBodyState*& rigidBodyState, PxVehicleArrayData<const PxVehicleWheelParams>& wheelParams, PxVehicleArrayData<const PxVehicleSuspensionParams>& suspensionParams, PxVehicleArrayData<const PxVehicleSuspensionComplianceParams>& suspensionComplianceParams, PxVehicleArrayData<const PxVehicleSuspensionForceLegacyParams>& suspensionForceParams, PxVehicleSizedArrayData<const PxVehicleAntiRollForceParams>& antiRollForceParams, PxVehicleArrayData<const PxVehicleRoadGeometryState>& wheelRoadGeomStates, PxVehicleArrayData<PxVehicleSuspensionState>& suspensionStates, PxVehicleArrayData<PxVehicleSuspensionComplianceState>& suspensionComplianceStates, PxVehicleArrayData<PxVehicleSuspensionForce>& suspensionForces, PxVehicleAntiRollTorque*& antiRollTorque) = 0; /** \brief Update the suspension state and suspension compliance state and use those updated states to compute suspension and anti-roll forces/torques to apply to the vehicle's rigid body. \param[in] dt is the simulation time that has passed since the last call to PxVehicleSuspensionComponent::update() \param[in] context describes a variety of global simulation constants such as frame and scale of the simulation and the gravitational acceleration of the simulated environment. \note The suspension and anti-roll forces are computed in the world frame. \note PxVehicleLegacySuspensionComponent::update() implements legacy suspension behaviour. */ virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context) { PX_PROFILE_ZONE("PxVehicleLegacySuspensionComponent::update", 0); const PxVehicleAxleDescription* axleDescription; const PxVehicleSuspensionStateCalculationParams* suspensionStateCalculationParams; PxVehicleArrayData<const PxReal> steerResponseStates; const PxVehicleRigidBodyState* rigidBodyState; PxVehicleArrayData<const PxVehicleWheelParams> wheelParams; PxVehicleArrayData<const PxVehicleSuspensionParams> suspensionParams; PxVehicleArrayData<const PxVehicleSuspensionComplianceParams> suspensionComplianceParams; PxVehicleArrayData<const PxVehicleSuspensionForceLegacyParams> suspensionForceParams; PxVehicleSizedArrayData<const PxVehicleAntiRollForceParams> antiRollForceParams; PxVehicleArrayData<const PxVehicleRoadGeometryState> wheelRoadGeomStates; PxVehicleArrayData<PxVehicleSuspensionState> suspensionStates; PxVehicleArrayData<PxVehicleSuspensionComplianceState> suspensionComplianceStates; PxVehicleArrayData<PxVehicleSuspensionForce> suspensionForces; PxVehicleAntiRollTorque* antiRollTorque; getDataForLegacySuspensionComponent(axleDescription, suspensionStateCalculationParams, steerResponseStates, rigidBodyState, wheelParams, suspensionParams, suspensionComplianceParams, suspensionForceParams, antiRollForceParams, wheelRoadGeomStates, suspensionStates, suspensionComplianceStates, suspensionForces, antiRollTorque); for (PxU32 i = 0; i < axleDescription->nbWheels; i++) { const PxU32 wheelId = axleDescription->wheelIdsInAxleOrder[i]; //Update the suspension state (jounce, jounce speed) PxVehicleSuspensionStateUpdate( wheelParams[wheelId], suspensionParams[wheelId], *suspensionStateCalculationParams, suspensionForceParams[wheelId].stiffness, suspensionForceParams[wheelId].damping, steerResponseStates[wheelId], wheelRoadGeomStates[wheelId], *rigidBodyState, dt, context.frame, context.gravity, suspensionStates[wheelId]); //Update the compliance from the suspension state. PxVehicleSuspensionComplianceUpdate( suspensionParams[wheelId], suspensionComplianceParams[wheelId], suspensionStates[wheelId], suspensionComplianceStates[wheelId]); //Compute the suspension force from the suspension and compliance states. PxVehicleSuspensionLegacyForceUpdate( suspensionParams[wheelId], suspensionForceParams[wheelId], wheelRoadGeomStates[wheelId], suspensionStates[wheelId], suspensionComplianceStates[wheelId], *rigidBodyState, context.gravity, suspensionForces[wheelId]); } if (antiRollForceParams.size>0 && antiRollTorque) { PxVehicleAntiRollForceUpdate( suspensionParams, antiRollForceParams, suspensionStates.getConst(), suspensionComplianceStates.getConst(), *rigidBodyState, *antiRollTorque); } return true; } }; #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
18,164
C
54.212766
160
0.821625
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/suspension/PxVehicleSuspensionStates.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "foundation/PxSimpleTypes.h" #include "foundation/PxVec3.h" #include "foundation/PxMemory.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif #define PX_VEHICLE_UNSPECIFIED_JOUNCE PX_MAX_F32 #define PX_VEHICLE_UNSPECIFIED_SEPARATION PX_MAX_F32 /** */ struct PxVehicleSuspensionState { /** \brief jounce is the distance from maximum droop. \note jounce is positive semi-definite \note A value of 0.0 represents the suspension at maximum droop and zero suspension force. \note A value of suspensionTravelDist represents the suspension at maximum compression. \note jounce is clamped in range [0, suspensionTravelDist]. */ PxReal jounce; /** \brief jounceSpeed is the rate of change of jounce. */ PxReal jounceSpeed; /** \brief separation holds extra information about the contact state of the wheel with the ground. If the suspension travel range is enough to place the wheel on the ground, then separation will be 0. If separation holds a negative value, then the wheel penetrates into the ground at maximum compression as well as maximum droop. The suspension would need to go beyond maximum compression (ground normal pointing in opposite direction of suspension) or beyond maximum droop (ground normal pointing in same direction as suspension) to place the wheel on the ground. In that case the separation value defines how much the wheel penetrates into the ground along the ground plane normal. This penetration may be resolved by using a constraint that simulates the effect of a bump stop. If separation holds a positive value, then the wheel does not penetrate the ground at maximum droop but can not touch the ground because the suspension would need to expand beyond max droop to reach it or because the suspension could not expand fast enough to reach the ground. */ PxReal separation; PX_FORCE_INLINE void setToDefault(const PxReal _jounce = PX_VEHICLE_UNSPECIFIED_JOUNCE, const PxReal _separation = PX_VEHICLE_UNSPECIFIED_SEPARATION) { jounce = _jounce; jounceSpeed = 0; separation = _separation; } }; /** \brief The effect of suspension compliance on toe and camber angle and on the tire and suspension force application points. */ struct PxVehicleSuspensionComplianceState { /** \brief The toe angle in radians that arises from suspension compliance. \note toe is expressed in the suspension frame. */ PxReal toe; /** \brief The camber angle in radians that arises from suspension compliance. \note camber is expressed in the suspension frame. */ PxReal camber; /** \brief The tire force application point that arises from suspension compliance. \note tireForceAppPoint is expressed in the suspension frame. */ PxVec3 tireForceAppPoint; /** \brief The suspension force application point that arises from suspension compliance. \note suspForceAppPoint is expressed in the suspension frame. */ PxVec3 suspForceAppPoint; PX_FORCE_INLINE void setToDefault() { PxMemZero(this, sizeof(PxVehicleSuspensionComplianceState)); } }; /** \brief The force and torque for a single suspension to apply to the vehicle's rigid body. */ struct PxVehicleSuspensionForce { /** \brief The force to apply to the rigid body. \note force is expressed in the world frame. <b>Unit:</b> mass * length / (time^2) */ PxVec3 force; /** \brief The torque to apply to the rigid body. \note torque is expressed in the world frame. <b>Unit:</b> mass * (length^2) / (time^2) */ PxVec3 torque; /** \brief The component of force that lies along the normal of the plane under the wheel. \note normalForce may be used by the tire model as the tire load. <b>Unit:</b> mass * length / (time^2) */ PxReal normalForce; PX_FORCE_INLINE void setToDefault() { PxMemZero(this, sizeof(PxVehicleSuspensionForce)); } }; /** \brief The anti-roll torque of all anti-roll bars accumulates in a single torque to apply to the vehicle's rigid body. */ struct PxVehicleAntiRollTorque { /** \brief The accumulated torque to apply to the rigid body. \note antiRollTorque is expressed in the world frame. <b>Unit:</b> mass * (length^2) / (time^2) */ PxVec3 antiRollTorque; PX_FORCE_INLINE void setToDefault() { PxMemZero(this, sizeof(PxVehicleAntiRollTorque)); } }; #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
6,102
C
31.121052
123
0.753851
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/suspension/PxVehicleSuspensionParams.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "foundation/PxTransform.h" #include "foundation/PxFoundation.h" #include "common/PxCoreUtilityTypes.h" #include "vehicle2/PxVehicleParams.h" #include "vehicle2/PxVehicleFunctions.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif struct PxVehicleSuspensionParams { /** \brief suspensionAttachment specifies the wheel pose at maximum compression. \note suspensionAttachment is specified in the frame of the rigid body. \note camber, steer and toe angles are all applied in the suspension frame. */ PxTransform suspensionAttachment; /** \brief suspensionTravelDir specifies the direction of suspension travel. \note suspensionTravelDir is specified in the frame of the rigid body. */ PxVec3 suspensionTravelDir; /** \brief suspensionTravelDist is the maximum distance that the suspenson can elongate along #suspensionTravelDir from the pose specified by #suspensionAttachment. \note The position suspensionAttachment.p + #suspensionTravelDir*#suspensionTravelDist corresponds to the the suspension at maximum droop in the rigid body frame. */ PxReal suspensionTravelDist; /** \brief wheelAttachment is the pose of the wheel in the suspension frame. \note The rotation angle around the wheel's lateral axis is applied in the wheel attachment frame. */ PxTransform wheelAttachment; PX_FORCE_INLINE PxVehicleSuspensionParams transformAndScale( const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const { PxVehicleSuspensionParams r = *this; r.suspensionAttachment= PxVehicleTransformFrameToFrame(srcFrame, trgFrame, srcScale, trgScale, suspensionAttachment); r.suspensionTravelDir = PxVehicleTransformFrameToFrame(srcFrame, trgFrame, suspensionTravelDir); r.suspensionTravelDist *= (trgScale.scale/srcScale.scale); r.wheelAttachment = PxVehicleTransformFrameToFrame(srcFrame, trgFrame, srcScale, trgScale, wheelAttachment); return r; } PX_FORCE_INLINE bool isValid() const { PX_CHECK_AND_RETURN_VAL(suspensionAttachment.isValid(), "PxVehicleSuspensionParams.suspensionAttachment must be a valid transform", false); PX_CHECK_AND_RETURN_VAL(suspensionTravelDir.isFinite(), "PxVehicleSuspensionParams.suspensionTravelDir must be a valid vector", false); PX_CHECK_AND_RETURN_VAL(suspensionTravelDir.isNormalized(), "PxVehicleSuspensionParams.suspensionTravelDir must be a unit vector", false); PX_CHECK_AND_RETURN_VAL(suspensionTravelDist > 0.0f, "PxVehicleSuspensionParams.suspensionTravelDist must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(wheelAttachment.isValid(), "PxVehicleSuspensionParams.wheelAttachment must be a valid transform", false); return true; } }; struct PxVehicleSuspensionJounceCalculationType { enum Enum { eRAYCAST, //!< The jounce is calculated using a raycast against the plane of the road geometry state eSWEEP, //!< The jounce is calculated by sweeping a cylinder against the plane of the road geometry state eMAX_NB }; }; struct PxVehicleSuspensionStateCalculationParams { PxVehicleSuspensionJounceCalculationType::Enum suspensionJounceCalculationType; /** \brief Limit the suspension expansion dynamics. If a hit with the ground is detected, the suspension jounce will be set such that the wheel is placed on the ground. This can result in large changes to jounce within a single simulation frame, if the ground surface has high frequency or if the simulation time step is large. As a result, large damping forces can evolve and cause undesired behavior. If this parameter is set to true, the suspension expansion speed will be limited to what can be achieved given the time step, suspension stiffness etc. As a consequence, handling of the vehicle will be affected as the wheel might loose contact with the ground more easily. */ bool limitSuspensionExpansionVelocity; PX_FORCE_INLINE PxVehicleSuspensionStateCalculationParams transformAndScale( const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const { PX_UNUSED(srcFrame); PX_UNUSED(trgFrame); PX_UNUSED(srcScale); PX_UNUSED(trgScale); return *this; } PX_FORCE_INLINE bool isValid() const { return true; } }; /** \brief Compliance describes how toe and camber angle and force application points are affected by suspension compression. \note Each compliance term is in the form of a graph with up to 3 points. \note Each point in the graph has form (jounce/suspensionTravelDist, complianceValue). \note The sequence of points must respresent monotonically increasing values of jounce. \note The compliance value can be computed by linear interpolation. \note If any graph has zero points in it, a value of 0.0 is used for the compliance value. \note If any graph has 1 point in it, the compliance value of that point is used directly. */ struct PxVehicleSuspensionComplianceParams { /** \brief A graph of toe angle against jounce/suspensionTravelDist with the toe angle expressed in radians. \note The toe angle is applied in the suspension frame. */ PxVehicleFixedSizeLookupTable<PxReal, 3> wheelToeAngle; /** \brief A graph of camber angle against jounce/suspensionTravelDist with the camber angle expressed in radians. \note The camber angle is applied in the suspension frame. */ PxVehicleFixedSizeLookupTable<PxReal, 3> wheelCamberAngle; /** \brief Suspension forces are applied at an offset from the suspension frame. suspForceAppPoint specifies the (X, Y, Z) components of that offset as a function of jounce/suspensionTravelDist. */ PxVehicleFixedSizeLookupTable<PxVec3, 3> suspForceAppPoint; /** \brief Tire forces are applied at an offset from the suspension frame. tireForceAppPoint specifies the (X, Y, Z) components of that offset as a function of jounce/suspensionTravelDist. */ PxVehicleFixedSizeLookupTable<PxVec3, 3> tireForceAppPoint; PX_FORCE_INLINE PxVehicleSuspensionComplianceParams transformAndScale( const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const { PX_UNUSED(srcFrame); PX_UNUSED(trgFrame); PxVehicleSuspensionComplianceParams r = *this; const PxReal scale = trgScale.scale / srcScale.scale; for (PxU32 i = 0; i < r.suspForceAppPoint.nbDataPairs; i++) { r.suspForceAppPoint.yVals[i] = PxVehicleTransformFrameToFrame(srcFrame, trgFrame, suspForceAppPoint.yVals[i]); r.suspForceAppPoint.yVals[i] *= scale; } for (PxU32 i = 0; i < r.tireForceAppPoint.nbDataPairs; i++) { r.tireForceAppPoint.yVals[i] = PxVehicleTransformFrameToFrame(srcFrame, trgFrame, tireForceAppPoint.yVals[i]); r.tireForceAppPoint.yVals[i] *= scale; } return r; } PX_FORCE_INLINE bool isValid() const { PX_CHECK_AND_RETURN_VAL(wheelToeAngle.isValid(), "PxVehicleSuspensionComplianceParams.wheelToeAngle is invalid", false); PX_CHECK_AND_RETURN_VAL(wheelCamberAngle.isValid(), "PxVehicleSuspensionComplianceParams.wheelCamberAngle is invalid", false); PX_CHECK_AND_RETURN_VAL(suspForceAppPoint.isValid(), "PxVehicleSuspensionComplianceParams.wheelToeAngle is invalid", false); PX_CHECK_AND_RETURN_VAL(tireForceAppPoint.isValid(), "PxVehicleSuspensionComplianceParams.wheelCamberAngle is invalid", false); for (PxU32 i = 0; i < wheelToeAngle.nbDataPairs; i++) { PX_CHECK_AND_RETURN_VAL(wheelToeAngle.xVals[i] >= 0.0f && wheelToeAngle.xVals[i] <= 1.0f, "PxVehicleSuspensionComplianceParams.wheelToeAngle must be an array of points (x,y) with x in range [0, 1]", false); PX_CHECK_AND_RETURN_VAL(wheelToeAngle.yVals[i] >= -PxPi && wheelToeAngle.yVals[i] <= PxPi, "PxVehicleSuspensionComplianceParams.wheelToeAngle must be an array of points (x,y) with y in range [-Pi, Pi]", false); } for (PxU32 i = 0; i < wheelCamberAngle.nbDataPairs; i++) { PX_CHECK_AND_RETURN_VAL(wheelCamberAngle.xVals[i] >= 0.0f && wheelCamberAngle.xVals[i] <= 1.0f, "PxVehicleSuspensionComplianceParams.wheelCamberAngle must be an array of points (x,y) with x in range [0, 1]", false); PX_CHECK_AND_RETURN_VAL(wheelCamberAngle.yVals[i] >= -PxPi && wheelCamberAngle.yVals[i] <= PxPi, "PxVehicleSuspensionComplianceParams.wheelCamberAngle must be an array of points (x,y) with y in range [-Pi, Pi]", false); } for (PxU32 i = 0; i < suspForceAppPoint.nbDataPairs; i++) { PX_CHECK_AND_RETURN_VAL(suspForceAppPoint.xVals[i] >= 0.0f && suspForceAppPoint.xVals[i] <= 1.0f, "PxVehicleSuspensionComplianceParams.suspForceAppPoint[0] must be an array of points (x,y) with x in range [0, 1]", false); } for (PxU32 i = 0; i < tireForceAppPoint.nbDataPairs; i++) { PX_CHECK_AND_RETURN_VAL(tireForceAppPoint.xVals[i] >= 0.0f && tireForceAppPoint.xVals[i] <= 1.0f, "PxVehicleSuspensionComplianceParams.tireForceAppPoint[0] must be an array of points (x,y) with x in range [0, 1]", false); } return true; } }; /** \brief Suspension force is computed by converting suspenson state to suspension force under the assumption of a linear spring. @see PxVehicleSuspensionForceUpdate */ struct PxVehicleSuspensionForceParams { /** \brief Spring strength of suspension. <b>Range:</b> (0, inf)<br> <b>Unit:</b> mass / (time^2) */ PxReal stiffness; /** \brief Spring damper rate of suspension. <b>Range:</b> [0, inf)<br> <b>Unit:</b> mass / time */ PxReal damping; /** \brief Part of the vehicle mass that is supported by the suspension spring. <b>Range:</b> (0, inf)<br> <b>Unit:</b> mass */ PxReal sprungMass; PX_FORCE_INLINE PxVehicleSuspensionForceParams transformAndScale( const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const { PX_UNUSED(srcFrame); PX_UNUSED(trgFrame); PX_UNUSED(srcScale); PX_UNUSED(trgScale); return *this; } PX_FORCE_INLINE bool isValid() const { PX_CHECK_AND_RETURN_VAL(stiffness > 0.0f, "PxVehicleSuspensionForceParams.stiffness must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(damping >= 0.0f, "PxVehicleSuspensionForceParams.damping must be greater than or equal to zero", false); PX_CHECK_AND_RETURN_VAL(sprungMass > 0.0f, "PxVehicleSuspensionForceParams.sprungMass must be greater than zero", false); return true; } }; /** \brief Suspension force is computed by converting suspenson state to suspension force under the assumption of a linear spring. @see PxVehicleSuspensionLegacyForceUpdate @deprecated */ struct PX_DEPRECATED PxVehicleSuspensionForceLegacyParams { /** \brief Spring strength of suspension. <b>Range:</b> (0, inf)<br> <b>Unit:</b> mass / (time^2) */ PxReal stiffness; /** \brief Spring damper rate of suspension. <b>Range:</b> [0, inf)<br> <b>Unit:</b> mass / time */ PxReal damping; /** \brief The suspension compression that balances the gravitational force acting on the sprung mass. <b>Range:</b> (0, inf)<br> <b>Unit:</b> length */ PxReal restDistance; /** \brief The mass supported by the suspension spring. <b>Range:</b> (0, inf)<br> <b>Unit:</b> mass */ PxReal sprungMass; PX_FORCE_INLINE PxVehicleSuspensionForceLegacyParams transformAndScale( const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const { PX_UNUSED(srcFrame); PX_UNUSED(trgFrame); PxVehicleSuspensionForceLegacyParams r = *this; r.restDistance *= (trgScale.scale / srcScale.scale); return *this; } PX_FORCE_INLINE bool isValid() const { PX_CHECK_AND_RETURN_VAL(stiffness > 0.0f, "PxVehicleSuspensionForceLegacyParams.stiffness must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(damping >= 0.0f, "PxVehicleSuspensionForceLegacyParams.damping must be greater than or equal to zero", false); PX_CHECK_AND_RETURN_VAL(restDistance > 0.0f, "PxVehicleSuspensionForceLegacyParams.restDistance must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(sprungMass > 0.0f, "PxVehicleSuspensionForceLegacyParams.sprungMass must be greater than zero", false); return true; } }; /** \brief The purpose of the anti-roll bar is to generate a torque to apply to the vehicle's rigid body that will reduce the jounce difference arising between any pair of chosen wheels. If the chosen wheels share an axle, the anti-roll bar will attempt to reduce the roll angle of the vehicle's rigid body. Alternatively, if the chosen wheels are the front and rear wheels along one side of the vehicle, the anti-roll bar will attempt to reduce the pitch angle of the vehicle's rigid body. */ struct PxVehicleAntiRollForceParams { /* \brief The anti-roll bar connects two wheels with indices wheel0 and wheel1 \note wheel0 and wheel1 may be chosen to have the effect of an anti-dive bar or to have the effect of an anti-roll bar. */ PxU32 wheel0; /* \brief The anti-roll bar connects two wheels with indices wheel0 and wheel1 \note wheel0 and wheel1 may be chosen to have the effect of an anti-dive bar or to have the effect of an anti-roll bar. */ PxU32 wheel1; /* \brief The linear stiffness of the anti-roll bar. \note A positive stiffness will work to reduce the discrepancy in jounce between wheel0 and wheel1. \note A negative stiffness will work to increase the discrepancy in jounce between wheel0 and wheel1. <b>Unit:</b> mass / (time^2) */ PxReal stiffness; PX_FORCE_INLINE PxVehicleAntiRollForceParams transformAndScale( const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const { PX_UNUSED(srcFrame); PX_UNUSED(trgFrame); PX_UNUSED(srcScale); PX_UNUSED(trgScale); return *this; } PX_FORCE_INLINE bool isValid(const PxVehicleAxleDescription& axleDesc) const { if (!PxIsFinite(stiffness)) return false; if (wheel0 == wheel1) return false; //Check that each wheel id is a valid wheel. const PxU32 wheelIds[2] = { wheel0, wheel1 }; for (PxU32 k = 0; k < 2; k++) { const PxU32 wheelToFind = wheelIds[k]; bool foundWheelInAxleDescription = false; for (PxU32 i = 0; i < axleDesc.nbWheels; i++) { const PxU32 wheel = axleDesc.wheelIdsInAxleOrder[i]; if (wheel == wheelToFind) { foundWheelInAxleDescription = true; } } if (!foundWheelInAxleDescription) return false; } return true; } }; #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
16,224
C
38.096385
224
0.759615
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/suspension/PxVehicleSuspensionFunctions.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "foundation/PxVec3.h" #include "foundation/PxSimpleTypes.h" #include "vehicle2/PxVehicleParams.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif struct PxVehicleWheelParams; struct PxVehicleSuspensionParams; struct PxVehicleSuspensionStateCalculationParams; struct PxVehicleRoadGeometryState; struct PxVehicleRigidBodyState; struct PxVehicleSuspensionState; struct PxVehicleSuspensionComplianceParams; struct PxVehicleSuspensionComplianceState; struct PxVehicleSuspensionForceParams; struct PxVehicleSuspensionForce; struct PxVehicleSuspensionForceLegacyParams; struct PxVehicleAntiRollForceParams; struct PxVehicleAntiRollTorque; /** \brief Compute the suspension compression and compression speed for a single suspension. \param[in] wheelParams is a description of the radius and half-width of the wheel on the suspension. \param[in] suspensionParams is a description of the suspension and wheel frames. \param[in] suspensionStateCalcParams specifies whether to compute the suspension compression by either raycasting or sweeping against the plane of the road geometry under the wheel. \param[in] suspensionStiffness is the stiffness of the suspension \param[in] suspensionDamping is the damping rate of the suspension. or whether to apply a limit to the expansion speed so that the wheel may not reach the ground. \param[in] steerAngle is the yaw angle (in radians) of the wheel. \param[in] roadGeometryState describes the plane under the wheel. \param[in] rigidBodyState describes the pose of the rigid body. \param[in] dt is the simulation time that has lapsed since the last call to PxVehicleSuspensionStateUpdate \param[in] frame describes the longitudinal, lateral and vertical axes of the vehicle. \param[in] gravity is the gravitational acceleration that acts on the suspension sprung mass. \param[in,out] suspState is the compression (jounce) and compression speed of the suspension. */ void PxVehicleSuspensionStateUpdate (const PxVehicleWheelParams& wheelParams, const PxVehicleSuspensionParams& suspensionParams, const PxVehicleSuspensionStateCalculationParams& suspensionStateCalcParams, const PxReal suspensionStiffness, const PxReal suspensionDamping, const PxReal steerAngle, const PxVehicleRoadGeometryState& roadGeometryState, const PxVehicleRigidBodyState& rigidBodyState, const PxReal dt, const PxVehicleFrame& frame, const PxVec3& gravity, PxVehicleSuspensionState& suspState); /** \brief Compute the toe, camber and force application points that are affected by suspension compression. \param[in] suspensionParams is a description of the suspension and wheel frames. \param[in] complianceParams describes how toe, camber and force application points are affected by suspension compression. \param[in] suspensionState describes the current suspension compression. \param[in] complianceState is the computed toe, camber and force application points. */ void PxVehicleSuspensionComplianceUpdate (const PxVehicleSuspensionParams& suspensionParams, const PxVehicleSuspensionComplianceParams& complianceParams, const PxVehicleSuspensionState& suspensionState, PxVehicleSuspensionComplianceState& complianceState); /** \brief Compute the suspension force and torque arising from suspension compression and speed. \param[in] suspensionParams is a description of the suspension and wheel frames. \param[in] suspensionForceParams describes the conversion of suspension state to suspension force. \param[in] roadGeometryState describes the plane under the wheel of the suspension. \param[in] suspensionState is the current compression state of the suspension. \param[in] complianceState is the current compliance state of the suspension. \param[in] rigidBodyState describes the current pose of the rigid body. \param[in] gravity is the gravitational acceleration. \param[in] vehicleMass is the rigid body mass. \param[out] suspensionForce is the force and torque to apply to the rigid body arising from the suspension state. */ void PxVehicleSuspensionForceUpdate (const PxVehicleSuspensionParams& suspensionParams, const PxVehicleSuspensionForceParams& suspensionForceParams, const PxVehicleRoadGeometryState& roadGeometryState, const PxVehicleSuspensionState& suspensionState, const PxVehicleSuspensionComplianceState& complianceState, const PxVehicleRigidBodyState& rigidBodyState, const PxVec3& gravity, const PxReal vehicleMass, PxVehicleSuspensionForce& suspensionForce); /** \brief Compute the suspension force and torque arising from suspension compression and speed. \param[in] suspensionParams is a description of the suspension and wheel frames. \param[in] suspensionForceParams describes the conversion of suspension state to suspension force. \param[in] roadGeometryState describes the plane under the wheel of the suspension. \param[in] suspensionState is the current compression state of the suspension. \param[in] complianceState is the current compliance state of the suspension. \param[in] rigidBodyState describes the current pose of the rigid body. \param[in] gravity is the gravitational acceleration. \param[out] suspensionForce is the force and torque to apply to the rigid body arising from the suspension state. \note PxVehicleSuspensionLegacyForceUpdate implements the legacy force computation of PhysX 5.0 and earlier. @deprecated */ PX_DEPRECATED void PxVehicleSuspensionLegacyForceUpdate (const PxVehicleSuspensionParams& suspensionParams, const PxVehicleSuspensionForceLegacyParams& suspensionForceParams, const PxVehicleRoadGeometryState& roadGeometryState, const PxVehicleSuspensionState& suspensionState, const PxVehicleSuspensionComplianceState& complianceState, const PxVehicleRigidBodyState& rigidBodyState, const PxVec3& gravity, PxVehicleSuspensionForce& suspensionForce); /** \brief Compute the accumulated anti-roll torque to apply to the vehicle's rigid body. \param[in] suspensionParams The suspension parameters for each wheel. \param[in] antiRollParams describes the wheel pairs connected by anti-roll bars and the strength of each anti-roll bar. \param[in] suspensionStates The suspension states for each wheel. \param[in] complianceStates The suspension compliance states for each wheel. \param[in] rigidBodyState describes the pose and momentum of the vehicle's rigid body in the world frame. \param[in] antiRollTorque is the accumulated anti-roll torque that is computed by iterating over all anti-roll bars describes in *antiRollParams*. \note suspensionParams must contain an entry for each wheel index referenced by *antiRollParams*. \note suspensionStates must contain an entry for each wheel index referenced by *antiRollParams*. \note complianceStates must contain an entry for each wheel index referenced by *antiRollParams*. \note antiRollTorque is expressed in the world frame. */ void PxVehicleAntiRollForceUpdate (const PxVehicleArrayData<const PxVehicleSuspensionParams>& suspensionParams, const PxVehicleSizedArrayData<const PxVehicleAntiRollForceParams>& antiRollParams, const PxVehicleArrayData<const PxVehicleSuspensionState>& suspensionStates, const PxVehicleArrayData<const PxVehicleSuspensionComplianceState>& complianceStates, const PxVehicleRigidBodyState& rigidBodyState, PxVehicleAntiRollTorque& antiRollTorque); #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
9,080
C
53.377245
168
0.822797
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/tire/PxVehicleTireParams.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "foundation/PxFoundation.h" #include "vehicle2/PxVehicleParams.h" #include "PxVehicleTireStates.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif struct PxVehicleTireForceParams { /** \brief Tire lateral stiffness is a graph of tire load that has linear behavior near zero load and flattens at large loads. latStiffX describes the minimum normalized load (load/restLoad) that gives a flat lateral stiffness response to load. \note A value of 0.0 indicates that the tire lateral stiffness is independent of load and will adopt the value #latStiffY for all values of tire load. */ PxReal latStiffX; /** \brief Tire lateral stiffness is a graph of tire load that has linear behavior near zero load and flattens at large loads. latStiffY describes the maximum possible value of lateral stiffness that occurs when (load/restLoad) >= #latStiffX. <b>Unit:</b> force per lateral slip = mass * length / (time^2) */ PxReal latStiffY; /** \brief Tire Longitudinal stiffness \note Longitudinal force can be approximated as longStiff*longitudinalSlip. <b>Unit:</b> force per longitudinal slip = mass * length / (time^2) */ PxReal longStiff; /** \brief Tire camber stiffness \note Camber force can be approximated as camberStiff*camberAngle. <b>Unit:</b> force per radian = mass * length / (time^2) */ PxReal camberStiff; /** \brief Graph of friction vs longitudinal slip with 3 points. \note frictionVsSlip[0][0] is always zero. \note frictionVsSlip[0][1] is the friction available at zero longitudinal slip. \note frictionVsSlip[1][0] is the value of longitudinal slip with maximum friction. \note frictionVsSlip[1][1] is the maximum friction. \note frictionVsSlip[2][0] is the end point of the graph. \note frictionVsSlip[2][1] is the value of friction for slips greater than frictionVsSlip[2][0]. \note The friction value is computed from the friction vs longitudinal slip graph using linear interpolation. \note The friction value computed from the friction vs longitudinal slip graph is used to scale the friction value of the road geometry. \note frictionVsSlip[2][0] > frictionVsSlip[1][0] > frictionVsSlip[0][0] \note frictionVsSlip[1][1] is typically greater than frictionVsSlip[0][1] \note frictionVsSlip[2][1] is typically smaller than frictionVsSlip[1][1] \note longitudinal slips > frictionVsSlip[2][0] use friction multiplier frictionVsSlip[2][1] */ PxReal frictionVsSlip[3][2]; //3 (x,y) points /** \brief The rest load is the load that develops on the tire when the vehicle is at rest on a flat plane. \note The rest load is approximately the product of gravitational acceleration and (sprungMass + wheelMass). <b>Unit:</b> force = mass * length / (time^2) */ PxReal restLoad; /** \brief Tire load variation can be strongly dependent on the time-step so it is a good idea to filter it to give less jerky handling behavior. \note Tire load filtering is implemented by linear interpolating a graph containing just two points. The x-axis of the graph is normalized tire load, while the y-axis is the filtered normalized tire load that is to be applied during the tire force calculation. \note The normalized load is the force acting downwards on the tire divided by restLoad. \note The minimum possible normalized load is zero. \note There are two points on the graph: (minNormalisedLoad, minNormalisedFilteredLoad) and (maxNormalisedLoad, maxFilteredNormalisedLoad). \note Normalized loads less than minNormalisedLoad have filtered normalized load = minNormalisedFilteredLoad. \note Normalized loads greater than maxNormalisedLoad have filtered normalized load = maxFilteredNormalisedLoad. \note Normalized loads in-between are linearly interpolated between minNormalisedFilteredLoad and maxFilteredNormalisedLoad. \note The tire load applied as input to the tire force computation is the filtered normalized load multiplied by the rest load. \note loadFilter[0][0] is minNormalisedLoad \note loadFilter[0][1] is minFilteredNormalisedLoad \note loadFilter[1][0] is maxNormalisedLoad \note loadFilter[1][1] is maxFilteredNormalisedLoad */ PxReal loadFilter[2][2]; //2 (x,y) points PX_FORCE_INLINE PxVehicleTireForceParams transformAndScale( const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const { PX_UNUSED(srcFrame); PX_UNUSED(trgFrame); PxVehicleTireForceParams r = *this; const PxReal scale = trgScale.scale / srcScale.scale; r.latStiffY *= scale; r.longStiff *= scale; r.camberStiff *= scale; r.restLoad *= scale; return r; } PX_FORCE_INLINE bool isValid() const { PX_CHECK_AND_RETURN_VAL(latStiffX >= 0, "PxVehicleTireForceParams.latStiffX must be greater than or equal to zero", false); PX_CHECK_AND_RETURN_VAL(latStiffY > 0, "PxVehicleTireForceParams.latStiffY must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(longStiff > 0, "PxVehicleTireForceParams.longStiff must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(camberStiff >= 0, "PxVehicleTireForceParams.camberStiff must be greater than or equal zero", false); PX_CHECK_AND_RETURN_VAL(restLoad > 0, "PxVehicleTireForceParams.restLoad must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(loadFilter[1][0] >= loadFilter[0][0], "PxVehicleTireForceParams.loadFilter[1][0] must be greater than or equal to PxVehicleTireForceParams.loadFilter[0][0]", false); PX_CHECK_AND_RETURN_VAL(loadFilter[1][1] > 0, "PxVehicleTireLoadFilterData.loadFilter[1][1] must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(0.0f == loadFilter[0][0], "PxVehicleTireLoadFilterData.loadFilter[0][0] must be equal to zero", false); PX_CHECK_AND_RETURN_VAL(frictionVsSlip[0][0] >= 0.0f && frictionVsSlip[0][1] >= 0.0f, "Illegal values for frictionVsSlip[0]", false); PX_CHECK_AND_RETURN_VAL(frictionVsSlip[1][0] >= 0.0f && frictionVsSlip[1][1] >= 0.0f, "Illegal values for frictionVsSlip[1]", false); PX_CHECK_AND_RETURN_VAL(frictionVsSlip[2][0] >= 0.0f && frictionVsSlip[2][1] >= 0.0f, "Illegal values for frictionVsSlip[2]", false); return true; } }; #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
7,983
C
46.808383
191
0.759614
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/tire/PxVehicleTireStates.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "foundation/PxVec3.h" #include "foundation/PxMemory.h" #include "vehicle2/PxVehicleParams.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif /** \brief PxVehicleTireDirectionState stores the world frame lateral and longtidinal axes of the tire after projecting the wheel pose in the world frame onto the road geometry plane (also in the world frame). */ struct PxVehicleTireDirectionState { PxVec3 directions[PxVehicleTireDirectionModes::eMAX_NB_PLANAR_DIRECTIONS]; PX_FORCE_INLINE void setToDefault() { PxMemZero(this, sizeof(PxVehicleTireDirectionState)); } }; /** \brief PxVehicleTireSpeedState stores the components of the instantaneous velocity of the rigid body at the tire contact point projected along the lateral and longitudinal axes of the tire. @see PxVehicleTireDirectionState */ struct PxVehicleTireSpeedState { PxReal speedStates[PxVehicleTireDirectionModes::eMAX_NB_PLANAR_DIRECTIONS]; PX_FORCE_INLINE void setToDefault() { PxMemZero(this, sizeof(PxVehicleTireSpeedState)); } }; /** \brief The lateral and longitudinal tire slips. @see PxVehicleTireSpeedState */ struct PxVehicleTireSlipState { PxReal slips[PxVehicleTireDirectionModes::eMAX_NB_PLANAR_DIRECTIONS]; PX_FORCE_INLINE void setToDefault() { PxMemZero(this, sizeof(PxVehicleTireSlipState)); } }; /** \brief The load and friction experienced by a tire. */ struct PxVehicleTireGripState { /** \brief The tire load <b>Unit:</b> force = mass * length / (time^2) */ PxReal load; /** \brief The tire friction is the product of the road geometry friction and a friction response multiplier. */ PxReal friction; PX_FORCE_INLINE void setToDefault() { PxMemZero(this, sizeof(PxVehicleTireGripState)); } }; /** \brief Camber angle of the tire relative to the ground plane. */ struct PxVehicleTireCamberAngleState { PxReal camberAngle; PX_FORCE_INLINE void setToDefault() { PxMemZero(this, sizeof(PxVehicleTireCamberAngleState)); } }; /** \brief Prolonged low speeds in the lateral and longitudinal directions may be handled with "sticky" velocity constraints that activate after a speed below a threshold has been recorded for a threshold time. @see PxVehicleTireStickyParams @see PxVehicleTireSpeedState */ struct PxVehicleTireStickyState { PxReal lowSpeedTime[PxVehicleTireDirectionModes::eMAX_NB_PLANAR_DIRECTIONS]; bool activeStatus[PxVehicleTireDirectionModes::eMAX_NB_PLANAR_DIRECTIONS]; PX_FORCE_INLINE void setToDefault() { PxMemZero(this, sizeof(PxVehicleTireStickyState)); } }; /** \brief The longitudinal/lateral forces/torques that develop on the tire. */ struct PxVehicleTireForce { /* \brief The tire forces that develop along the tire's longitudinal and lateral directions. Specified in the world frame. */ PxVec3 forces[PxVehicleTireDirectionModes::eMAX_NB_PLANAR_DIRECTIONS]; /* \brief The tire torques that develop around the tire's longitudinal and lateral directions. Specified in the world frame. */ PxVec3 torques[PxVehicleTireDirectionModes::eMAX_NB_PLANAR_DIRECTIONS]; /** \brief The aligning moment may be propagated to a torque-driven steering controller. */ PxReal aligningMoment; /** \brief The torque to apply to the wheel's 1d rigid body. */ PxReal wheelTorque; PX_FORCE_INLINE void setToDefault() { PxMemZero(this, sizeof(PxVehicleTireForce)); } }; #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
5,186
C
27.5
140
0.76668
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/tire/PxVehicleTireComponents.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "vehicle2/PxVehicleParams.h" #include "vehicle2/PxVehicleComponent.h" #include "vehicle2/commands/PxVehicleCommandHelpers.h" #include "vehicle2/roadGeometry/PxVehicleRoadGeometryState.h" #include "vehicle2/suspension/PxVehicleSuspensionParams.h" #include "vehicle2/suspension/PxVehicleSuspensionStates.h" #include "vehicle2/wheel/PxVehicleWheelStates.h" #include "vehicle2/wheel/PxVehicleWheelParams.h" #include "vehicle2/wheel/PxVehicleWheelHelpers.h" #include "PxVehicleTireFunctions.h" #include "PxVehicleTireParams.h" #include "common/PxProfileZone.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif class PxVehicleTireComponent : public PxVehicleComponent { public: PxVehicleTireComponent() : PxVehicleComponent() {} virtual ~PxVehicleTireComponent() {} virtual void getDataForTireComponent( const PxVehicleAxleDescription*& axleDescription, PxVehicleArrayData<const PxReal>& steerResponseStates, const PxVehicleRigidBodyState*& rigidBodyState, PxVehicleArrayData<const PxVehicleWheelActuationState>& actuationStates, PxVehicleArrayData<const PxVehicleWheelParams>& wheelParams, PxVehicleArrayData<const PxVehicleSuspensionParams>& suspensionParams, PxVehicleArrayData<const PxVehicleTireForceParams>& tireForceParams, PxVehicleArrayData<const PxVehicleRoadGeometryState>& roadGeomStates, PxVehicleArrayData<const PxVehicleSuspensionState>& suspensionStates, PxVehicleArrayData<const PxVehicleSuspensionComplianceState>& suspensionComplianceStates, PxVehicleArrayData<const PxVehicleSuspensionForce>& suspensionForces, PxVehicleArrayData<const PxVehicleWheelRigidBody1dState>& wheelRigidBody1DStates, PxVehicleArrayData<PxVehicleTireGripState>& tireGripStates, PxVehicleArrayData<PxVehicleTireDirectionState>& tireDirectionStates, PxVehicleArrayData<PxVehicleTireSpeedState>& tireSpeedStates, PxVehicleArrayData<PxVehicleTireSlipState>& tireSlipStates, PxVehicleArrayData<PxVehicleTireCamberAngleState>& tireCamberAngleStates, PxVehicleArrayData<PxVehicleTireStickyState>& tireStickyStates, PxVehicleArrayData<PxVehicleTireForce>& tireForces) = 0; virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context) { PX_PROFILE_ZONE("PxVehicleTireComponent::update", 0); const PxVehicleAxleDescription* axleDescription; PxVehicleArrayData<const PxReal> steerResponseStates; const PxVehicleRigidBodyState* rigidBodyState; PxVehicleArrayData<const PxVehicleWheelActuationState> actuationStates; PxVehicleArrayData<const PxVehicleWheelParams> wheelParams; PxVehicleArrayData<const PxVehicleSuspensionParams> suspensionParams; PxVehicleArrayData<const PxVehicleTireForceParams> tireForceParams; PxVehicleArrayData<const PxVehicleRoadGeometryState> roadGeomStates; PxVehicleArrayData<const PxVehicleSuspensionState> suspensionStates; PxVehicleArrayData<const PxVehicleSuspensionComplianceState> suspensionComplianceStates; PxVehicleArrayData<const PxVehicleSuspensionForce> suspensionForces; PxVehicleArrayData<const PxVehicleWheelRigidBody1dState> wheelRigidBody1DStates; PxVehicleArrayData<PxVehicleTireGripState> tireGripStates; PxVehicleArrayData<PxVehicleTireDirectionState> tireDirectionStates; PxVehicleArrayData<PxVehicleTireSpeedState> tireSpeedStates; PxVehicleArrayData<PxVehicleTireSlipState> tireSlipStates; PxVehicleArrayData<PxVehicleTireCamberAngleState> tireCamberAngleStates; PxVehicleArrayData<PxVehicleTireStickyState> tireStickyStates; PxVehicleArrayData<PxVehicleTireForce> tireForces; getDataForTireComponent(axleDescription, steerResponseStates, rigidBodyState, actuationStates, wheelParams, suspensionParams, tireForceParams, roadGeomStates, suspensionStates, suspensionComplianceStates, suspensionForces, wheelRigidBody1DStates, tireGripStates, tireDirectionStates, tireSpeedStates, tireSlipStates, tireCamberAngleStates, tireStickyStates, tireForces); for (PxU32 i = 0; i < axleDescription->nbWheels; i++) { const PxU32 wheelId = axleDescription->wheelIdsInAxleOrder[i]; const bool isWheelOnGround = PxVehicleIsWheelOnGround(suspensionStates[wheelId]); //Compute the tire slip directions PxVehicleTireDirsUpdate( suspensionParams[wheelId], steerResponseStates[wheelId], roadGeomStates[wheelId].plane.n, isWheelOnGround, suspensionComplianceStates[wheelId], *rigidBodyState, context.frame, tireDirectionStates[wheelId]); //Compute the rigid body speeds along the tire slip directions. PxVehicleTireSlipSpeedsUpdate( wheelParams[wheelId], suspensionParams[wheelId], steerResponseStates[wheelId], suspensionStates[wheelId], tireDirectionStates[wheelId], *rigidBodyState, roadGeomStates[wheelId], context.frame, tireSpeedStates[wheelId]); //Compute the tire slip angles. PxVehicleTireSlipsUpdate( wheelParams[wheelId], context.tireSlipParams, actuationStates[wheelId], tireSpeedStates[wheelId], wheelRigidBody1DStates[wheelId], tireSlipStates[wheelId]); //Update the camber angle PxVehicleTireCamberAnglesUpdate( suspensionParams[wheelId], steerResponseStates[wheelId], roadGeomStates[wheelId].plane.n, isWheelOnGround, suspensionComplianceStates[wheelId], *rigidBodyState, context.frame, tireCamberAngleStates[wheelId]); //Compute the friction PxVehicleTireGripUpdate( tireForceParams[wheelId], roadGeomStates[wheelId].friction, isWheelOnGround, suspensionForces[wheelId], tireSlipStates[wheelId], tireGripStates[wheelId]); //Update the tire sticky state // //Note: this should be skipped if tires do not use the sticky feature PxVehicleTireStickyStateUpdate( *axleDescription, wheelParams[wheelId], context.tireStickyParams, actuationStates, tireGripStates[wheelId], tireSpeedStates[wheelId], wheelRigidBody1DStates[wheelId], dt, tireStickyStates[wheelId]); //If sticky tire is active set the slip angle to zero. // //Note: this should be skipped if tires do not use the sticky feature PxVehicleTireSlipsAccountingForStickyStatesUpdate( tireStickyStates[wheelId], tireSlipStates[wheelId]); //Compute the tire forces PxVehicleTireForcesUpdate( wheelParams[wheelId], suspensionParams[wheelId], tireForceParams[wheelId], suspensionComplianceStates[wheelId], tireGripStates[wheelId], tireDirectionStates[wheelId], tireSlipStates[wheelId], tireCamberAngleStates[wheelId], *rigidBodyState, tireForces[wheelId]); } return true; } }; /** * @deprecated */ class PX_DEPRECATED PxVehicleLegacyTireComponent : public PxVehicleComponent { public: PxVehicleLegacyTireComponent() : PxVehicleComponent() {} virtual ~PxVehicleLegacyTireComponent() {} virtual void getDataForLegacyTireComponent( const PxVehicleAxleDescription*& axleDescription, PxVehicleArrayData<const PxReal>& steerResponseStates, const PxVehicleRigidBodyState*& rigidBodyState, PxVehicleArrayData<const PxVehicleWheelActuationState>& actuationStates, PxVehicleArrayData<const PxVehicleWheelParams>& wheelParams, PxVehicleArrayData<const PxVehicleSuspensionParams>& suspensionParams, PxVehicleArrayData<const PxVehicleTireForceParams>& tireForceParams, PxVehicleArrayData<const PxVehicleRoadGeometryState>& roadGeomStates, PxVehicleArrayData<const PxVehicleSuspensionState>& suspensionStates, PxVehicleArrayData<const PxVehicleSuspensionComplianceState>& suspensionComplianceStates, PxVehicleArrayData<const PxVehicleSuspensionForce>& suspensionForces, PxVehicleArrayData<const PxVehicleWheelRigidBody1dState>& wheelRigidBody1DStates, PxVehicleArrayData<PxVehicleTireGripState>& tireGripStates, PxVehicleArrayData<PxVehicleTireDirectionState>& tireDirectionStates, PxVehicleArrayData<PxVehicleTireSpeedState>& tireSpeedStates, PxVehicleArrayData<PxVehicleTireSlipState>& tireSlipStates, PxVehicleArrayData<PxVehicleTireCamberAngleState>& tireCamberAngleStates, PxVehicleArrayData<PxVehicleTireStickyState>& tireStickyStates, PxVehicleArrayData<PxVehicleTireForce>& tireForces) = 0; virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context) { PX_PROFILE_ZONE("PxVehicleLegacyTireComponent::update", 0); const PxVehicleAxleDescription* axleDescription; PxVehicleArrayData<const PxReal> steerResponseStates; const PxVehicleRigidBodyState* rigidBodyState; PxVehicleArrayData<const PxVehicleWheelActuationState> actuationStates; PxVehicleArrayData<const PxVehicleWheelParams> wheelParams; PxVehicleArrayData<const PxVehicleSuspensionParams> suspensionParams; PxVehicleArrayData<const PxVehicleTireForceParams> tireForceParams; PxVehicleArrayData<const PxVehicleRoadGeometryState> roadGeomStates; PxVehicleArrayData<const PxVehicleSuspensionState> suspensionStates; PxVehicleArrayData<const PxVehicleSuspensionComplianceState> suspensionComplianceStates; PxVehicleArrayData<const PxVehicleSuspensionForce> suspensionForces; PxVehicleArrayData<const PxVehicleWheelRigidBody1dState> wheelRigidBody1DStates; PxVehicleArrayData<PxVehicleTireGripState> tireGripStates; PxVehicleArrayData<PxVehicleTireDirectionState> tireDirectionStates; PxVehicleArrayData<PxVehicleTireSpeedState> tireSpeedStates; PxVehicleArrayData<PxVehicleTireSlipState> tireSlipStates; PxVehicleArrayData<PxVehicleTireCamberAngleState> tireCamberAngleStates; PxVehicleArrayData<PxVehicleTireStickyState> tireStickyStates; PxVehicleArrayData<PxVehicleTireForce> tireForces; getDataForLegacyTireComponent(axleDescription, steerResponseStates, rigidBodyState, actuationStates, wheelParams, suspensionParams, tireForceParams, roadGeomStates, suspensionStates, suspensionComplianceStates, suspensionForces, wheelRigidBody1DStates, tireGripStates, tireDirectionStates, tireSpeedStates, tireSlipStates, tireCamberAngleStates, tireStickyStates, tireForces); for (PxU32 i = 0; i < axleDescription->nbWheels; i++) { const PxU32 wheelId = axleDescription->wheelIdsInAxleOrder[i]; const bool isWheelOnGround = roadGeomStates[wheelId].hitState; // note: since this is the legacy component, PxVehicleIsWheelOnGround() is not used // here //Compute the tire slip directions PxVehicleTireDirsLegacyUpdate( suspensionParams[wheelId], steerResponseStates[wheelId], roadGeomStates[wheelId], *rigidBodyState, context.frame, tireDirectionStates[wheelId]); //Compute the rigid body speeds along the tire slip directions. PxVehicleTireSlipSpeedsUpdate( wheelParams[wheelId], suspensionParams[wheelId], steerResponseStates[wheelId], suspensionStates[wheelId], tireDirectionStates[wheelId], *rigidBodyState, roadGeomStates[wheelId], context.frame, tireSpeedStates[wheelId]); //Compute the tire slip angles. PxVehicleTireSlipsLegacyUpdate( wheelParams[wheelId], context.tireSlipParams, actuationStates[wheelId], tireSpeedStates[wheelId], wheelRigidBody1DStates[wheelId], tireSlipStates[wheelId]); //Update the camber angle PxVehicleTireCamberAnglesUpdate( suspensionParams[wheelId], steerResponseStates[wheelId], roadGeomStates[wheelId].plane.n, isWheelOnGround, suspensionComplianceStates[wheelId], *rigidBodyState, context.frame, tireCamberAngleStates[wheelId]); //Compute the friction PxVehicleTireGripUpdate( tireForceParams[wheelId], roadGeomStates[wheelId].friction, PxVehicleIsWheelOnGround(suspensionStates[wheelId]), suspensionForces[wheelId], tireSlipStates[wheelId], tireGripStates[wheelId]); // note: PxVehicleIsWheelOnGround() used here to reflect previous behavior since this is // the legacy component after all //Update the tire sticky state // //Note: this should be skipped if tires do not use the sticky feature PxVehicleTireStickyStateUpdate( *axleDescription, wheelParams[wheelId], context.tireStickyParams, actuationStates, tireGripStates[wheelId], tireSpeedStates[wheelId], wheelRigidBody1DStates[wheelId], dt, tireStickyStates[wheelId]); //If sticky tire is active set the slip angle to zero. // //Note: this should be skipped if tires do not use the sticky feature PxVehicleTireSlipsAccountingForStickyStatesUpdate( tireStickyStates[wheelId], tireSlipStates[wheelId]); //Compute the tire forces PxVehicleTireForcesUpdate( wheelParams[wheelId], suspensionParams[wheelId], tireForceParams[wheelId], suspensionComplianceStates[wheelId], tireGripStates[wheelId], tireDirectionStates[wheelId], tireSlipStates[wheelId], tireCamberAngleStates[wheelId], *rigidBodyState, tireForces[wheelId]); } return true; } }; #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
14,559
C
41.080925
91
0.807542
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/tire/PxVehicleTireFunctions.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "foundation/PxSimpleTypes.h" #include "vehicle2/PxVehicleParams.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif struct PxVehicleSuspensionParams; struct PxVehicleRoadGeometryState; struct PxVehicleRigidBodyState; struct PxVehicleTireDirectionState; struct PxVehicleSuspensionComplianceState; struct PxVehicleWheelParams; struct PxVehicleTireSpeedState; struct PxVehicleWheelActuationState; struct PxVehicleWheelRigidBody1dState; struct PxVehicleTireSlipState; struct PxVehicleSuspensionState; struct PxVehicleTireCamberAngleState; struct PxVehicleTireGripState; struct PxVehicleTireForceParams; struct PxVehicleSuspensionForce; struct PxVehicleTireForce; struct PxVehicleTireStickyState; /** \brief Compute the longitudinal and lateral tire directions in the ground plane. \param[in] suspensionParams describes the frame of the suspension and wheel. \param[in] steerAngle is the steer angle in radians to be applied to the wheel. \param[in] roadGeometryState describes the plane of the road geometry under the wheel \param[in] rigidBodyState describes the current pose of the vehicle's rigid body in the world frame. \param[in] frame is a description of the vehicle's lateral and longitudinal axes. \param[out] tireDirectionState is the computed tire longitudinal and lateral directions in the world frame. \note PxVehicleTireDirsLegacyUpdate replicates the tire direction calculation of PhysX 5.0 and earlier. @deprecated */ PX_DEPRECATED void PxVehicleTireDirsLegacyUpdate (const PxVehicleSuspensionParams& suspensionParams, const PxReal steerAngle, const PxVehicleRoadGeometryState& roadGeometryState, const PxVehicleRigidBodyState& rigidBodyState, const PxVehicleFrame& frame, PxVehicleTireDirectionState& tireDirectionState); /** \brief Compute the longitudinal and lateral tire directions in the ground plane. \param[in] suspensionParams describes the frame of the suspension and wheel. \param[in] steerAngle is the steer angle in radians to be applied to the wheel. \param[in] groundNormal describes the plane normal of the road geometry under the wheel. \param[in] isWheelOnGround defines whether the wheel touches the road geometry. \param[in] complianceState is a description of the camber and toe angle that arise from suspension compliance. \param[in] rigidBodyState describes the current pose of the vehicle's rigid body in the world frame. \param[in] frame is a description of the vehicle's lateral and longitudinal axes. \param[out] tireDirectionState is the computed tire longitudinal and lateral directions in the world frame. \note The difference between PxVehicleTireDirsUpdate and PxVehicleTireDirsLegacyUpdate is that PxVehicleTireDirsUpdate accounts for suspension compliance while PxVehicleTireDirsLegacyUpdate does not. */ void PxVehicleTireDirsUpdate (const PxVehicleSuspensionParams& suspensionParams, const PxReal steerAngle, const PxVec3& groundNormal, bool isWheelOnGround, const PxVehicleSuspensionComplianceState& complianceState, const PxVehicleRigidBodyState& rigidBodyState, const PxVehicleFrame& frame, PxVehicleTireDirectionState& tireDirectionState); /** \brief Project the rigid body velocity at the tire contact point along the tire longitudinal directions. \param[in] wheelParams is a description of the wheel's radius and half-width. \param[in] suspensionParams describes the frame of the suspension and wheel. \param[in] steerAngle is the steer angle in radians to be applied to the wheel. \param[in] suspensionStates is the current suspension compression state. \param[in] tireDirectionState is the tire's longitudinal and lateral directions in the ground plane. \param[in] rigidBodyState describes the current pose and velocity of the vehicle's rigid body in the world frame. \param[in] roadGeometryState describes the current velocity of the road geometry under each wheel. \param[in] frame is a description of the vehicle's lateral and longitudinal axes. \param[out] tireSpeedState is the components of rigid body velocity at the tire contact point along the tire's longitudinal and lateral axes. @see PxVehicleTireDirsUpdate @see PxVehicleTireDirsLegacyUpdate */ void PxVehicleTireSlipSpeedsUpdate (const PxVehicleWheelParams& wheelParams, const PxVehicleSuspensionParams& suspensionParams, const PxF32 steerAngle, const PxVehicleSuspensionState& suspensionStates, const PxVehicleTireDirectionState& tireDirectionState, const PxVehicleRigidBodyState& rigidBodyState, const PxVehicleRoadGeometryState& roadGeometryState, const PxVehicleFrame& frame, PxVehicleTireSpeedState& tireSpeedState); /** \brief Compute a tire's longitudinal and lateral slip angles. \param[in] wheelParams describes the radius of the wheel. \param[in] tireSlipParams describes how to manage small longitudinal speeds by setting minimum values on the denominator of the quotients used to calculate lateral and longitudinal slip. \param[in] actuationState describes whether a wheel is to be driven by a drive torque or not. \param[in] tireSpeedState is the component of rigid body velocity at the tire contact point projected along the tire's longitudinal and lateral axes. \param[in] wheelRigidBody1dState is the wheel rotation speed. \param[out] tireSlipState is the computed tire longitudinal and lateral slips. \note Longitudinal slip angle has the following theoretical form: (wheelRotationSpeed*wheelRadius - longitudinalSpeed)/|longitudinalSpeed| \note Lateral slip angle has the following theoretical form: atan(lateralSpeed/|longitudinalSpeed|) \note The calculation of both longitudinal and lateral slip angles avoid a zero denominator using minimum values for the denominator set in tireSlipParams. */ void PxVehicleTireSlipsUpdate (const PxVehicleWheelParams& wheelParams, const PxVehicleTireSlipParams& tireSlipParams, const PxVehicleWheelActuationState& actuationState, PxVehicleTireSpeedState& tireSpeedState, const PxVehicleWheelRigidBody1dState& wheelRigidBody1dState, PxVehicleTireSlipState& tireSlipState); /** @deprecated \brief Compute a tire's longitudinal and lateral slip angles. \param[in] wheelParams describes the radius of the wheel. \param[in] tireSlipParams describes how to manage small longitudinal speeds by setting minimum values on the denominator of the quotients used to calculate lateral and longitudinal slip. \param[in] actuationState describes whether a wheel is to be driven by a drive torque or not. \param[in] tireSpeedState is the component of rigid body velocity at the tire contact point projected along the tire's longitudinal and lateral axes. \param[in] wheelRigidBody1dState is the wheel rotation speed. \param[out] tireSlipState is the computed tire longitudinal and lateral slips. \note Longitudinal slip angle has the following theoretical form: (wheelRotationSpeed*wheelRadius - longitudinalSpeed)/|longitudinalSpeed| \note Lateral slip angle has the following theoretical form: atan(lateralSpeed/|longitudinalSpeed|) \note The calculation of both longitudinal and lateral slip angles avoid a zero denominator using minimum values for the denominator set in tireSlipParams. */ void PX_DEPRECATED PxVehicleTireSlipsLegacyUpdate (const PxVehicleWheelParams& wheelParams, const PxVehicleTireSlipParams& tireSlipParams, const PxVehicleWheelActuationState& actuationState, PxVehicleTireSpeedState& tireSpeedState, const PxVehicleWheelRigidBody1dState& wheelRigidBody1dState, PxVehicleTireSlipState& tireSlipState); /** \brief Compute the camber angle of the wheel \param[in] suspensionParams describes the frame of the suspension and wheel. \param[in] steerAngle is the steer angle in radians to be applied to the wheel. \param[in] groundNormal describes the plane normal of the road geometry under the wheel. \param[in] isWheelOnGround defines whether the wheel touches the road geometry. \param[in] complianceState is a description of the camber and toe angle that arise from suspension compliance. \param[in] rigidBodyState describes the current pose of the vehicle's rigid body in the world frame. \param[in] frame is a description of the vehicle's lateral and longitudinal axes. \param[out] tireCamberAngleState is the computed camber angle of the tire expressed in radians. */ void PxVehicleTireCamberAnglesUpdate (const PxVehicleSuspensionParams& suspensionParams, const PxReal steerAngle, const PxVec3& groundNormal, bool isWheelOnGround, const PxVehicleSuspensionComplianceState& complianceState, const PxVehicleRigidBodyState& rigidBodyState, const PxVehicleFrame& frame, PxVehicleTireCamberAngleState& tireCamberAngleState); /** \brief Compute the load and friction experienced by the tire. \param[in] tireForceParams describes the tire's friction response to longitudinal lip angle and its load response. \param[in] frictionCoefficient describes the friction coefficient for the tire and road geometry pair. \param[in] isWheelOnGround defines whether the wheel touches the road geometry. \param[in] suspensionForce is the force that the suspension exerts on the sprung mass of the suspension. \param[in] tireSlipState is the tire longitudinal and lateral slip angles. \param[out] tireGripState is the computed load and friction experienced by the tire. \note If the suspension cannot place the wheel on the ground the tire load and friction will be 0.0. */ void PxVehicleTireGripUpdate (const PxVehicleTireForceParams& tireForceParams, PxReal frictionCoefficient, bool isWheelOnGround, const PxVehicleSuspensionForce& suspensionForce, const PxVehicleTireSlipState& tireSlipState, PxVehicleTireGripState& tireGripState); /** \brief When a tire has been at a very low speed for a threshold time without application of drive torque, a secondary tire model is applied to bring the tire to rest using velocity constraints that asymptotically approach zero speed along the tire's lateral and longitudinal directions. This secondary tire model is referred to as the sticky tire model and the tire is considered to be in the sticky tire state when the speed and time conditions are satisfied. The purpose of PxVehicleTireStickyStateUpdate is to compute the target speeds of the sticky state and to record whether sticky state is active or not. \param[in] axleDescription is the axles of the vehicle and the wheels on each axle. \param[in] wheelParams describes the radius of the wheel \param[in] tireStickyParams describe the threshold speeds and times for the lateral and longitudinal sticky states. \param[in] actuationStates describes whether each wheel experiences a drive torque. \param[in] tireGripState is the load and friction experienced by the tire. \param[in] tireSpeedState is the component of rigid body velocity at the tire contact point projected along the tire's longitudinal and lateral axes. \param[in] wheelRigidBody1dState is the wheel rotation speed. \param[in] dt is the simulation time that has lapsed since the last call to PxVehicleTireStickyStateUpdate \param[out] tireStickyState is a description of the sticky state of the tire in the longitudinal and lateral directions. \note The velocity constraints are maintained through integration with the PhysX scene using the function PxVehiclePhysXConstraintStatesUpdate. Alternative implementations independent of PhysX are possible. @see PxVehiclePhysXConstraintStatesUpdate @see PxVehicleTireSlipsAccountingForStickyStatesUpdate */ void PxVehicleTireStickyStateUpdate (const PxVehicleAxleDescription& axleDescription, const PxVehicleWheelParams& wheelParams, const PxVehicleTireStickyParams& tireStickyParams, const PxVehicleArrayData<const PxVehicleWheelActuationState>& actuationStates, const PxVehicleTireGripState& tireGripState, const PxVehicleTireSpeedState& tireSpeedState, const PxVehicleWheelRigidBody1dState& wheelRigidBody1dState, const PxReal dt, PxVehicleTireStickyState& tireStickyState); /** \brief Set the tire longitudinal and lateral slip values to 0.0 in the event that the tire has entred tire sticky state. This is necessary to avoid both tire models being simultaneously active and interfering with each other. \param[in] tireStickyState is a description of the sticky state of the tire in the longitudinal and lateral directions. \param[out] tireSlipState is the updated lateral and longudinal slip with either set to 0.0 in the event that the correspoinding sticky state is active. \note This function should not be invoked if there is no subsequent component to implement the sticky tire model. */ void PxVehicleTireSlipsAccountingForStickyStatesUpdate (const PxVehicleTireStickyState& tireStickyState, PxVehicleTireSlipState& tireSlipState); /** \brief Compute the longitudinal and lateral forces in the world frame that develop on the tire as a consequence of the tire's slip angles, friction and load. \param[in] wheelParams describes the radius and half-width of the wheel. \param[in] suspensionParams describes the frame of the suspension and wheel. \param[in] tireForceParams describes the conversion of slip angle, friction and load to a force along the longitudinal and lateral directions of the tire. \param[in] complianceState is a description of the camber and toe angle that arise from suspension compliance. \param[out] tireGripState is the load and friction experienced by the tire. \param[in] tireDirectionState is the tire's longitudinal and lateral directions in the ground plane. \param[in] tireSlipState is the longitudinal and lateral slip angles. \param[in] tireCamberAngleState is the camber angle of the tire expressed in radians. \param[in] rigidBodyState describes the current pose of the vehicle's rigid body in the world frame. \param[out] tireForce is the computed tire forces in the world frame. */ void PxVehicleTireForcesUpdate (const PxVehicleWheelParams& wheelParams, const PxVehicleSuspensionParams& suspensionParams, const PxVehicleTireForceParams& tireForceParams, const PxVehicleSuspensionComplianceState& complianceState, const PxVehicleTireGripState& tireGripState, const PxVehicleTireDirectionState& tireDirectionState, const PxVehicleTireSlipState& tireSlipState, const PxVehicleTireCamberAngleState& tireCamberAngleState, const PxVehicleRigidBodyState& rigidBodyState, PxVehicleTireForce& tireForce); #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
16,040
C
57.543795
154
0.824813
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/drivetrain/PxVehicleDrivetrainComponents.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "vehicle2/PxVehicleFunctions.h" #include "vehicle2/PxVehicleParams.h" #include "vehicle2/PxVehicleComponent.h" #include "vehicle2/braking/PxVehicleBrakingFunctions.h" #include "vehicle2/commands/PxVehicleCommandHelpers.h" #include "vehicle2/rigidBody/PxVehicleRigidBodyStates.h" #include "vehicle2/steering/PxVehicleSteeringFunctions.h" #include "vehicle2/steering/PxVehicleSteeringParams.h" #include "vehicle2/wheel/PxVehicleWheelStates.h" #include "vehicle2/wheel/PxVehicleWheelParams.h" #include "vehicle2/tire/PxVehicleTireStates.h" #include "PxVehicleDrivetrainStates.h" #include "PxVehicleDrivetrainFunctions.h" #include "common/PxProfileZone.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif struct PxVehicleBrakeCommandResponseParams; struct PxVehicleDirectDriveThrottleCommandResponseParams; /** \brief Forward the applicable set of control values for a direct drive vehicle to a command response state for each applicable control value. \note The applicable control values are brake, handbrake, throttle and steer. @see PxVehicleDirectDriveActuationStateComponent @see PxVehicleDirectDrivetrainComponent @see PxVehicleBrakeCommandLinearUpdate @see PxVehicleDirectDriveThrottleLinearCommandUpdate @see PxVehicleSteerCommandLinearUpdate @see PxVehicleAckermannSteerUpdate */ class PxVehicleDirectDriveCommandResponseComponent : public PxVehicleComponent { public: PxVehicleDirectDriveCommandResponseComponent() : PxVehicleComponent() {} virtual ~PxVehicleDirectDriveCommandResponseComponent() {} /** \brief Provide vehicle data items for this component. \param[out] axleDescription identifies the wheels on each axle. \param[out] brakeResponseParams An array of brake response parameters with a brake response for each brake command. \param[out] throttleResponseParams The throttle response parameters. \param[out] steerResponseParams The steer response parameters. \param[out] ackermannParams The parameters defining Ackermann steering. NULL if no Ackermann steering is desired. \param[out] commands The throttle, brake, steer etc. command states. \param[out] transmissionCommands The transmission command state describing the current gear. \param[out] rigidBodyState The state of the vehicle's rigid body. \param[out] brakeResponseStates The resulting brake response states given the command input and brake response parameters. \param[out] throttleResponseStates The resulting throttle response states given the command input and throttle response parameters. \param[out] steerResponseStates The resulting steer response states given the command input, steer response and (optionally) Ackermann parameters. */ virtual void getDataForDirectDriveCommandResponseComponent( const PxVehicleAxleDescription*& axleDescription, PxVehicleSizedArrayData<const PxVehicleBrakeCommandResponseParams>& brakeResponseParams, const PxVehicleDirectDriveThrottleCommandResponseParams*& throttleResponseParams, const PxVehicleSteerCommandResponseParams*& steerResponseParams, PxVehicleSizedArrayData<const PxVehicleAckermannParams>& ackermannParams, const PxVehicleCommandState*& commands, const PxVehicleDirectDriveTransmissionCommandState*& transmissionCommands, const PxVehicleRigidBodyState*& rigidBodyState, PxVehicleArrayData<PxReal>& brakeResponseStates, PxVehicleArrayData<PxReal>& throttleResponseStates, PxVehicleArrayData<PxReal>& steerResponseStates) = 0; /** \brief Compute a per wheel response to the input brake/handbrake/throttle/steer commands and determine if there is an intention to accelerate the vehicle. */ virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context) { PX_UNUSED(dt); PX_UNUSED(context); PX_PROFILE_ZONE("PxVehicleDirectDriveCommandResponseComponent::update", 0); const PxVehicleAxleDescription* axleDescription; PxVehicleSizedArrayData<const PxVehicleBrakeCommandResponseParams> brakeResponseParams; const PxVehicleDirectDriveThrottleCommandResponseParams* throttleResponseParams; const PxVehicleSteerCommandResponseParams* steerResponseParams; PxVehicleSizedArrayData<const PxVehicleAckermannParams> ackermannParams; const PxVehicleCommandState* commands; const PxVehicleDirectDriveTransmissionCommandState* transmissionCommands; const PxVehicleRigidBodyState* rigidBodyState; PxVehicleArrayData<PxReal> brakeResponseStates; PxVehicleArrayData<PxReal> throttleResponseStates; PxVehicleArrayData<PxReal> steerResponseStates; getDataForDirectDriveCommandResponseComponent(axleDescription, brakeResponseParams, throttleResponseParams, steerResponseParams, ackermannParams, commands, transmissionCommands, rigidBodyState, brakeResponseStates, throttleResponseStates, steerResponseStates); const PxReal longitudinalSpeed = rigidBodyState->getLongitudinalSpeed(context.frame); for (PxU32 i = 0; i < axleDescription->nbWheels; i++) { const PxU32 wheelId = axleDescription->wheelIdsInAxleOrder[i]; PxVehicleBrakeCommandResponseUpdate( commands->brakes, commands->nbBrakes, longitudinalSpeed, wheelId, brakeResponseParams, brakeResponseStates[wheelId]); PxVehicleDirectDriveThrottleCommandResponseUpdate( commands->throttle, *transmissionCommands, longitudinalSpeed, wheelId, *throttleResponseParams, throttleResponseStates[wheelId]); PxVehicleSteerCommandResponseUpdate( commands->steer, longitudinalSpeed, wheelId, *steerResponseParams, steerResponseStates[wheelId]); } if (ackermannParams.size > 0) PxVehicleAckermannSteerUpdate( commands->steer, *steerResponseParams, ackermannParams, steerResponseStates); return true; } }; /** \brief Determine the actuation state for each wheel of a direct drive vehicle. \note The actuation state for each wheel contains a binary record of whether brake and drive torque are to be applied to the wheel. @see PxVehicleDirectDriveCommandResponseComponent @see PxVehicleDirectDrivetrainComponent @see PxVehicleDirectDriveActuationStateUpdate */ class PxVehicleDirectDriveActuationStateComponent : public PxVehicleComponent { public: PxVehicleDirectDriveActuationStateComponent() : PxVehicleComponent() {} virtual ~PxVehicleDirectDriveActuationStateComponent() {} /** \brief Provide vehicle data items for this component. \param[out] axleDescription identifies the wheels on each axle. \param[out] brakeResponseStates The brake response states. \param[out] throttleResponseStates The throttle response states. \param[out] actuationStates The actuation states. */ virtual void getDataForDirectDriveActuationStateComponent( const PxVehicleAxleDescription*& axleDescription, PxVehicleArrayData<const PxReal>& brakeResponseStates, PxVehicleArrayData<const PxReal>& throttleResponseStates, PxVehicleArrayData<PxVehicleWheelActuationState>& actuationStates) = 0; /** \brief Compute the actuation state for each wheel given the brake, handbrake and throttle states. \*/ virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context) { PX_UNUSED(dt); PX_UNUSED(context); PX_PROFILE_ZONE("PxVehicleDirectDriveActuationStateComponent::update", 0); const PxVehicleAxleDescription* axleDescription; PxVehicleArrayData<const PxReal> brakeResponseStates; PxVehicleArrayData<const PxReal> throttleResponseStates; PxVehicleArrayData<PxVehicleWheelActuationState> actuationStates; getDataForDirectDriveActuationStateComponent( axleDescription, brakeResponseStates, throttleResponseStates, actuationStates); for (PxU32 i = 0; i < axleDescription->nbWheels; i++) { const PxU32 wheelId = axleDescription->wheelIdsInAxleOrder[i]; PxVehicleDirectDriveActuationStateUpdate( brakeResponseStates[wheelId], throttleResponseStates[wheelId], actuationStates[wheelId]); } return true; } }; /** \brief Forward integrate the angular speed of each wheel on a vehicle by integrating the brake and drive torque applied to each wheel and the torque that develops on the tire as a response to the longitudinal tire force. @see PxVehicleDirectDriveUpdate */ class PxVehicleDirectDrivetrainComponent : public PxVehicleComponent { public: PxVehicleDirectDrivetrainComponent() : PxVehicleComponent() {} virtual ~PxVehicleDirectDrivetrainComponent() {} virtual void getDataForDirectDrivetrainComponent( const PxVehicleAxleDescription*& axleDescription, PxVehicleArrayData<const PxReal>& brakeResponseStates, PxVehicleArrayData<const PxReal>& throttleResponseStates, PxVehicleArrayData<const PxVehicleWheelParams>& wheelParams, PxVehicleArrayData<const PxVehicleWheelActuationState>& actuationStates, PxVehicleArrayData<const PxVehicleTireForce>& tireForces, PxVehicleArrayData<PxVehicleWheelRigidBody1dState>& wheelRigidBody1dStates) = 0; virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context) { PX_UNUSED(context); PX_PROFILE_ZONE("PxVehicleDirectDrivetrainComponent::update", 0); const PxVehicleAxleDescription* axleDescription; PxVehicleArrayData<const PxReal> brakeResponseStates; PxVehicleArrayData<const PxReal> throttleResponseStates; PxVehicleArrayData<const PxVehicleWheelParams> wheelParams; PxVehicleArrayData<const PxVehicleWheelActuationState> actuationStates; PxVehicleArrayData<const PxVehicleTireForce> tireForces; PxVehicleArrayData<PxVehicleWheelRigidBody1dState> wheelRigidBody1dStates; getDataForDirectDrivetrainComponent(axleDescription, brakeResponseStates, throttleResponseStates, wheelParams, actuationStates, tireForces, wheelRigidBody1dStates); for (PxU32 i = 0; i < axleDescription->nbWheels; i++) { const PxU32 wheelId = axleDescription->wheelIdsInAxleOrder[i]; PxVehicleDirectDriveUpdate( wheelParams[wheelId], actuationStates[wheelId], brakeResponseStates[wheelId], throttleResponseStates[wheelId], tireForces[wheelId], dt, wheelRigidBody1dStates[wheelId]); } return true; } }; /** \brief Forward the applicable set of control values for a vehicle driven by an engine to a command response state for each applicable control value. If parameters for an autobox are provided, the autobox will determine if a gear change should begin in order to maintain a desired engine revs. @see PxVehicleBrakeCommandLinearUpdate @see PxVehicleClutchCommandResponseLinearUpdate @see PxVehicleEngineDriveThrottleCommandResponseUpdate @see PxVehicleSteerCommandLinearUpdate @see PxVehicleAckermannSteerUpdate @see PxVehicleAutoBoxUpdate @see PxVehicleGearCommandResponseUpdate */ class PxVehicleEngineDriveCommandResponseComponent : public PxVehicleComponent { public: PxVehicleEngineDriveCommandResponseComponent() : PxVehicleComponent() {} virtual ~PxVehicleEngineDriveCommandResponseComponent() {} /** \brief Provide vehicle data items for this component. \param[out] axleDescription identifies the wheels on each axle. \param[out] brakeResponseParams An array of brake response parameters with a brake response for each brake command. \param[out] steerResponseParams The steer response parameters. \param[out] ackermannParams The parameters defining Ackermann steering. NULL if no Ackermann steering is desired. \param[out] gearboxParams The gearbox parameters. \param[out] clutchResponseParams The clutch response parameters. \param[out] engineParams The engine parameters. Only needed if an autobox is provided (see autoboxParams), else it can be set to NULL. \param[out] engineState The engine state. Only needed if an autobox is provided (see autoboxParams), else it can be set to NULL. \param[out] autoboxParams The autobox parameters. If not NULL, the autobox will determine the target gear. Requires the parameters engineParams, engineState and autoboxState to be available. If no autobox is desired, NULL can be used in which case the aforementioned additional parameters can be set to NULL too. \param[out] rigidBodyState The state of the vehicle's rigid body. \param[out] commands The throttle, brake, steer etc. command states. \param[out] transmissionCommands The clutch, target gear etc. command states. If an autobox is provided (see autoboxParams) and the target gear is set to PxVehicleEngineDriveTransmissionCommandState::eAUTOMATIC_GEAR, then the autobox will trigger gear shifts. \param[out] brakeResponseStates The resulting brake response states given the command input and brake response parameters. \param[out] throttleResponseState The resulting throttle response to the input throttle command. \param[out] steerResponseStates The resulting steer response states given the command input, steer response and (optionally) Ackermann parameters. \param[out] gearboxResponseState The resulting gearbox response state given the command input and gearbox parameters. \param[out] clutchResponseState The resulting clutch state given the command input and clutch response parameters. \param[out] autoboxState The resulting autobox state given the autobox/engine/gear params and engine state. Only needed if an autobox is provided (see autoboxParams), else it can be set to NULL. */ virtual void getDataForEngineDriveCommandResponseComponent( const PxVehicleAxleDescription*& axleDescription, PxVehicleSizedArrayData<const PxVehicleBrakeCommandResponseParams>& brakeResponseParams, const PxVehicleSteerCommandResponseParams*& steerResponseParams, PxVehicleSizedArrayData<const PxVehicleAckermannParams>& ackermannParams, const PxVehicleGearboxParams*& gearboxParams, const PxVehicleClutchCommandResponseParams*& clutchResponseParams, const PxVehicleEngineParams*& engineParams, const PxVehicleRigidBodyState*& rigidBodyState, const PxVehicleEngineState*& engineState, const PxVehicleAutoboxParams*& autoboxParams, const PxVehicleCommandState*& commands, const PxVehicleEngineDriveTransmissionCommandState*& transmissionCommands, PxVehicleArrayData<PxReal>& brakeResponseStates, PxVehicleEngineDriveThrottleCommandResponseState*& throttleResponseState, PxVehicleArrayData<PxReal>& steerResponseStates, PxVehicleGearboxState*& gearboxResponseState, PxVehicleClutchCommandResponseState*& clutchResponseState, PxVehicleAutoboxState*& autoboxState) = 0; virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context) { PX_UNUSED(dt); PX_UNUSED(context); PX_PROFILE_ZONE("PxVehicleEngineDriveCommandResponseComponent::update", 0); const PxVehicleAxleDescription* axleDescription; PxVehicleSizedArrayData<const PxVehicleBrakeCommandResponseParams> brakeResponseParams; const PxVehicleSteerCommandResponseParams* steerResponseParams; PxVehicleSizedArrayData<const PxVehicleAckermannParams> ackermannParams; const PxVehicleGearboxParams* gearboxParams; const PxVehicleClutchCommandResponseParams* clutchResponseParams; const PxVehicleEngineParams* engineParams; const PxVehicleRigidBodyState* rigidBodyState; const PxVehicleEngineState* engineState; const PxVehicleAutoboxParams* autoboxParams; const PxVehicleCommandState* commands; const PxVehicleEngineDriveTransmissionCommandState* transmissionCommands; PxVehicleArrayData<PxReal> brakeResponseStates; PxVehicleEngineDriveThrottleCommandResponseState* throttleResponseState; PxVehicleArrayData<PxReal> steerResponseStates; PxVehicleGearboxState* gearboxResponseState; PxVehicleClutchCommandResponseState* clutchResponseState; PxVehicleAutoboxState* autoboxState; getDataForEngineDriveCommandResponseComponent(axleDescription, brakeResponseParams, steerResponseParams, ackermannParams, gearboxParams, clutchResponseParams, engineParams, rigidBodyState, engineState, autoboxParams, commands, transmissionCommands, brakeResponseStates, throttleResponseState, steerResponseStates, gearboxResponseState, clutchResponseState, autoboxState); //The autobox can modify commands like throttle and target gear. Since the user defined //values should not be overwritten, a copy is used to compute the response. PxVehicleCommandState commandsTmp = *commands; PxVehicleEngineDriveTransmissionCommandState transmissionCommandsTmp = *transmissionCommands; const PxReal longitudinalSpeed = rigidBodyState->getLongitudinalSpeed(context.frame); //Let the autobox set the target gear, unless the user defined target gear requests //a shift already if (autoboxParams) { PX_ASSERT(engineParams); PX_ASSERT(engineState); PX_ASSERT(autoboxState); PxVehicleAutoBoxUpdate( *engineParams, *gearboxParams, *autoboxParams, *engineState, *gearboxResponseState, dt, transmissionCommandsTmp.targetGear, *autoboxState, commandsTmp.throttle); } else if (transmissionCommandsTmp.targetGear == PxVehicleEngineDriveTransmissionCommandState::eAUTOMATIC_GEAR) { //If there is no autobox but eAUTOMATIC_GEAR was specified, use the current target gear transmissionCommandsTmp.targetGear = gearboxResponseState->targetGear; } //Distribute brake torque to the wheels across each axle. for (PxU32 i = 0; i < axleDescription->nbWheels; i++) { const PxU32 wheelId = axleDescription->wheelIdsInAxleOrder[i]; PxVehicleBrakeCommandResponseUpdate( commandsTmp.brakes, commandsTmp.nbBrakes, longitudinalSpeed, wheelId, brakeResponseParams, brakeResponseStates[i]); } //Update target gear as required. PxVehicleGearCommandResponseUpdate( transmissionCommandsTmp.targetGear, *gearboxParams, *gearboxResponseState); //Compute the response to the clutch command. PxVehicleClutchCommandResponseLinearUpdate( transmissionCommandsTmp.clutch, *clutchResponseParams, *clutchResponseState); //Compute the response to the throttle command. PxVehicleEngineDriveThrottleCommandResponseLinearUpdate( commandsTmp, *throttleResponseState); //Update the steer angles and Ackermann correction. for (PxU32 i = 0; i < axleDescription->nbWheels; i++) { const PxU32 wheelId = axleDescription->wheelIdsInAxleOrder[i]; PxVehicleSteerCommandResponseUpdate(commandsTmp.steer, longitudinalSpeed, wheelId, *steerResponseParams, steerResponseStates[i]); } if (ackermannParams.size > 0) PxVehicleAckermannSteerUpdate(commandsTmp.steer, *steerResponseParams, ackermannParams, steerResponseStates); return true; } }; /** \brief Compute the per wheel drive torque split of a multi-wheel drive differential. @see PxVehicleDifferentialStateUpdate */ class PxVehicleMultiWheelDriveDifferentialStateComponent : public PxVehicleComponent { public: PxVehicleMultiWheelDriveDifferentialStateComponent() : PxVehicleComponent() {} virtual ~PxVehicleMultiWheelDriveDifferentialStateComponent() {} virtual void getDataForMultiWheelDriveDifferentialStateComponent( const PxVehicleAxleDescription*& axleDescription, const PxVehicleMultiWheelDriveDifferentialParams*& differentialParams, PxVehicleDifferentialState*& differentialState) = 0; virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context) { PX_UNUSED(dt); PX_UNUSED(context); PX_PROFILE_ZONE("PxVehicleMultiWheelDriveDifferentialStateComponent::update", 0); const PxVehicleAxleDescription* axleDescription; const PxVehicleMultiWheelDriveDifferentialParams* differentialParams; PxVehicleDifferentialState* differentialState; getDataForMultiWheelDriveDifferentialStateComponent(axleDescription, differentialParams, differentialState); PxVehicleDifferentialStateUpdate( *axleDescription, *differentialParams, *differentialState); return true; } }; /** \brief Compute the per wheel drive torque split of a differential delivering torque to multiple wheels with limited slip applied to specified wheel pairs. @see PxVehicleDifferentialStateUpdate */ class PxVehicleFourWheelDriveDifferentialStateComponent : public PxVehicleComponent { public: PxVehicleFourWheelDriveDifferentialStateComponent() : PxVehicleComponent() {} virtual ~PxVehicleFourWheelDriveDifferentialStateComponent() {} virtual void getDataForFourWheelDriveDifferentialStateComponent( const PxVehicleAxleDescription*& axleDescription, const PxVehicleFourWheelDriveDifferentialParams*& differentialParams, PxVehicleArrayData<const PxVehicleWheelRigidBody1dState>& wheelRigidbody1dStates, PxVehicleDifferentialState*& differentialState, PxVehicleWheelConstraintGroupState*& wheelConstraintGroupState) = 0; virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context) { PX_UNUSED(dt); PX_UNUSED(context); PX_PROFILE_ZONE("PxVehicleFourWheelDriveDifferentialStateComponent::update", 0); const PxVehicleAxleDescription* axleDescription; const PxVehicleFourWheelDriveDifferentialParams* differentialParams; PxVehicleArrayData<const PxVehicleWheelRigidBody1dState> wheelRigidbody1dStates; PxVehicleDifferentialState* differentialState; PxVehicleWheelConstraintGroupState* wheelConstraintGroupState; getDataForFourWheelDriveDifferentialStateComponent(axleDescription, differentialParams, wheelRigidbody1dStates, differentialState, wheelConstraintGroupState); PxVehicleDifferentialStateUpdate( *axleDescription, *differentialParams, wheelRigidbody1dStates, dt, *differentialState, *wheelConstraintGroupState); return true; } }; /** \brief Compute the per wheel drive torque split of a tank drive differential. @see PxVehicleDifferentialStateUpdate */ class PxVehicleTankDriveDifferentialStateComponent : public PxVehicleComponent { public: PxVehicleTankDriveDifferentialStateComponent() : PxVehicleComponent() {} virtual ~PxVehicleTankDriveDifferentialStateComponent() {} /** \brief Provide vehicle data items for this component. \param[out] axleDescription identifies the wheels on each axle. \param[out] transmissionCommands specifies the values of the thrust controllers that divert torque to the tank tracks. \param[out] wheelParams is an array describing the radius of each wheel. \param[out] differentialParams describes the operation of the tank differential by specifying the default torque split between all wheels connected to the differential and by specifying the wheels coupled to each tank track. \param[out] differentialState stores the instantaneous torque split between all wheels arising from the difference between the thrust controllers. \param[out] constraintGroupState stores the groups of wheels that are connected by sharing a tank track. */ virtual void getDataForTankDriveDifferentialStateComponent( const PxVehicleAxleDescription*& axleDescription, const PxVehicleTankDriveTransmissionCommandState*& transmissionCommands, PxVehicleArrayData<const PxVehicleWheelParams>& wheelParams, const PxVehicleTankDriveDifferentialParams*& differentialParams, PxVehicleDifferentialState*& differentialState, PxVehicleWheelConstraintGroupState*& constraintGroupState) = 0; virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context) { PX_UNUSED(dt); PX_UNUSED(context); PX_PROFILE_ZONE("PxVehicleTankDriveDifferentialStateComponent::update", 0); const PxVehicleAxleDescription* axleDescription; const PxVehicleTankDriveTransmissionCommandState* transmissionCommands; PxVehicleArrayData<const PxVehicleWheelParams> wheelParams; const PxVehicleTankDriveDifferentialParams* differentialParams; PxVehicleDifferentialState* differentialState; PxVehicleWheelConstraintGroupState* constraintGroupState; getDataForTankDriveDifferentialStateComponent( axleDescription, transmissionCommands, wheelParams, differentialParams, differentialState, constraintGroupState); PxVehicleDifferentialStateUpdate( *axleDescription, wheelParams, *differentialParams, transmissionCommands->thrusts[0], transmissionCommands->thrusts[1], *differentialState, *constraintGroupState); return true; } }; /** @deprecated \brief Compute the per wheel drive torque split of a four wheel drive differential. @see PxVehicleDifferentialStateUpdate */ class PX_DEPRECATED PxVehicleLegacyFourWheelDriveDifferentialStateComponent : public PxVehicleComponent { public: PxVehicleLegacyFourWheelDriveDifferentialStateComponent() : PxVehicleComponent() {} virtual ~PxVehicleLegacyFourWheelDriveDifferentialStateComponent() {} virtual void getDataForLegacyFourWheelDriveDifferentialStateComponent( const PxVehicleAxleDescription*& axleDescription, const PxVehicleFourWheelDriveDifferentialLegacyParams*& differentialParams, PxVehicleArrayData<const PxVehicleWheelRigidBody1dState>& wheelRigidbody1dStates, PxVehicleDifferentialState*& differentialState) = 0; virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context) { PX_UNUSED(dt); PX_UNUSED(context); PX_PROFILE_ZONE("PxVehicleLegacyFourWheelDriveDifferentialStateComponent::update", 0); const PxVehicleAxleDescription* axleDescription; const PxVehicleFourWheelDriveDifferentialLegacyParams* differentialParams; PxVehicleArrayData<const PxVehicleWheelRigidBody1dState> wheelRigidbody1dStates; PxVehicleDifferentialState* differentialState; getDataForLegacyFourWheelDriveDifferentialStateComponent(axleDescription, differentialParams, wheelRigidbody1dStates, differentialState); PxVehicleDifferentialStateUpdate( *differentialParams, wheelRigidbody1dStates, *differentialState); return true; } }; /** \brief Determine the actuation state for each wheel for a vehicle propelled by engine torque. \note The actuation state for each wheel contains a binary record of whether brake and drive torque are to be applied to the wheel. @see PxVehicleEngineDriveActuationStateUpdate */ class PxVehicleEngineDriveActuationStateComponent : public PxVehicleComponent { public: PxVehicleEngineDriveActuationStateComponent() : PxVehicleComponent() {} virtual ~PxVehicleEngineDriveActuationStateComponent() {} virtual void getDataForEngineDriveActuationStateComponent( const PxVehicleAxleDescription*& axleDescription, const PxVehicleGearboxParams*& gearboxParams, PxVehicleArrayData<const PxReal>& brakeResponseStates, const PxVehicleEngineDriveThrottleCommandResponseState*& throttleResponseState, const PxVehicleGearboxState*& gearboxState, const PxVehicleDifferentialState*& differentialState, const PxVehicleClutchCommandResponseState*& clutchResponseState, PxVehicleArrayData<PxVehicleWheelActuationState>& actuationStates) = 0; virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context) { PX_UNUSED(dt); PX_UNUSED(context); PX_PROFILE_ZONE("PxVehicleEngineDriveActuationStateComponent::update", 0); const PxVehicleAxleDescription* axleDescription; const PxVehicleGearboxParams* gearboxParams; PxVehicleArrayData<const PxReal> brakeResponseStates; const PxVehicleEngineDriveThrottleCommandResponseState* throttleResponseState; const PxVehicleGearboxState* gearboxState; const PxVehicleDifferentialState* differentialState; const PxVehicleClutchCommandResponseState* clutchResponseState; PxVehicleArrayData<PxVehicleWheelActuationState> actuationStates; getDataForEngineDriveActuationStateComponent(axleDescription, gearboxParams, brakeResponseStates, throttleResponseState, gearboxState, differentialState, clutchResponseState, actuationStates); PxVehicleEngineDriveActuationStateUpdate( *axleDescription, *gearboxParams, brakeResponseStates, *throttleResponseState, *gearboxState, *differentialState, *clutchResponseState, actuationStates); return true; } }; /** \brief Forward integrate the angular speed of each wheel and of the engine, accounting for the state of the clutch, gearbox and differential. @see PxVehicleGearboxUpdate @see PxVehicleEngineDrivetrainUpdate */ class PxVehicleEngineDrivetrainComponent : public PxVehicleComponent { public: PxVehicleEngineDrivetrainComponent() : PxVehicleComponent() {} virtual ~PxVehicleEngineDrivetrainComponent() {} /** \brief Provide vehicle data items for this component. \param[out] axleDescription identifies the wheels on each axle. \param[out] wheelParams specifies the radius of each wheel. \param[out] engineParams specifies the engine's torque curve, idle revs and max revs. \param[out] clutchParams specifies the maximum strength of the clutch. \param[out] gearboxParams specifies the gear ratio of each gear. \param[out] brakeResponseStates stores the instantaneous brake brake torque to apply to each wheel. \param[out] actuationStates stores whether a brake and/or drive torque are to be applied to each wheel. \param[out] tireForces stores the lateral and longitudinal tire force that has developed on each tire. \param[out] throttleResponseState stores the response of the throttle to the input throttle command. \param[out] clutchResponseState stores the instantaneous clutch strength that arises from the input clutch command. \param[out] differentialState stores the instantaneous torque split between the wheels. \param[out] constraintGroupState stores the groups of wheels that are subject to constraints that require them to have the same angular or linear velocity. \param[out] wheelRigidBody1dStates stores the per wheel angular speed to be computed by the component. \param[out] engineState stores the engine rotation speed to be computed by the component. \param[out] gearboxState stores the state of the gearbox to be computed by the component. \param[out] clutchState stores the clutch slip to be computed by the component. \note If constraintGroupState is set to NULL it is assumed that there are no requirements for any wheels to have the same angular or linear velocity. */ virtual void getDataForEngineDrivetrainComponent( const PxVehicleAxleDescription*& axleDescription, PxVehicleArrayData<const PxVehicleWheelParams>& wheelParams, const PxVehicleEngineParams*& engineParams, const PxVehicleClutchParams*& clutchParams, const PxVehicleGearboxParams*& gearboxParams, PxVehicleArrayData<const PxReal>& brakeResponseStates, PxVehicleArrayData<const PxVehicleWheelActuationState>& actuationStates, PxVehicleArrayData<const PxVehicleTireForce>& tireForces, const PxVehicleEngineDriveThrottleCommandResponseState*& throttleResponseState, const PxVehicleClutchCommandResponseState*& clutchResponseState, const PxVehicleDifferentialState*& differentialState, const PxVehicleWheelConstraintGroupState*& constraintGroupState, PxVehicleArrayData<PxVehicleWheelRigidBody1dState>& wheelRigidBody1dStates, PxVehicleEngineState*& engineState, PxVehicleGearboxState*& gearboxState, PxVehicleClutchSlipState*& clutchState) = 0; virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context) { PX_UNUSED(context); PX_PROFILE_ZONE("PxVehicleEngineDrivetrainComponent::update", 0); const PxVehicleAxleDescription* axleDescription; PxVehicleArrayData<const PxVehicleWheelParams> wheelParams; const PxVehicleEngineParams* engineParams; const PxVehicleClutchParams* clutchParams; const PxVehicleGearboxParams* gearboxParams; PxVehicleArrayData<const PxReal> brakeResponseStates; PxVehicleArrayData<const PxVehicleWheelActuationState> actuationStates; PxVehicleArrayData<const PxVehicleTireForce> tireForces; const PxVehicleEngineDriveThrottleCommandResponseState* throttleResponseState; const PxVehicleClutchCommandResponseState* clutchResponseState; const PxVehicleDifferentialState* differentialState; const PxVehicleWheelConstraintGroupState* constraintGroupState; PxVehicleArrayData<PxVehicleWheelRigidBody1dState> wheelRigidBody1dStates; PxVehicleEngineState* engineState; PxVehicleGearboxState* gearboxState; PxVehicleClutchSlipState* clutchState; getDataForEngineDrivetrainComponent(axleDescription, wheelParams, engineParams, clutchParams, gearboxParams, brakeResponseStates, actuationStates, tireForces, throttleResponseState, clutchResponseState, differentialState, constraintGroupState, wheelRigidBody1dStates, engineState, gearboxState, clutchState); PxVehicleGearboxUpdate(*gearboxParams, dt, *gearboxState); PxVehicleEngineDrivetrainUpdate( *axleDescription, wheelParams, *engineParams, *clutchParams, *gearboxParams, brakeResponseStates, actuationStates, tireForces, *gearboxState, *throttleResponseState, *clutchResponseState, *differentialState, constraintGroupState, dt, wheelRigidBody1dStates, *engineState, *clutchState); return true; } }; #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
34,285
C
41.697385
156
0.822109
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/drivetrain/PxVehicleDrivetrainStates.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "vehicle2/commands/PxVehicleCommandStates.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif struct PxVehicleClutchCommandResponseState { PxReal normalisedCommandResponse; PxReal commandResponse; PX_FORCE_INLINE void setToDefault() { PxMemZero(this, sizeof(PxVehicleClutchCommandResponseState)); } }; struct PxVehicleEngineDriveThrottleCommandResponseState { PxReal commandResponse; PX_FORCE_INLINE void setToDefault() { PxMemZero(this, sizeof(PxVehicleEngineDriveThrottleCommandResponseState)); } }; struct PxVehicleEngineState { /** \brief The rotation speed of the engine (radians per second). <b>Unit:</b> radians / time */ PxReal rotationSpeed; PX_FORCE_INLINE void setToDefault() { PxMemZero(this, sizeof(PxVehicleEngineState)); } }; #define PX_VEHICLE_NO_GEAR_SWITCH_PENDING -1.0f #define PX_VEHICLE_GEAR_SWITCH_INITIATED -2.0f struct PxVehicleGearboxState { /** \brief Current gear */ PxU32 currentGear; /** \brief Target gear (different from current gear if a gear change is underway) */ PxU32 targetGear; /** \brief Reported time that has passed since gear change started. The special value PX_VEHICLE_NO_GEAR_SWITCH_PENDING denotes that there is currently no gear change underway. If a gear switch was initiated, the special value PX_VEHICLE_GEAR_SWITCH_INITIATED will be used temporarily but get translated to 0 in the gearbox update immediately. This state might only get encountered, if the vehicle component update is split into multiple sequences that do not run in one go. <b>Unit:</b> time */ PxReal gearSwitchTime; PX_FORCE_INLINE void setToDefault() { currentGear = 0; targetGear = 0; gearSwitchTime = PX_VEHICLE_NO_GEAR_SWITCH_PENDING; } }; #define PX_VEHICLE_UNSPECIFIED_TIME_SINCE_LAST_SHIFT PX_MAX_F32 struct PxVehicleAutoboxState { /** \brief Time that has lapsed since the last autobox gear shift. <b>Unit:</b> time */ PxReal timeSinceLastShift; /** \brief Describes whether a gear shift triggered by the autobox is still in flight. */ bool activeAutoboxGearShift; PX_FORCE_INLINE void setToDefault() { timeSinceLastShift = PX_VEHICLE_UNSPECIFIED_TIME_SINCE_LAST_SHIFT; activeAutoboxGearShift = false; } }; struct PxVehicleDifferentialState { /** \brief A list of wheel indices that are connected to the differential. */ PxU32 connectedWheels[PxVehicleLimits::eMAX_NB_WHEELS]; /** \brief The number of wheels that are connected to the differential. */ PxU32 nbConnectedWheels; /** \brief The fraction of available torque that is delivered to each wheel through the differential. \note If a wheel is not connected to the differential then the fraction of available torque delivered to that wheel will be zero. \note A negative torque ratio for a wheel indicates a negative gearing is to be applied to that wheel. \note The sum of the absolute value of each fraction must equal 1.0. */ PxReal torqueRatiosAllWheels[PxVehicleLimits::eMAX_NB_WHEELS]; /** \brief The contribution of each wheel to the average wheel rotation speed measured at the clutch. \note If a wheel is not connected to the differential then the contribution to the average rotation speed measured at the clutch must be zero. \note The sum of all contributions must equal 1.0. */ PxReal aveWheelSpeedContributionAllWheels[PxVehicleLimits::eMAX_NB_WHEELS]; PX_FORCE_INLINE void setToDefault() { PxMemZero(this, sizeof(PxVehicleDifferentialState)); } }; /** \brief Specify groups of wheels that are to be constrained to have pre-determined angular velocity relationship. */ struct PxVehicleWheelConstraintGroupState { PX_FORCE_INLINE void setToDefault() { PxMemZero(this, sizeof(PxVehicleWheelConstraintGroupState)); } /** \brief Add a wheel constraint group by specifying the number of wheels in the group, an array of wheel ids specifying each wheel in the group and a desired rotational speed relationship. \param[in] nbWheelsInGroupToAdd is the number of wheels in the group to be added. \param[in] wheelIdsInGroupToAdd is an array of wheel ids specifying all the wheels in the group to be added. \param[in] constraintMultipliers is an array of constraint multipliers describing the desired relationship of the wheel rotational speeds. \note constraintMultipliers[j] specifies the target rotational speed of the jth wheel in the constraint group as a multiplier of the rotational speed of the zeroth wheel in the group. */ void addConstraintGroup(const PxU32 nbWheelsInGroupToAdd, const PxU32* const wheelIdsInGroupToAdd, const PxF32* constraintMultipliers) { PX_ASSERT((nbWheelsInGroups + nbWheelsInGroupToAdd) < PxVehicleLimits::eMAX_NB_WHEELS); PX_ASSERT(nbGroups < PxVehicleLimits::eMAX_NB_WHEELS); nbWheelsPerGroup[nbGroups] = nbWheelsInGroupToAdd; groupToWheelIds[nbGroups] = nbWheelsInGroups; for (PxU32 i = 0; i < nbWheelsInGroupToAdd; i++) { wheelIdsInGroupOrder[nbWheelsInGroups + i] = wheelIdsInGroupToAdd[i]; wheelMultipliersInGroupOrder[nbWheelsInGroups + i] = constraintMultipliers[i]; } nbWheelsInGroups += nbWheelsInGroupToAdd; nbGroups++; } /** \brief Return the number of wheel constraint groups in the vehicle. \return The number of wheel constraint groups. @see getNbWheelsInConstraintGroup() */ PX_FORCE_INLINE PxU32 getNbConstraintGroups() const { return nbGroups; } /** \brief Return the number of wheels in the ith constraint group. \param[in] i specifies the constraint group to be queried for its wheel count. \return The number of wheels in the specified constraint group. @see getWheelInConstraintGroup() */ PX_FORCE_INLINE PxU32 getNbWheelsInConstraintGroup(const PxU32 i) const { return nbWheelsPerGroup[i]; } /** \brief Return the wheel id of the jth wheel in the ith constraint group. \param[in] j specifies that the wheel id to be returned is the jth wheel in the list of wheels on the specified constraint group. \param[in] i specifies the constraint group to be queried. \return The wheel id of the jth wheel in the ith constraint group. @see getNbWheelsInConstraintGroup() */ PX_FORCE_INLINE PxU32 getWheelInConstraintGroup(const PxU32 j, const PxU32 i) const { return wheelIdsInGroupOrder[groupToWheelIds[i] + j]; } /** \brief Return the constraint multiplier of the jth wheel in the ith constraint group \param[in] j specifies that the wheel id to be returned is the jth wheel in the list of wheels on the specified constraint group. \param[in] i specifies the constraint group to be queried. \return The constraint multiplier of the jth wheel in the ith constraint group. */ PX_FORCE_INLINE PxReal getMultiplierInConstraintGroup(const PxU32 j, const PxU32 i) const { return wheelMultipliersInGroupOrder[groupToWheelIds[i] + j]; } PxU32 nbGroups; //!< The number of constraint groups in the vehicle PxU32 nbWheelsPerGroup[PxVehicleLimits::eMAX_NB_AXLES]; //!< The number of wheels in each group PxU32 groupToWheelIds[PxVehicleLimits::eMAX_NB_AXLES]; //!< The list of wheel ids for the ith group begins at wheelIdsInGroupOrder[groupToWheelIds[i]] PxU32 wheelIdsInGroupOrder[PxVehicleLimits::eMAX_NB_WHEELS]; //!< The list of all wheel ids in constraint groups PxF32 wheelMultipliersInGroupOrder[PxVehicleLimits::eMAX_NB_WHEELS];//!< The constraint multipliers for each constraint group. PxU32 nbWheelsInGroups; //!< The number of wheels in a constraint group. }; /** \brief The clutch is modelled as two spinning plates with one connected to the wheels through the gearing and the other connected to the engine. The clutch slip is angular speed difference of the two plates. */ struct PxVehicleClutchSlipState { /** \brief The slip at the clutch. <b>Unit:</b> radians / time */ PxReal clutchSlip; PX_FORCE_INLINE void setToDefault() { PxMemZero(this, sizeof(PxVehicleClutchSlipState)); } }; #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
9,741
C
32.709342
207
0.764603
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/drivetrain/PxVehicleDrivetrainHelpers.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "vehicle2/drivetrain/PxVehicleDrivetrainParams.h" #include "vehicle2/drivetrain/PxVehicleDrivetrainStates.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif struct PxVehicleWheelRigidBody1dState; /** \brief Compute the coupling strength of the clutch. \param[in] clutchResponseState describes the response of the clutch to the input clutch command. \param[in] gearboxParams holds the index of neutral gear. \param[in] gearboxState describes the current gear. \note If the gear is in neutral the clutch is fully disengaged and the clutch strength is 0. \note A clutch response state of 0.0 denotes a fully engaged clutch with maximum strength. \note A clutch response state of 1.0 denotes a fully disengaged clutch with a strength of 0.0. */ PX_FORCE_INLINE PxReal PxVehicleClutchStrengthCompute(const PxVehicleClutchCommandResponseState& clutchResponseState, const PxVehicleGearboxParams& gearboxParams, const PxVehicleGearboxState& gearboxState) { return (gearboxParams.neutralGear != gearboxState.currentGear) ? clutchResponseState.commandResponse : 0.0f; } /** \brief Compute the damping rate of the engine. \param[in] engineParams describes various damping rates of the engine in different operational states. \param[in] gearboxParams holds the index of neutral gear. \param[in] gearboxState describes the current gear. \param[in] clutchResponseState is the response of the clutch to the clutch command. \param[in] throttleResponseState is the response of the throttle to the throttle command. \note Engines typically have different damping rates with clutch engaged and disengaged. \note Engines typically have different damping rates at different throttle pedal values. @see PxVehicleClutchStrengthCompute() \note In neutral gear the clutch is considered to be fully disengaged. */ PX_FORCE_INLINE PxReal PxVehicleEngineDampingRateCompute (const PxVehicleEngineParams& engineParams, const PxVehicleGearboxParams& gearboxParams, const PxVehicleGearboxState& gearboxState, const PxVehicleClutchCommandResponseState& clutchResponseState, const PxVehicleEngineDriveThrottleCommandResponseState& throttleResponseState) { const PxReal K = (gearboxParams.neutralGear != gearboxState.currentGear) ? clutchResponseState.normalisedCommandResponse : 0.0f; const PxReal zeroThrottleDamping = engineParams.dampingRateZeroThrottleClutchEngaged + (1.0f - K)* (engineParams.dampingRateZeroThrottleClutchDisengaged - engineParams.dampingRateZeroThrottleClutchEngaged); const PxReal appliedThrottle = throttleResponseState.commandResponse; const PxReal fullThrottleDamping = engineParams.dampingRateFullThrottle; const PxReal engineDamping = zeroThrottleDamping + (fullThrottleDamping - zeroThrottleDamping)*appliedThrottle; return engineDamping; } /** \brief Compute the gear ratio delivered by the gearbox in the current gear. \param[in] gearboxParams describes the gear ratio of each gear and the final ratio. \param[in] gearboxState describes the current gear. \note The gear ratio is the product of the gear ratio of the current gear and the final gear ratio of the gearbox. */ PX_FORCE_INLINE PxReal PxVehicleGearRatioCompute (const PxVehicleGearboxParams& gearboxParams, const PxVehicleGearboxState& gearboxState) { const PxReal gearRatio = gearboxParams.ratios[gearboxState.currentGear] * gearboxParams.finalRatio; return gearRatio; } /** \brief Compute the drive torque to deliver to the engine. \param[in] engineParams describes the profile of maximum available torque across the full range of engine rotational speed. \param[in] engineState describes the engine rotational speed. \param[in] throttleCommandResponseState describes the engine's response to input throttle command. */ PX_FORCE_INLINE PxReal PxVehicleEngineDriveTorqueCompute (const PxVehicleEngineParams& engineParams, const PxVehicleEngineState& engineState, const PxVehicleEngineDriveThrottleCommandResponseState& throttleCommandResponseState) { const PxReal appliedThrottle = throttleCommandResponseState.commandResponse; const PxReal peakTorque = engineParams.peakTorque; const PxVehicleFixedSizeLookupTable<PxReal, PxVehicleEngineParams::eMAX_NB_ENGINE_TORQUE_CURVE_ENTRIES>& torqueCurve = engineParams.torqueCurve; const PxReal normalisedRotSpeed = engineState.rotationSpeed/engineParams.maxOmega; const PxReal engineDriveTorque = appliedThrottle*peakTorque*torqueCurve.interpolate(normalisedRotSpeed); return engineDriveTorque; } /** @deprecated \brief Compute the contribution that each wheel makes to the averaged wheel speed at the clutch plate connected to the wheels driven by the differential. \param[in] diffParams describes the wheels coupled to the differential and the operation of the torque split at the differential. \param[in] nbWheels The number of wheels. Can be larger than the number of wheels connected to the differential. \param[out] diffAveWheelSpeedContributions describes the contribution that each wheel makes to the averaged wheel speed at the clutch. The buffer needs to be sized to be able to hold at least nbWheels entries. \note Any wheel on an axle connected to the differential could have a non-zero value, depending on the way the differential couples to the wheels. \note Any wheel on an axle not connected to the differential will have a zero contribution to the averaged wheel speed. */ void PX_DEPRECATED PxVehicleLegacyDifferentialWheelSpeedContributionsCompute (const PxVehicleFourWheelDriveDifferentialLegacyParams& diffParams, const PxU32 nbWheels, PxReal* diffAveWheelSpeedContributions); /** @deprecated \brief Compute the fraction of available torque that is delivered to each wheel through the differential. \param[in] diffParams describes the wheels coupled to the differential and the operation of the torque split at the differential. \param[in] wheelOmegas describes the rotational speeds of the wheels. Is expected to have nbWheels entries. \param[in] nbWheels The number of wheels. Can be larger than the number of wheels connected to the differential. \param[out] diffTorqueRatios describes the fraction of available torque delivered to each wheel. The buffer needs to be sized to be able to hold at least nbWheels entries. \note Any wheel on an axle connected to the diff could receive a non-zero ratio, depending on the way the differential couples to the wheels. \note Any wheel not on an axle connected to the diff will have a zero value. \note The sum of all the ratios adds to 1.0. \note Slipping wheels driven by the differential will typically receive less torque than non-slipping wheels in the event that the differential has a limited slip configuration. */ void PX_DEPRECATED PxVehicleLegacyDifferentialTorqueRatiosCompute (const PxVehicleFourWheelDriveDifferentialLegacyParams& diffParams, const PxVehicleArrayData<const PxVehicleWheelRigidBody1dState>& wheelOmegas, const PxU32 nbWheels, PxReal* diffTorqueRatios); #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
8,765
C
53.447205
205
0.811067
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/drivetrain/PxVehicleDrivetrainFunctions.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "foundation/PxSimpleTypes.h" #include "vehicle2/PxVehicleParams.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif struct PxVehicleCommandState; struct PxVehicleDirectDriveTransmissionCommandState; struct PxVehicleEngineDriveTransmissionCommandState; struct PxVehicleDirectDriveThrottleCommandResponseParams; struct PxVehicleWheelActuationState; struct PxVehicleWheelParams; struct PxVehicleTireForce; struct PxVehicleWheelRigidBody1dState; struct PxVehicleEngineParams; struct PxVehicleGearboxParams; struct PxVehicleAutoboxParams; struct PxVehicleEngineState; struct PxVehicleGearboxState; struct PxVehicleAutoboxState; struct PxVehicleClutchCommandResponseParams; struct PxVehicleClutchCommandResponseState; struct PxVehicleEngineDriveThrottleCommandResponseState; struct PxVehicleDifferentialState; struct PxVehicleMultiWheelDriveDifferentialParams; struct PxVehicleFourWheelDriveDifferentialParams; struct PxVehicleTankDriveDifferentialParams; struct PxVehicleFourWheelDriveDifferentialLegacyParams; struct PxVehicleClutchParams; struct PxVehicleWheelConstraintGroupState; struct PxVehicleClutchSlipState; /** \brief Compute the drive torque response to a throttle command. \param[in] throttle is the throttle command. \param[in] transmissionCommands is the gearing command to apply to the direct drive tranmission. \param[in] longitudinalSpeed is the longitudinal speed of the vehicle's rigid body. \param[in] wheelId specifies the wheel that is to have its throttle response computed. \param[in] throttleResponseParams specifies the per wheel drive torque response to the throttle command as a nonlinear function of throttle command and longitudinal speed. \param[out] throttleResponseState is the drive torque response to the input throttle command. */ void PxVehicleDirectDriveThrottleCommandResponseUpdate (const PxReal throttle, const PxVehicleDirectDriveTransmissionCommandState& transmissionCommands, const PxReal longitudinalSpeed, const PxU32 wheelId, const PxVehicleDirectDriveThrottleCommandResponseParams& throttleResponseParams, PxReal& throttleResponseState); /** \brief Determine the actuation state of a wheel given the brake torque, handbrake torque and drive torque applied to it. \param[in] brakeTorque is the brake torque to be applied to the wheel. \param[in] driveTorque is the drive torque to be applied to the wheel. \param[out] actuationState contains a binary record of whether brake or drive torque is applied to the wheel. */ void PxVehicleDirectDriveActuationStateUpdate (const PxReal brakeTorque, const PxReal driveTorque, PxVehicleWheelActuationState& actuationState); /** \brief Forward integrate the angular speed of a wheel given the brake and drive torque applied to it \param[in] wheelParams specifies the moment of inertia of the wheel. \param[in] actuationState is a binary record of whether brake and drive torque are to be applied to the wheel. \param[in] brakeTorque is the brake torque to be applied to the wheel. \param[in] driveTorque is the drive torque to be applied to the wheel. \param[in] tireForce specifies the torque to apply to the wheel as a response to the longitudinal tire force. \param[in] dt is the timestep of the forward integration. \param[out] wheelRigidBody1dState describes the angular speed of the wheel. */ void PxVehicleDirectDriveUpdate (const PxVehicleWheelParams& wheelParams, const PxVehicleWheelActuationState& actuationState, const PxReal brakeTorque, const PxReal driveTorque, const PxVehicleTireForce& tireForce, const PxF32 dt, PxVehicleWheelRigidBody1dState& wheelRigidBody1dState); /** \param[in] engineParams specifies the engine configuration. \param[in] gearboxParams specifies the gear ratios and the time required to complete a gear change. \param[in] autoboxParams specifies the conditions for switching gear. \param[in] engineState contains the current angular speed of the engine. \param[in] gearboxState describes the current and target gear. \param[in] dt is the time that has lapsed since the last call to PxVehicleAutoBoxUpdate. \param[in,out] targetGearCommand specifies the desired target gear for the gearbox. If set to PxVehicleEngineDriveTransmissionCommandState::eAUTOMATIC_GEAR, the value will get overwritten with a target gear chosen by the autobox. \param[out] autoboxState specifies the time that has lapsed since the last automated gear change and contains a record of any ongoing automated gear change. \param[out] throttle A throttle command value in [0, 1] that will be set to 0 if a gear change is initiated or is ongoing. \note The autobox will not begin a gear change if a gear change is already ongoing. \note The autobox will not begin a gear change until a threshold time has lapsed since the last automated gear change. \note A gear change is considered as ongoing for as long as PxVehicleGearboxState::currentGear is different from PxVehicleGearboxState::targetGear. \note The autobox will not shift down from 1st gear or up from reverse gear. \note The autobox shifts in single gear increments or decrements. \note The autobox instantiates a gear change by setting PxVehicleCommandState::targetGear to be different from from PxVehicleGearboxState::currentGear */ void PxVehicleAutoBoxUpdate (const PxVehicleEngineParams& engineParams, const PxVehicleGearboxParams& gearboxParams, const PxVehicleAutoboxParams& autoboxParams, const PxVehicleEngineState& engineState, const PxVehicleGearboxState& gearboxState, const PxReal dt, PxU32& targetGearCommand, PxVehicleAutoboxState& autoboxState, PxReal& throttle); /** \brief Propagate input gear commands to the gearbox state. \param[in] targetGearCommand specifies the target gear for the gearbox. \param[in] gearboxParams specifies the number of gears and the index of neutral gear. \param[out] gearboxState contains a record of the current and target gear. \note Any ongoing gear change must complete before starting another. \note A gear change is considered as ongoing for as long as PxVehicleGearboxState::currentGear is different from PxVehicleGearboxState::targetGear. \note The gearbox remains in neutral for the duration of the gear change. \note A gear change begins if PxVehicleCommandState::targetGear is different from PxVehicleGearboxState::currentGear. */ void PxVehicleGearCommandResponseUpdate (const PxU32 targetGearCommand, const PxVehicleGearboxParams& gearboxParams, PxVehicleGearboxState& gearboxState); /** \brief Propagate the input clutch command to the clutch response state. \param[in] clutchCommand specifies the state of the clutch pedal. \param[in] clutchResponseParams specifies how the clutch responds to the input clutch command. \param[out] clutchResponse specifies the response of the clutch to the input clutch command. */ void PxVehicleClutchCommandResponseLinearUpdate (const PxReal clutchCommand, const PxVehicleClutchCommandResponseParams& clutchResponseParams, PxVehicleClutchCommandResponseState& clutchResponse); /** \brief Propagate the input throttle command to the throttle response state. \param[in] commands specifies the state of the throttle pedal. \param[out] throttleResponse specifies how the clutch responds to the input throttle command. */ void PxVehicleEngineDriveThrottleCommandResponseLinearUpdate (const PxVehicleCommandState& commands, PxVehicleEngineDriveThrottleCommandResponseState& throttleResponse); /** \brief Determine the actuation state of all wheels on a vehicle. \param[in] axleDescription is a decription of the axles of the vehicle and the wheels on each axle. \param[in] gearboxParams specifies the index of the neutral gear of the gearbox. \param[in] brakeResponseStates specifies the response of each wheel to the input brake command. \param[in] throttleResponseState specifies the response of the engine to the input throttle command. \param[in] gearboxState specifies the current gear. \param[in] diffState specifies the fraction of available drive torque to be delivered to each wheel. \param[in] clutchResponseState specifies the response of the clutch to the input throttle command. \param[out] actuationStates is an array of binary records determining whether brake and drive torque are to be applied to each wheel. \note Drive torque is not applied to a wheel if a) the gearbox is in neutral b) the differential delivers no torque to the wheel c) no throttle is applied to the engine c) the clutch is fully disengaged. */ void PxVehicleEngineDriveActuationStateUpdate (const PxVehicleAxleDescription& axleDescription, const PxVehicleGearboxParams& gearboxParams, const PxVehicleArrayData<const PxReal>& brakeResponseStates, const PxVehicleEngineDriveThrottleCommandResponseState& throttleResponseState, const PxVehicleGearboxState& gearboxState, const PxVehicleDifferentialState& diffState, const PxVehicleClutchCommandResponseState& clutchResponseState, PxVehicleArrayData<PxVehicleWheelActuationState>& actuationStates); /** @deprecated \brief Compute the fraction of available torque to be delivered to each wheel and gather a list of all wheels connected to the differential. \param[in] diffParams specifies the operation of a differential that can be connected to up to four wheels. \param[in] wheelStates describes the angular speed of each wheel \param[out] diffState contains the fraction of available drive torque to be delivered to each wheel. \note If the handbrake is on then torque is only delivered to the wheels specified as the front wheels of the differential. */ void PX_DEPRECATED PxVehicleDifferentialStateUpdate (const PxVehicleFourWheelDriveDifferentialLegacyParams& diffParams, const PxVehicleArrayData<const PxVehicleWheelRigidBody1dState>& wheelStates, PxVehicleDifferentialState& diffState); /** \brief Compute the fraction of available torque to be delivered to each wheel and gather a list of all wheels connected to the differential. Additionally, add wheel constraints for wheel pairs whose rotational speed ratio exceeds the corresponding differential bias. \param[in] axleDescription is a decription of the axles of the vehicle and the wheels on each axle. \param[in] diffParams describe the division of available drive torque and the biases of the limited slip differential. \param[in] wheelStates describes the rotational speeds of each wheel. \param[in] dt is the simulation time that has passes since the last call to PxVehicleDifferentialStateUpdate() \param[out] diffState contains the fraction of available drive torque to be delivered to each wheel. \param[out] wheelConstraintGroupState describes the groups of wheels that have exceeded their corresponding differential biases. */ void PxVehicleDifferentialStateUpdate (const PxVehicleAxleDescription& axleDescription, const PxVehicleFourWheelDriveDifferentialParams& diffParams, const PxVehicleArrayData<const PxVehicleWheelRigidBody1dState>& wheelStates, const PxReal dt, PxVehicleDifferentialState& diffState, PxVehicleWheelConstraintGroupState& wheelConstraintGroupState); /** \brief Compute the fraction of available torque to be delivered to each wheel and gather a list of all wheels connected to the differential. \param[in] axleDescription is a decription of the axles of the vehicle and the wheels on each axle. \param[in] diffParams specifies the operation of a differential that can be connected to any combination of wheels. \param[out] diffState contains the fraction of available drive torque to be delivered to each wheel connected to the differential. */ void PxVehicleDifferentialStateUpdate (const PxVehicleAxleDescription& axleDescription, const PxVehicleMultiWheelDriveDifferentialParams& diffParams, PxVehicleDifferentialState& diffState); /** \brief Compute the fraction of available torque to be delivered to each wheel and gather a list of all wheels connected to the differential. \param[in] axleDescription is a decription of the axles of the vehicle and the wheels on each axle. \param[in] wheelParams is an array that describes the wheel radius of each wheel. \param[in] diffParams specifies the operation of a tank differential. \param[in] thrustCommand0 is the state of one of the two thrust controllers. \param[in] thrustCommand1 is the state of one of the two thrust controllers. \param[out] diffState contains the fraction of available drive torque to be delivered to each wheel connected to the differential. \param[out] wheelConstraintGroupState describes the groups of wheels connected by sharing a tank track. */ void PxVehicleDifferentialStateUpdate (const PxVehicleAxleDescription& axleDescription, const PxVehicleArrayData<const PxVehicleWheelParams>& wheelParams, const PxVehicleTankDriveDifferentialParams& diffParams, const PxReal thrustCommand0, PxReal thrustCommand1, PxVehicleDifferentialState& diffState, PxVehicleWheelConstraintGroupState& wheelConstraintGroupState); /** \brief Update the current gear of the gearbox. If a gear change is ongoing then complete the gear change if a threshold time has passed since the beginning of the gear change. \param[in] gearboxParams describes the time required to complete a gear change. \param[in] dt is the time that has lapsed since the last call to PxVehicleGearboxUpdate. \param[out] gearboxState is the gearbox state to be updated. \note A gear change is considered as ongoing for as long as PxVehicleGearboxState::currentGear is different from PxVehicleGearboxState::targetGear. */ void PxVehicleGearboxUpdate (const PxVehicleGearboxParams& gearboxParams, const PxF32 dt, PxVehicleGearboxState& gearboxState); /** \brief Forward integrate the angular speed of the vehicle's wheels and engine, given the state of clutch, differential and gearbox. \param[in] axleDescription is a decription of the axles of the vehicle and the wheels on each axle. \param[in] wheelParams specifies the moment of inertia of each wheel. \param[in] engineParams specifies the torque curve of the engine and its moment of inertia. \param[in] clutchParams specifies the maximum clutch strength that happens when the clutch is fully engaged. \param[in] gearboxParams specifies the gearing ratios of the gearbox. \param[in] brakeResponseStates describes the per wheel response to the input brake command. \param[in] actuationStates is a binary record of whether brake or drive torque is applied to each wheel. \param[in] tireForces describes the torque to apply to each wheel as a response to the longitudinal tire force. \param[in] gearboxState describes the current gear. \param[in] throttleResponse describes the engine response to the input throttle pedal. \param[in] clutchResponse describes the clutch response to the input clutch pedal. \param[in] diffState describes the fraction of available drive torque to be delivered to each wheel. \param[in] constraintGroupState describes groups of wheels with rotational speed constrained to the same value. \param[in] dt is the time that has lapsed since the last call to PxVehicleEngineDrivetrainUpdate \param[out] wheelRigidbody1dStates describes the angular speed of each wheel. \param[out] engineState describes the angular speed of the engine. \param[out] clutchState describes the clutch slip. \note If constraintGroupState is NULL then it is assumed that there are no wheels subject to rotational speed constraints. */ void PxVehicleEngineDrivetrainUpdate (const PxVehicleAxleDescription& axleDescription, const PxVehicleArrayData<const PxVehicleWheelParams>& wheelParams, const PxVehicleEngineParams& engineParams, const PxVehicleClutchParams& clutchParams, const PxVehicleGearboxParams& gearboxParams, const PxVehicleArrayData<const PxReal>& brakeResponseStates, const PxVehicleArrayData<const PxVehicleWheelActuationState>& actuationStates, const PxVehicleArrayData<const PxVehicleTireForce>& tireForces, const PxVehicleGearboxState& gearboxState, const PxVehicleEngineDriveThrottleCommandResponseState& throttleResponse, const PxVehicleClutchCommandResponseState& clutchResponse, const PxVehicleDifferentialState& diffState, const PxVehicleWheelConstraintGroupState* constraintGroupState, const PxReal dt, PxVehicleArrayData<PxVehicleWheelRigidBody1dState>& wheelRigidbody1dStates, PxVehicleEngineState& engineState, PxVehicleClutchSlipState& clutchState); #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
18,099
C
55.739812
177
0.823637
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/drivetrain/PxVehicleDrivetrainParams.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "foundation/PxFoundation.h" #include "common/PxCoreUtilityTypes.h" #include "vehicle2/PxVehicleParams.h" #include "vehicle2/commands/PxVehicleCommandParams.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif /** \brief Distribute a throttle response to the wheels of a direct drive vehicle. \note The drive torque applied to each wheel on the ith axle is throttleCommand * maxResponse * wheelResponseMultipliers[i]. \note A typical use case is to set maxResponse to be the vehicle's maximum achievable drive torque that occurs when the steer command is equal to 1.0. The array wheelResponseMultipliers[i] would then be used to specify the maximum achievable drive torque per wheel as a fractional multiplier of the vehicle's maximum achievable steer angle. */ struct PxVehicleDirectDriveThrottleCommandResponseParams : public PxVehicleCommandResponseParams { PX_FORCE_INLINE PxVehicleDirectDriveThrottleCommandResponseParams transformAndScale( const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const { PX_UNUSED(srcFrame); PX_UNUSED(trgFrame); PxVehicleDirectDriveThrottleCommandResponseParams r = *this; const PxReal scale = trgScale.scale/srcScale.scale; r.maxResponse *= (scale*scale); //Max response is a torque! return r; } PX_FORCE_INLINE bool isValid(const PxVehicleAxleDescription& axleDesc) const { PX_CHECK_AND_RETURN_VAL(PxIsFinite(maxResponse), "PxVehicleDirectDriveThrottleCommandResponseParams.maxResponse must be a finite value", false); for (PxU32 i = 0; i < axleDesc.nbWheels; i++) { PX_CHECK_AND_RETURN_VAL(PxIsFinite(wheelResponseMultipliers[axleDesc.wheelIdsInAxleOrder[i]]), "PxVehicleDirectDriveThrottleCommandResponseParams.wheelResponseMultipliers[i] must be a finite value", false); } return true; } }; /** \brief Specifies the maximum clutch strength that occurs when the clutch pedal is fully disengaged and the clutch is fully engaged. */ struct PxVehicleClutchCommandResponseParams { /** \brief Strength of clutch. \note The clutch is the mechanism that couples the engine to the wheels. A stronger clutch more strongly couples the engine to the wheels, while a clutch of strength zero completely decouples the engine from the wheels. Stronger clutches more quickly bring the wheels and engine into equilibrium, while weaker clutches take longer, resulting in periods of clutch slip and delays in power transmission from the engine to the wheels. The torque generated by the clutch is proportional to the clutch strength and the velocity difference between the engine's rotational speed and the rotational speed of the driven wheels after accounting for the gear ratio. The torque at the clutch is applied negatively to the engine and positively to the driven wheels. <b>Range:</b> [0,inf)<br> <b>Unit:</b> torque * time = mass * (length^2) / time */ PxReal maxResponse; PX_FORCE_INLINE PxVehicleClutchCommandResponseParams transformAndScale( const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const { PX_UNUSED(srcFrame); PX_UNUSED(trgFrame); const PxReal scale = trgScale.scale/srcScale.scale; PxVehicleClutchCommandResponseParams r = *this; r.maxResponse *= (scale*scale); return r; } PX_FORCE_INLINE bool isValid() const { PX_CHECK_AND_RETURN_VAL(maxResponse >= 0.0f, "PxVehicleClutchCommandResponseParams.maxResponse must be greater than or equal to zero", false); return true; } }; /** \brief Choose between a potentially more expensive but more accurate solution to the clutch model or a potentially cheaper but less accurate solution. @see PxVehicleClutchParams */ struct PxVehicleClutchAccuracyMode { enum Enum { eESTIMATE = 0, eBEST_POSSIBLE }; }; /** \brief The clutch connects two plates together. One plate rotates with the speed of the engine. The second plate rotates with a weighted average of all wheels connected to the differential after accounting for the gear ratio. The difference in rotation speeds generates a restoring torque applied to engine and wheels that aims to reduce the difference in rotational speed. The restoring torque is proportional to the clutch strength and the clutch pedal position. */ struct PxVehicleClutchParams { public: /** \brief The engine and wheel rotation speeds that are coupled through the clutch can be updated by choosing one of two modes: eESTIMATE and eBEST_POSSIBLE. \note If eESTIMATE is chosen the vehicle sdk will update the wheel and engine rotation speeds with estimated values to the implemented clutch model. \note If eBEST_POSSIBLE is chosen the vehicle sdk will compute the best possible solution (within floating point tolerance) to the implemented clutch model. This is the recommended mode. \note The clutch model remains the same if either eESTIMATE or eBEST_POSSIBLE is chosen but the accuracy and computational cost of the solution to the model can be tuned as required. */ PxVehicleClutchAccuracyMode::Enum accuracyMode; /** \brief Tune the mathematical accuracy and computational cost of the computed estimate to the wheel and engine rotation speeds if eESTIMATE is chosen. \note As estimateIterations increases the computational cost of the clutch also increases and the solution approaches the solution that would be computed if eBEST_POSSIBLE was chosen instead. \note This has no effect if eBEST_POSSIBLE is chosen as the accuracy mode. \note A value of zero is not allowed if eESTIMATE is chosen as the accuracy mode. */ PxU32 estimateIterations; PX_FORCE_INLINE PxVehicleClutchParams transformAndScale( const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const { PX_UNUSED(srcFrame); PX_UNUSED(trgFrame); PX_UNUSED(srcScale); PX_UNUSED(trgScale); return *this; } PX_FORCE_INLINE bool isValid() const { PX_CHECK_AND_RETURN_VAL((PxVehicleClutchAccuracyMode::eBEST_POSSIBLE == accuracyMode) || ((PxVehicleClutchAccuracyMode::eESTIMATE == accuracyMode) && (estimateIterations > 0)), "PxVehicleClutchParams.estimateIterations must be greater than zero if PxVehicleClutchAccuracyMode::eESTIMATE is selected", false); return true; } }; struct PxVehicleEngineParams { /** \brief Maximum supported number of points in the #torqueCurve graph. */ enum { eMAX_NB_ENGINE_TORQUE_CURVE_ENTRIES = 8 }; /** \brief Graph of normalized torque (torque/#peakTorque) against normalized engine speed ( engineRotationSpeed / #maxOmega ). \note The normalized engine speed is the x-axis of the graph, while the normalized torque is the y-axis of the graph. */ PxVehicleFixedSizeLookupTable<PxReal, eMAX_NB_ENGINE_TORQUE_CURVE_ENTRIES> torqueCurve; /** \brief Moment of inertia of the engine around the axis of rotation. <b>Range:</b> (0, inf)<br> <b>Unit:</b> mass * (length^2) */ PxReal moi; /** \brief Maximum torque available to apply to the engine when the accelerator pedal is at maximum. \note The torque available is the value of the accelerator pedal (in range [0, 1]) multiplied by the normalized torque as computed from #torqueCurve multiplied by #peakTorque. <b>Range:</b> [0, inf)<br> <b>Unit:</b> mass * (length^2) / (time^2) */ PxReal peakTorque; /** \brief Minimum rotation speed of the engine. <b>Range:</b> [0, inf)<br> <b>Unit:</b> radians / time */ PxReal idleOmega; /** \brief Maximum rotation speed of the engine. <b>Range:</b> [0, inf)<br> <b>Unit:</b> radians / time */ PxReal maxOmega; /** \brief Damping rate of engine when full throttle is applied. \note If the clutch is engaged (any gear except neutral) then the damping rate applied at run-time is an interpolation between #dampingRateZeroThrottleClutchEngaged and #dampingRateFullThrottle: #dampingRateZeroThrottleClutchEngaged + (#dampingRateFullThrottle-#dampingRateZeroThrottleClutchEngaged)*acceleratorPedal; \note If the clutch is disengaged (in neutral gear) the damping rate applied at run-time is an interpolation between #dampingRateZeroThrottleClutchDisengaged and #dampingRateFullThrottle: #dampingRateZeroThrottleClutchDisengaged + (#dampingRateFullThrottle-#dampingRateZeroThrottleClutchDisengaged)*acceleratorPedal; <b>Range:</b> [0, inf)<br> <b>Unit:</b> torque * time = mass * (length^2) / time */ PxReal dampingRateFullThrottle; /** \brief Damping rate of engine when no throttle is applied and with engaged clutch. \note If the clutch is engaged (any gear except neutral) then the damping rate applied at run-time is an interpolation between #dampingRateZeroThrottleClutchEngaged and #dampingRateFullThrottle: #dampingRateZeroThrottleClutchEngaged + (#dampingRateFullThrottle-#dampingRateZeroThrottleClutchEngaged)*acceleratorPedal; \note If the clutch is disengaged (in neutral gear) the damping rate applied at run-time is an interpolation between #dampingRateZeroThrottleClutchDisengaged and #dampingRateFullThrottle: #dampingRateZeroThrottleClutchDisengaged + (#dampingRateFullThrottle-#dampingRateZeroThrottleClutchDisengaged)*acceleratorPedal; <b>Range:</b> [0, inf)<br> <b>Unit:</b> torque * time = mass * (length^2) / time */ PxReal dampingRateZeroThrottleClutchEngaged; /** \brief Damping rate of engine when no throttle is applied and with disengaged clutch. \note If the clutch is engaged (any gear except neutral) then the damping rate applied at run-time is an interpolation between #dampingRateZeroThrottleClutchEngaged and #dampingRateFullThrottle: #dampingRateZeroThrottleClutchEngaged + (#dampingRateFullThrottle-#dampingRateZeroThrottleClutchEngaged)*acceleratorPedal; \note If the clutch is disengaged (in neutral gear) the damping rate applied at run-time is an interpolation between #dampingRateZeroThrottleClutchDisengaged and #dampingRateFullThrottle: #dampingRateZeroThrottleClutchDisengaged + (#dampingRateFullThrottle-#dampingRateZeroThrottleClutchDisengaged)*acceleratorPedal; <b>Range:</b> [0, inf)<br> <b>Unit:</b> torque * time = mass * (length^2) / time */ PxReal dampingRateZeroThrottleClutchDisengaged; PX_FORCE_INLINE PxVehicleEngineParams transformAndScale( const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const { PX_UNUSED(srcFrame); PX_UNUSED(trgFrame); PxVehicleEngineParams r = *this; const PxReal scale = trgScale.scale/srcScale.scale; r.moi *= (scale*scale); r.peakTorque *= (scale*scale); r.dampingRateFullThrottle *= (scale*scale); r.dampingRateZeroThrottleClutchDisengaged *= (scale*scale); r.dampingRateZeroThrottleClutchEngaged *= (scale*scale); return r; } PX_FORCE_INLINE bool isValid() const { PX_CHECK_AND_RETURN_VAL(moi > 0.0f, "PxVehicleEngineParams.moi must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(peakTorque >= 0.0f, "PxVehicleEngineParams.peakTorque must be greater than or equal to zero", false); PX_CHECK_AND_RETURN_VAL(torqueCurve.isValid(), "PxVehicleEngineParams.torqueCurve is invalid", false); PX_CHECK_AND_RETURN_VAL(maxOmega >= 0.0f, "PxVehicleEngineParams.maxOmega must be greater than or equal to zero", false); PX_CHECK_AND_RETURN_VAL(idleOmega >= 0.0f, "PxVehicleEngineParams.idleOmega must be greater or equal to zero", false); PX_CHECK_AND_RETURN_VAL(dampingRateFullThrottle >= 0.0f, "PxVehicleEngineParams.dampingRateFullThrottle must be greater than or equal to zero", false); PX_CHECK_AND_RETURN_VAL(dampingRateZeroThrottleClutchEngaged >= 0.0f, "PxVehicleEngineParams.dampingRateZeroThrottleClutchEngaged must be greater than or equal to zero", false); PX_CHECK_AND_RETURN_VAL(dampingRateZeroThrottleClutchDisengaged >= 0.0f, "PxVehicleEngineParams.dampingRateZeroThrottleClutchDisengaged must be greater than or equal to zero", false) return true; } }; struct PxVehicleGearboxParams { public: /** \brief The gear that denotes neutral gear */ PxU32 neutralGear; /** \brief Maximum supported number of gears, including reverse and neutral. */ enum Enum { eMAX_NB_GEARS = 32 }; /** \brief Gear ratios The ratio for reverse gears must be negative, the ratio for the neutral gear has to be 0 and the ratio for forward gears must be positive. */ PxReal ratios[eMAX_NB_GEARS]; /** \brief Gear ratio applied is #ratios[currentGear]*#finalRatio <b>Range:</b> (0, inf)<br> */ PxReal finalRatio; /** \brief Number of gears (including reverse and neutral). <b>Range:</b> [1, eMAX_NB_GEARS]<br> */ PxU32 nbRatios; /** \brief Time it takes to switch gear. <b>Range:</b> [0, inf)<br> <b>Unit:</b> time */ PxReal switchTime; PX_FORCE_INLINE PxVehicleGearboxParams transformAndScale( const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const { PX_UNUSED(srcFrame); PX_UNUSED(trgFrame); PX_UNUSED(srcScale); PX_UNUSED(trgScale); return *this; } PX_FORCE_INLINE bool isValid() const { PX_CHECK_AND_RETURN_VAL(finalRatio > 0, "PxVehicleGearboxParams.finalRatio must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(nbRatios >= 1, "PxVehicleGearboxParams.nbRatios must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(nbRatios <= eMAX_NB_GEARS, "PxVehicleGearboxParams.nbRatios must be less than or equal to eMAX_NB_GEARS", false); PX_CHECK_AND_RETURN_VAL(neutralGear < nbRatios, "PxVehicleGearboxParams.neutralGear must be less than PxVehicleGearboxParams.nbRatios", false); PX_CHECK_AND_RETURN_VAL(switchTime >= 0.0f, "PxVehicleGearboxParams.switchTime must be greater than or equal to zero", false); for(PxU32 i = 0; i < neutralGear; i++) { PX_CHECK_AND_RETURN_VAL(ratios[i] < 0.0f, "Reverse gear ratios must be less than zero", false); } { PX_CHECK_AND_RETURN_VAL(ratios[neutralGear] == 0.0f, "Neutral gear ratio must be equal to zero", false); } for (PxU32 i = neutralGear + 1; i < nbRatios; i++) { PX_CHECK_AND_RETURN_VAL(ratios[i] > 0.0f, "Forward gear ratios must be greater than zero", false); } for (PxU32 i = neutralGear + 2; i < nbRatios; i++) { PX_CHECK_AND_RETURN_VAL(ratios[i] < ratios[i - 1], "Forward gear ratios must be a descending sequence of gear ratios", false); } return true; } }; struct PxVehicleAutoboxParams { public: /** \brief Value of ( engineRotationSpeed /maxEngineRevs ) that is high enough to increment gear. \note When ( engineRotationSpeed / #PxVehicleEngineParams::maxOmega ) > upRatios[currentGear] the autobox will begin a transition to currentGear+1 unless currentGear is the highest possible gear or neutral or reverse. <b>Range:</b> [0, 1]<br> */ PxReal upRatios[PxVehicleGearboxParams::eMAX_NB_GEARS]; /** \brief Value of engineRevs/maxEngineRevs that is low enough to decrement gear. \note When ( engineRotationSpeed / #PxVehicleEngineParams::maxOmega) < downRatios[currentGear] the autobox will begin a transition to currentGear-1 unless currentGear is first gear or neutral or reverse. <b>Range:</b> [0, 1]<br> */ PxReal downRatios[PxVehicleGearboxParams::eMAX_NB_GEARS]; /** \brief Set the latency time of the autobox. \note Latency time is the minimum time that must pass between each gear change that is initiated by the autobox. The auto-box will only attempt to initiate another gear change up or down if the simulation time that has passed since the most recent automated gear change is greater than the specified latency. <b>Range:</b> [0, inf)<br> <b>Unit:</b> time */ PxReal latency; PX_FORCE_INLINE PxVehicleAutoboxParams transformAndScale( const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const { PX_UNUSED(srcFrame); PX_UNUSED(trgFrame); PX_UNUSED(srcScale); PX_UNUSED(trgScale); return *this; } PX_FORCE_INLINE bool isValid(const PxVehicleGearboxParams& gearboxParams) const { if (!gearboxParams.isValid()) return false; for (PxU32 i = gearboxParams.neutralGear + 1; i < gearboxParams.nbRatios-1; i++) { PX_CHECK_AND_RETURN_VAL(upRatios[i] >= 0.0f, "PxVehicleAutoboxParams.upRatios must be greater than or equal to zero", false); } for (PxU32 i = gearboxParams.neutralGear + 2; i < gearboxParams.nbRatios; i++) { PX_CHECK_AND_RETURN_VAL(downRatios[i] >= 0.0f, "PxVehicleAutoboxParams.downRatios must be greater than or equal to zero", false); } PX_CHECK_AND_RETURN_VAL(latency >= 0.0f, "PxVehicleAutoboxParams.latency must be greater than or equal to zero", false); return true; } }; /** @deprecated */ struct PX_DEPRECATED PxVehicleFourWheelDriveDifferentialLegacyParams { public: enum Enum { eDIFF_TYPE_LS_4WD, //limited slip differential for car with 4 driven wheels eDIFF_TYPE_LS_FRONTWD, //limited slip differential for car with front-wheel drive eDIFF_TYPE_LS_REARWD, //limited slip differential for car with rear-wheel drive eMAX_NB_DIFF_TYPES }; /** \brief The two front wheels are specified by the array frontWheelIds. \note The states eDIFF_TYPE_LS_4WD, eDIFF_TYPE_LS_FRONTWD require knowledge of the front wheels to allow torque splits between front and rear axles as well as torque splits across the front axle. \note frontWheelIds[0] should specify the wheel on the front axle that is negatively placed on the lateral axis. \note frontWheelIds[1] should specify the wheel on the front axle that is positively placed on the lateral axis. \note If #frontNegPosSplit > 0.5, more torque will be delivered to the wheel specified by frontWheelIds[0] than to the wheel specified by frontWheelIds[1]. The converse is true if #frontNegPosSplit < 0.5. */ PxU32 frontWheelIds[2]; /** \brief The two rear wheels are specified by the array rearWheelIds. \note The states eDIFF_TYPE_LS_4WD, eDIFF_TYPE_LS_REARWD require knowledge of the rear wheels to allow torque splits between front and rear axles as well as torque splits across the rear axle. \note rearWheelIds[0] should specify the wheel on the rear axle that is negatively placed on the lateral axis. \note rearWheelIds[1] should specify the wheel on the rear axle that is positively placed on the lateral axis. \note If #rearNegPosSplit > 0.5, more torque will be delivered to the wheel specified by rearWheelIds[0] than to the wheel specified by rearWheelIds[1]. The converse is true if #rearNegPosSplit < 0.5. */ PxU32 rearWheelIds[2]; /** \brief Ratio of torque split between front and rear wheels (>0.5 means more front, <0.5 means more to rear). \note Only applied to DIFF_TYPE_LS_4WD <b>Range:</b> [0, 1]<br> */ PxReal frontRearSplit; /** \brief Ratio of torque split between front-negative and front-positive wheels (>0.5 means more to #frontWheelIds[0], <0.5 means more to #frontWheelIds[1]). \note Only applied to DIFF_TYPE_LS_4WD and DIFF_TYPE_LS_FRONTWD <b>Range:</b> [0, 1]<br> */ PxReal frontNegPosSplit; /** \brief Ratio of torque split between rear-negative wheel and rear-positive wheels (>0.5 means more to #rearWheelIds[0], <0.5 means more to #rearWheelIds[1]). \note Only applied to DIFF_TYPE_LS_4WD and eDIFF_TYPE_LS_REARWD <b>Range:</b> [0, 1]<br> */ PxReal rearNegPosSplit; /** \brief Maximum allowed ratio of average front wheel rotation speed and rear wheel rotation speeds. The differential will divert more torque to the slower wheels when the bias is exceeded. \note Only applied to DIFF_TYPE_LS_4WD <b>Range:</b> [1, inf)<br> */ PxReal centerBias; /** \brief Maximum allowed ratio of front-left and front-right wheel rotation speeds. The differential will divert more torque to the slower wheel when the bias is exceeded. \note Only applied to DIFF_TYPE_LS_4WD and DIFF_TYPE_LS_FRONTWD <b>Range:</b> [1, inf)<br> */ PxReal frontBias; /** \brief Maximum allowed ratio of rear-left and rear-right wheel rotation speeds. The differential will divert more torque to the slower wheel when the bias is exceeded. \note Only applied to DIFF_TYPE_LS_4WD and DIFF_TYPE_LS_REARWD <b>Range:</b> [1, inf)<br> */ PxReal rearBias; /** \brief Type of differential. <b>Range:</b> [DIFF_TYPE_LS_4WD, eDIFF_TYPE_LS_REARWD]<br> */ Enum type; PX_FORCE_INLINE PxVehicleFourWheelDriveDifferentialLegacyParams transformAndScale( const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const { PX_UNUSED(srcFrame); PX_UNUSED(trgFrame); PX_UNUSED(srcScale); PX_UNUSED(trgScale); return *this; } PX_FORCE_INLINE bool isValid(const PxVehicleAxleDescription& axleDesc) const { PX_UNUSED(axleDesc); PX_CHECK_AND_RETURN_VAL((axleDesc.getAxle(frontWheelIds[0]) != 0xffffffff) && (axleDesc.getAxle(frontWheelIds[0])== axleDesc.getAxle(frontWheelIds[1])), "frontWheelIds[0] and frontWheelIds[1] must reference wheels on the same axle", false); PX_CHECK_AND_RETURN_VAL((axleDesc.getAxle(rearWheelIds[0]) != 0xffffffff) && (axleDesc.getAxle(rearWheelIds[0]) == axleDesc.getAxle(rearWheelIds[1])), "rearWheelIds[0] and rearWheelIds[1] must reference wheels on the same axle", false); PX_CHECK_AND_RETURN_VAL(frontRearSplit <= 1.0f && frontRearSplit >= 0.0f, "PxVehicleLegacyFourWheelDriveDifferentialParams.frontRearSplit must be in range [0,1]", false); PX_CHECK_AND_RETURN_VAL(frontNegPosSplit <= 1.0f && frontNegPosSplit >= 0.0f, "PxVehicleLegacyFourWheelDriveDifferentialParams.frontNegPosSplit must be in range [0,1]", false); PX_CHECK_AND_RETURN_VAL(rearNegPosSplit <= 1.0f && rearNegPosSplit >= 0.0f, "PxVehicleLegacyFourWheelDriveDifferentialParams.rearNegPosSplit must be in range [0,1]", false); PX_CHECK_AND_RETURN_VAL(centerBias >= 1.0f, "PxVehicleLegacyFourWheelDriveDifferentialParams.centerBias must be greater than or equal to 1.0f", false); PX_CHECK_AND_RETURN_VAL(frontBias >= 1.0f, "PxVehicleLegacyFourWheelDriveDifferentialParams.frontBias must be greater than or equal to 1.0f", false); PX_CHECK_AND_RETURN_VAL(rearBias >= 1.0f, "PxVehicleLegacyFourWheelDriveDifferentialParams.rearBias must be greater than or equal to 1.0f", false); PX_CHECK_AND_RETURN_VAL(type < PxVehicleFourWheelDriveDifferentialLegacyParams::eMAX_NB_DIFF_TYPES, "PxVehicleLegacyFourWheelDriveDifferentialParams.type has illegal value", false); return true; } }; /** \brief PxVehicleMultiWheelDriveDifferentialParams specifies the wheels that are to receive drive torque from the differential and the division of torque between the wheels that are connected to the differential. */ struct PxVehicleMultiWheelDriveDifferentialParams { /** \brief torqueRatios describes the fraction of torque delivered to each wheel through the differential. \note Wheels not connected to the differential must receive zero torque. \note Wheels connected to the differential may receive a non-zero torque. \note The sum of the absolute of the ratios of all wheels must equal to 1.0. \note A negative torque ratio simulates a wheel with negative gearing applied. <b>Range:</b> [1, -1]<br> */ PxReal torqueRatios[PxVehicleLimits::eMAX_NB_WHEELS]; /** \brief aveWheelSpeedRatios describes the contribution of each wheel to the average wheel speed measured at the clutch. \note Wheels not connected to the differential do not contribute to the average wheel speed measured at the clutch. \note Wheels connected to the differential may delivere a non-zero contribution to the average wheel speed measured at the clutch. \note The sum of all ratios of all wheels must equal to 1.0. <b>Range:</b> [0, 1]<br> */ PxReal aveWheelSpeedRatios[PxVehicleLimits::eMAX_NB_WHEELS]; PX_FORCE_INLINE void setToDefault() { PxMemZero(this, sizeof(PxVehicleMultiWheelDriveDifferentialParams)); } PX_FORCE_INLINE PxVehicleMultiWheelDriveDifferentialParams transformAndScale( const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const { PX_UNUSED(srcFrame); PX_UNUSED(trgFrame); PX_UNUSED(srcScale); PX_UNUSED(trgScale); return *this; } PX_FORCE_INLINE bool isValid(const PxVehicleAxleDescription& axleDesc) const { if (!axleDesc.isValid()) return false; PxReal aveWheelSpeedSum = 0.0f; PxReal torqueRatioSum = 0.0f; for (PxU32 i = 0; i < axleDesc.nbWheels; i++) { const PxU32 wheelId = axleDesc.wheelIdsInAxleOrder[i]; PX_CHECK_AND_RETURN_VAL(PxAbs(torqueRatios[wheelId]) <= 1.0f, "PxVehicleMultiWheelDriveDifferentialParams.torqueRatios[i] must be in range [-1, 1] for all wheels connected to the differential", false); PX_CHECK_AND_RETURN_VAL(aveWheelSpeedRatios[wheelId] >= 0.0f && aveWheelSpeedRatios[wheelId] <= 1.0f, "PxVehicleMultiWheelDriveDifferentialParams.aveWheelSpeedRatios[i] must be in range [0, 1] for all wheels connected to the differential", false); aveWheelSpeedSum += aveWheelSpeedRatios[wheelId]; torqueRatioSum += PxAbs(torqueRatios[wheelId]); } PX_CHECK_AND_RETURN_VAL(aveWheelSpeedSum >= 0.99f && aveWheelSpeedSum <= 1.01f, "Sum of PxVehicleMultiWheelDriveDifferentialParams.aveWheelSpeedRatios[i] must be 1.0.", false); PX_CHECK_AND_RETURN_VAL(torqueRatioSum >= 0.99f && torqueRatioSum <= 1.01f, "Sum of PxVehicleMultiWheelDriveDifferentialParams.torqueRatios[i] must be 1.0.", false); PX_UNUSED(aveWheelSpeedSum); PX_UNUSED(torqueRatioSum); return true; } }; /** \brief A special value that indicates instantaneous resolution of a slip that exceeds a differential bias. */ #define PX_VEHICLE_FOUR_WHEEL_DIFFERENTIAL_MAXIMUM_STRENGTH PX_MAX_F32 /** \brief PxVehicleFourWheelDriveDifferentialParams specifies the wheels that are to receive drive torque from the differential and the division of torque between the wheels that are connected to the differential. Additionally, it specifies the biases and strength of a limited slip differential that operates on two wheels specified as front wheels and two wheels specified as rear wheels. */ struct PxVehicleFourWheelDriveDifferentialParams : public PxVehicleMultiWheelDriveDifferentialParams { /** \brief The ids of the two wheels considered by the differential to be the front pair. \note When the ratio of the rotational speeds of the front wheels exceeds frontBias, drive torque is diverted so that the ratio approaches the value specified by frontTarget. When the bias is not breached, the drive torque is specified by the corresponding entries in PxVehicleMultiWheelDriveDifferentialParams::torqueRatios. */ PxU32 frontWheelIds[2]; /** \brief The ids of the two wheels considered by the differential to be the rear pair. \note When the ratio of the rotational speeds of the rear wheels exceeds rearBias, drive torque is diverted so that the ratio approaches the value specified by rearTarget. When the bias is not breached, the drive torque is specified by the corresponding entries in PxVehicleMultiWheelDriveDifferentialParams::torqueRatios. */ PxU32 rearWheelIds[2]; /** \brief The parameter frontBias specifies the maximum angular speed ratio of the two front wheels specified by frontWheelIds[2]. \note If frontBias has value 0.0, the differential will not try to enforce any relationship between the rotational speeds of the two front wheels. \note If frontBias has value 0.0, the torque split between the front wheels is specified by the array torqueRatios. \note frontBias must have value 0.0 (deactivated limited slip) or be greater than 1.0 (activated limited slip) or be equal to 1.0 (locked axle). \note If frontBias has value greater than or equal to 1.0 then the array frontWheelIds must be specified and the corresponding entries of the isConnected[] array must be set true. \note If frontBias has value greater than or equal to 1.0 then frontTarget must also be specified. \note A locked axle may be achieved by setting frontBias and frontTarget to 1.0. \note A limited slip differential may be achieved by setting frontBias > 1.0 and frontBias > frontTarget > 1.0. */ PxReal frontBias; /** \brief The parameter frontTarget specifies the target rotational speed ratio of the two front wheels in the event that the ratio exceeds frontBias and frontBias is configured for an activated limited slip or locked axle. \note frontTarget must be less than frontBias and greater than 1.0 to implement a limited slip differential. \note Set frontTarget and frontBias to 1.0 to implement a locked axle. */ PxReal frontTarget; /** \brief The parameter rearBias specifies the maximum angular speed ratio of the two rear wheels specified by rearWheelIds[2]. \note If rearBias has value 0.0, the differential will not try to enforce any relationship between the rotational speeds of the two rear wheels. \note If rearBias has value 0.0, the torque split between the rear wheels is specified by the array torqueRatios. \note rearBias must have value 0.0 (deactivated limited slip) or be greater than 1.0 (activated limited slip) or be equal to 1.0 (locked axle). \note If rearBias has value greater than or equal to 1.0 then the array rearWheelIds must be specified and the corresponding entries of the isConnected[] array must be set true. \note If rearBias has value greater than or equal to 1.0 then rearTarget must also be specified. \note A locked axle may be achieved by setting rearBias and rearTarget to 1.0. \note A limited slip differential may be achieved by setting rearBias > 1.0 and rearBias > rearTarget > 1.0 */ PxReal rearBias; /** \brief The parameter rearTarget specifies the target rotational speed ratio of the two rear wheels in the event that the ratio exceeds rearBias and rearBias is configured for an activated limited slip or locked axle. \note rearTarget must be less than rearBias and greater than 1.0 to implement a limited slip differential. \note Set rearTarget and rearBias to 1.0 to implement a locked axle. */ PxReal rearTarget; /** \brief The parameter centerBias specifies the maximum angular speed ratio of the sum of the two front wheels and the sum of the two rear wheels, as specified by frontWheelIds[2] and rearWheelIds[2]. \note If centerBias has value 0.0, the differential will not try to enforce any relationship between the rotational speeds of the front and rear wheels. \note If centerBias has value 0.0, the torque split between the front and rear rear wheels is specified by the array torqueRatios. \note centerBias must have value 0.0 (deactivated limited slip) or be greater than 1.0 (activated limited slip) or be equal to 1.0 (locked). \note If centerBias has value greater than or equal to 1.0 then the arrays frontWheelIds and rearWheelIds must be specified and the corresponding entries of the isConnected[] array must be set true. \note If centerBias has value greater than or equal to 1.0 then centerTarget must also be specified. \note A locked front/rear differential may be achieved by setting centerBias and centerTarget to 1.0. \note A limited slip differential may be achieved by setting centerBias > 1.0 and centerBias > centerTarget > 1.0 */ PxReal centerBias; /** \brief The parameter centerTarget specifies the target rotational speed ratio of the sum of the two front wheels and the sum of the two rear wheels in the event that the ratio exceeds centerBias and centerBias is configured for an activated limited slip. \note centerTarget must be less than centerBias and greater than 1.0 to implement a limited slip differential. \note Set centerTarget and centerBias to 1.0 to implement a locked differential. */ PxReal centerTarget; /** \brief The parameter rate specifies how quickly the ratio of rotational speeds approaches the target rotational speed ratio. \note strength must be in range [0,PX_VEHICLE_FOUR_WHEEL_DIFF_MAXIMUM_STRENGTH]. \note The ratio of rotational speeds is decremented each update by rate*dt until the ratio is equal to the target ratio. \note A value of 0 will result in a deactivated limited slip. \note A value of PX_VEHICLE_FOUR_WHEEL_DIFF_MAXIMUM_STRENGTH will result in instantaneous correction of the rotational speed ratios. */ PxReal rate; PX_FORCE_INLINE void setToDefault() { PxVehicleMultiWheelDriveDifferentialParams::setToDefault(); frontBias = 0.0f; rearBias = 0.0f; centerBias = 0.0f; } PX_FORCE_INLINE bool isValid(const PxVehicleAxleDescription& axleDesc) const { if (!PxVehicleMultiWheelDriveDifferentialParams::isValid(axleDesc)) return false; PX_CHECK_AND_RETURN_VAL((0.0f == centerBias) || (centerBias > 1.0f && frontWheelIds[0] < axleDesc.nbWheels && frontWheelIds[1] < axleDesc.nbWheels && rearWheelIds[0] < axleDesc.nbWheels && rearWheelIds[1] < axleDesc.nbWheels), "PxVehicleFourWheelDriveDifferentialParams:: centreBias is enabled but the frontWheelIds and rearWheelIds are not configured correctly.", false); PX_CHECK_AND_RETURN_VAL((0.0f == centerBias) || (centerBias > 1.0f && frontWheelIds[0] != frontWheelIds[1] && frontWheelIds[0] != rearWheelIds[0] && frontWheelIds[0] != rearWheelIds[1] && frontWheelIds[1] != rearWheelIds[0] && frontWheelIds[1] != rearWheelIds[1] && rearWheelIds[0] != rearWheelIds[1]), "PxVehicleFourWheelDriveDifferentialParams:: centreBias is enabled but the frontWheelIds and rearWheelIds are not configured correctly.", false); PX_CHECK_AND_RETURN_VAL((0.0f == centerBias) || (centerBias > 1.0f && torqueRatios[frontWheelIds[0]] != 0.0f && torqueRatios[frontWheelIds[1]] != 0.0f && torqueRatios[rearWheelIds[0]] != 0.0f && torqueRatios[rearWheelIds[1]] != 0.0f), "PxVehicleFourWheelDriveDifferentialParams:: centreBias is enabled but the front and rear wheels are not connected.", false); PX_CHECK_AND_RETURN_VAL((0.0f == rearBias) || (rearBias > 1.0f && rearWheelIds[0] < axleDesc.nbWheels && rearWheelIds[1] < axleDesc.nbWheels), "PxVehicleFourWheelDriveDifferentialParams:: rearBias is enabled but the rearWheelIds are not configured correctly.", false); PX_CHECK_AND_RETURN_VAL((0.0f == rearBias) || (rearBias > 1.0f && rearWheelIds[0] != rearWheelIds[1]), "PxVehicleFourWheelDriveDifferentialParams:: rearBias is enabled but the rearWheelIds are not configured correctly.", false); PX_CHECK_AND_RETURN_VAL((0.0f == centerBias) || (rearBias > 1.0f && torqueRatios[rearWheelIds[0]] != 0.0f && torqueRatios[rearWheelIds[1]] != 0.0f), "PxVehicleFourWheelDriveDifferentialParams:: rearBias is enabled but the rear wheels are not connected.", false); PX_CHECK_AND_RETURN_VAL((0.0f == frontBias) || (frontBias > 1.0f && frontWheelIds[0] < axleDesc.nbWheels && frontWheelIds[1] < axleDesc.nbWheels), "PxVehicleFourWheelDriveDifferentialParams:: frontBias is enabled but the frontWheelIds are not configured correctly.", false); PX_CHECK_AND_RETURN_VAL((0.0f == frontBias) || (frontBias > 1.0f && frontWheelIds[0] != frontWheelIds[1]), "PxVehicleFourWheelDriveDifferentialParams:: frontBias is enabled but the frontWheelIds are not configured correctly.", false); PX_CHECK_AND_RETURN_VAL((0.0f == frontBias) || (frontBias > 1.0f && torqueRatios[frontWheelIds[0]] != 0.0f && frontWheelIds[frontWheelIds[1]]), "PxVehicleFourWheelDriveDifferentialParams:: frontBias is enabled but the front wheels are not connected.", false); PX_CHECK_AND_RETURN_VAL(((0.0f == frontBias) && (0.0f == rearBias) && (0.0f == centerBias)) || (rate >= 0.0f), "PxVehicleFourWheelDriveDifferentialParams:: strength must be greater than or equal to zero", false); PX_CHECK_AND_RETURN_VAL((0.0f == frontBias) || ((1.0f == frontTarget && 1.0f == rearTarget) || (frontTarget > 1.0f && frontTarget < frontBias)), "PxVehicleFourWheelDriveDifferentialParams: frontBias is enabled but frontTarget not in range (1.0f, frontBias)", false); PX_CHECK_AND_RETURN_VAL((0.0f == rearBias) || ((1.0f == rearTarget && 1.0f == rearBias) || (rearTarget > 1.0f && rearTarget < rearBias)), "PxVehicleFourWheelDriveDifferentialParams: rearBias is enabled but rearTarget not in range (1.0f, rearBias)", false); PX_CHECK_AND_RETURN_VAL((0.0f == centerBias) || ((1.0f == centerTarget && 1.0f == centerBias) || (centerTarget > 1.0f && centerTarget < centerBias)), "PxVehicleFourWheelDriveDifferentialParams: centerBias is enabled but centerTarget not in range (1.0f, centerBias)", false); return true; } PX_FORCE_INLINE PxVehicleFourWheelDriveDifferentialParams transformAndScale( const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const { PX_UNUSED(srcFrame); PX_UNUSED(trgFrame); PX_UNUSED(srcScale); PX_UNUSED(trgScale); PxVehicleFourWheelDriveDifferentialParams r = *this; static_cast<PxVehicleMultiWheelDriveDifferentialParams&>(r) = PxVehicleMultiWheelDriveDifferentialParams::transformAndScale(srcFrame, trgFrame, srcScale, trgScale); return r; } }; /** \brief A description of a tank differential. \note The wheels on a tank may be connected to the differential or not connected to the differential. \note The wheels on a tank track may be connected to a tank track or not connected to a tank track. \note Wheels connected to the differential but not to a tank track receive the torque split specified by the corresponding elements of PxVehicleMultiWheelDriveDifferentialParams::torqueRatios[]. \note Wheels connected to a tank track but not to the differential receive no torque from the engine. \note Wheels connected to a tank track and to the differential receive the torque split specified by the corresponding elements of PxVehicleMultiWheelDriveDifferentialParams::torqueRatios[] multiplied by the corresponding thrust controller value. If the thrust controller has a negative value, the wheels will receive a torque that is negative with respect to the gearing ratio. \note The wheels in each tank track have a constraint applied to them to enforce the rule that they all have the same longitudinal speed at the contact point between the wheel and the tank track. */ struct PxVehicleTankDriveDifferentialParams : public PxVehicleMultiWheelDriveDifferentialParams { PX_FORCE_INLINE void setToDefault() { PxVehicleMultiWheelDriveDifferentialParams::setToDefault(); nbTracks = 0; } /** \brief Add a tank track by specifying the number of wheels along the track and an array of wheel ids specifying each wheel in the tank track. \param[in] nbWheelsInTrackToAdd is the number of wheels in the track to be added. \param[in] wheelIdsInTrackToAdd is an array of wheel ids specifying all the wheels in the track to be added. \param[in] thrustControllerIndex specifies the index of the thrust controller that will be used to control the tank track. */ void addTankTrack(const PxU32 nbWheelsInTrackToAdd, const PxU32* const wheelIdsInTrackToAdd, const PxU32 thrustControllerIndex) { PxU32 trackToWheelIdsOffset = nbTracks ? trackToWheelIds[nbTracks - 1] + nbWheelsPerTrack[nbTracks - 1] : 0; PX_ASSERT((trackToWheelIdsOffset + nbWheelsInTrackToAdd) <= PxVehicleLimits::eMAX_NB_WHEELS); PX_ASSERT(nbTracks < PxVehicleLimits::eMAX_NB_WHEELS); PX_ASSERT(thrustControllerIndex < 2); nbWheelsPerTrack[nbTracks] = nbWheelsInTrackToAdd; thrustIdPerTrack[nbTracks] = thrustControllerIndex; trackToWheelIds[nbTracks] = trackToWheelIdsOffset; for (PxU32 i = 0; i < nbWheelsInTrackToAdd; i++) { wheelIdsInTrackOrder[trackToWheelIdsOffset + i] = wheelIdsInTrackToAdd[i]; } nbTracks++; } /** \brief Return the number of tracks. \return The number of tracks. @see getNbWheelsInTrack() */ PX_FORCE_INLINE PxU32 getNbTracks() const { return nbTracks; } /** \brief Return the number of wheels in the ith track. \param[in] i specifies the track to be queried for its wheel count. \return The number of wheels in the specified track. @see getWheelInTrack() */ PX_FORCE_INLINE PxU32 getNbWheelsInTrack(const PxU32 i) const { return nbWheelsPerTrack[i]; } /** \brief Return the array of all wheels in the ith track. \param[in] i specifies the track to be queried for its wheels. \return The array of wheels in the specified track. */ PX_FORCE_INLINE const PxU32* getWheelsInTrack(const PxU32 i) const { return (wheelIdsInTrackOrder + trackToWheelIds[i]); } /** \brief Return the wheel id of the jth wheel in the ith track. \param[in] j specifies that the wheel id to be returned is the jth wheel in the list of wheels on the specified track. \param[in] i specifies the track to be queried. \return The wheel id of the jth wheel in the ith track. @see getNbWheelsInTrack() */ PX_FORCE_INLINE PxU32 getWheelInTrack(const PxU32 j, const PxU32 i) const { return wheelIdsInTrackOrder[trackToWheelIds[i] + j]; } /** \brief Return the index of the thrust controller that will control a specified track. \param[in] i specifies the track to be queried for its thrust controller index \return The index of the thrust controller that will control the ith track. */ PX_FORCE_INLINE PxU32 getThrustControllerIndex(const PxU32 i) const { return thrustIdPerTrack[i]; } PX_FORCE_INLINE PxVehicleTankDriveDifferentialParams transformAndScale( const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const { PX_UNUSED(srcFrame); PX_UNUSED(trgFrame); PX_UNUSED(srcScale); PX_UNUSED(trgScale); PxVehicleTankDriveDifferentialParams r = *this; static_cast<PxVehicleMultiWheelDriveDifferentialParams&>(r) = PxVehicleMultiWheelDriveDifferentialParams::transformAndScale(srcFrame, trgFrame, srcScale, trgScale); return r; } PX_FORCE_INLINE bool isValid(const PxVehicleAxleDescription& axleDesc) const { if (!PxVehicleMultiWheelDriveDifferentialParams::isValid(axleDesc)) return false; PX_CHECK_AND_RETURN_VAL(nbTracks <= PxVehicleLimits::eMAX_NB_WHEELS, "PxVehicleTankDriveDifferentialParams.nbTracks must not exceed PxVehicleLimits::eMAX_NB_WHEELS", false); const PxU32 nbWheelsInTracksSize = nbTracks ? trackToWheelIds[nbTracks - 1] + nbWheelsPerTrack[nbTracks - 1] : 0; PX_UNUSED(nbWheelsInTracksSize); PX_CHECK_AND_RETURN_VAL(nbWheelsInTracksSize <= PxVehicleLimits::eMAX_NB_WHEELS, "PxVehicleTankDriveDifferentialParams.nbWheelsInTracks must not exceed PxVehicleLimits::eMAX_NB_WHEELS", false); for (PxU32 i = 0; i < nbTracks; i++) { PX_CHECK_AND_RETURN_VAL(thrustIdPerTrack[i] < 2, "PxVehicleTankDriveDifferentialParams.thrustId must be less than 2", false); } for (PxU32 i = 0; i < axleDesc.nbWheels; i++) { const PxU32 wheelId = axleDesc.wheelIdsInAxleOrder[i]; PxU32 count = 0; for (PxU32 j = 0; j < nbTracks; j++) { const PxU32 nbWheels = getNbWheelsInTrack(j); const PxU32* wheelIds = getWheelsInTrack(j); for (PxU32 k = 0; k < nbWheels; k++) { if (wheelIds[k] == wheelId) count++; } } PX_CHECK_AND_RETURN_VAL(count <= 1, "PxVehicleTankDriveDifferentialParams - a wheel cannot be in more than one tank track", false); } return true; } PxU32 nbTracks; //!< The number of tracks PxU32 thrustIdPerTrack[PxVehicleLimits::eMAX_NB_WHEELS]; //!< The id of the thrust that will control the track. Must have value 0 or 1. PxU32 nbWheelsPerTrack[PxVehicleLimits::eMAX_NB_WHEELS]; //!< The number of wheels in each track PxU32 trackToWheelIds[PxVehicleLimits::eMAX_NB_WHEELS]; //!< The list of wheel ids for the ith tank track begins at wheelIdsInTrackOrder[trackToWheelIds[i]] PxU32 wheelIdsInTrackOrder[PxVehicleLimits::eMAX_NB_WHEELS];//!< The list of all wheel ids in all tracks }; #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
45,498
C
44.59018
310
0.763814
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/pvd/PxVehiclePvdFunctions.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "vehicle2/PxVehicleParams.h" #include "vehicle2/braking/PxVehicleBrakingParams.h" #include "vehicle2/commands/PxVehicleCommandStates.h" #include "vehicle2/drivetrain/PxVehicleDrivetrainParams.h" #include "vehicle2/drivetrain/PxVehicleDrivetrainStates.h" #include "vehicle2/physxActor/PxVehiclePhysXActorStates.h" #include "vehicle2/physxConstraints/PxVehiclePhysXConstraintParams.h" #include "vehicle2/physxConstraints/PxVehiclePhysXConstraintStates.h" #include "vehicle2/physxRoadGeometry/PxVehiclePhysXRoadGeometryParams.h" #include "vehicle2/physxRoadGeometry/PxVehiclePhysXRoadGeometryState.h" #include "vehicle2/roadGeometry/PxVehicleRoadGeometryState.h" #include "vehicle2/steering/PxVehicleSteeringParams.h" #include "vehicle2/suspension/PxVehicleSuspensionParams.h" #include "vehicle2/suspension/PxVehicleSuspensionStates.h" #include "vehicle2/tire/PxVehicleTireParams.h" #include "vehicle2/tire/PxVehicleTireStates.h" #include "vehicle2/wheel/PxVehicleWheelParams.h" #include "vehicle2/wheel/PxVehicleWheelStates.h" class OmniPvdWriter; namespace physx { class PxAllocatorCallback; namespace vehicle2 { struct PxVehiclePvdAttributeHandles; struct PxVehiclePvdObjectHandles; } // namespace vehicle2 } // namespace physx #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif /** \brief Create object instances in omnipvd that will be used to reflect the parameters and state of the rigid body of a vehicle instance. Handles to the created object instances will be stored in a PxVehiclePvdObjectHandles instance. \param[in] rbodyParams describes the parameters of the vehicle's rigid body. \param[in] rbodyState describes the state of the vehicle's rigid body. \param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd. \param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance. \param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd. \note If rbodyParams is NULL, omnipvd will not reflect rigid body parameters. \note If rbodyState is NULL, omnipvd will not reflect rigid body state. \note PxVehiclePvdRigidBodyRegister should be called once for each vehicle instance. @see PxVehiclePvdAttributesCreate @see PxVehiclePvdObjectCreate @see PxVehiclePvdRigidBodyWrite */ void PxVehiclePvdRigidBodyRegister (const PxVehicleRigidBodyParams* rbodyParams, const PxVehicleRigidBodyState* rbodyState, const PxVehiclePvdAttributeHandles& attributeHandles, PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter); /** \brief Write the parameters and state of the rigid body of a vehicle instance to omnipvd. \param[in] rbodyParams describes the parameters of the vehicle's rigid body. \param[in] rbodyState describes the state of the vehicle's rigid body. \param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd. \param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance. \param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd. \note If rbodyParams is NULL but a non-NULL value was used in PxVehiclePvdRigidBodyRegister(), the rigid body parameters will not be updated in omnipvd. \note If rbodyState is NULL but a non-NULL value was used in PxVehiclePvdRigidBodyRegister(), the rigid body state will not be updated in omnipvd. \note omniWriter must be the same instance used in PxVehiclePvdRigidBodyRegister(). @see PxVehiclePvdAttributesCreate @see PxVehiclePvdObjectCreate @see PxVehiclePvdRigidBodyRegister */ void PxVehiclePvdRigidBodyWrite (const PxVehicleRigidBodyParams* rbodyParams, const PxVehicleRigidBodyState* rbodyState, const PxVehiclePvdAttributeHandles& attributeHandles, const PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter); /** \brief Register object instances in omnipvd that will be used to reflect the suspension state calculation parameters of a vehicle instance. \param[in] suspStateCalcParams describes parameters used to calculate suspension state. \param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd. \param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance. \param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd. \note If suspStateCalcParams is NULL, omnipvd will not reflect the suspension state calculation parameters. @see PxVehiclePvdAttributesCreate @see PxVehiclePvdObjectCreate @see PxVehiclePvdSuspensionStateCalculationParamsWrite */ void PxVehiclePvdSuspensionStateCalculationParamsRegister (const PxVehicleSuspensionStateCalculationParams* suspStateCalcParams, const PxVehiclePvdAttributeHandles& attributeHandles, PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter); /** \brief Write the parameters and state of the rigid body of a vehicle instance to omnipvd. \param[in] suspStateCalcParams describes parameters used to calculate suspension state. \param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd. \param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance. \param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd. \note If suspStateCalcParams is NULL but a non-NULL value was used in void PxVehiclePvdSuspensionStateCalculationParamsRegister(), the suspension state calculation parameters will not be updated in omnipvd. \note omniWriter must be the same instance used in PxVehiclePvdSuspensionStateCalculationParamsRegister(). @see PxVehiclePvdAttributesCreate @see PxVehiclePvdObjectCreate @see PxVehiclePvdSuspensionStateCalculationParamsRegister */ void PxVehiclePvdSuspensionStateCalculationParamsWrite (const PxVehicleSuspensionStateCalculationParams* suspStateCalcParams, const PxVehiclePvdAttributeHandles& attributeHandles, const PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter); /** \brief Register object instances in omnipvd that will be used to reflect the brake and steer command response parameters of a vehicle instance. \param[in] brakeResponseParams is an array of brake command response parameters. \param[in] steerResponseParams describes the steer command response parameters. \param[in] ackermannParams defines the Ackermann steer correction. \param[in] brakeResponseStates is an array of brake responses torqyes, \param[in] steerResponseStates is an array of steer response angles. \param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd. \param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance. \param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd. \note If brakeResponseParams is empty, omnipvd will not reflect any brake command response parameters. \note If steerResponseParams is NULL, omnipvd will not reflect the steer command response parameters. \note If ackermannParams is NULL, omnipvd will not reflect any Ackermann steer correction parameters. \note If brakeResponseStates is empty, omnipvd will not reflect any brake command response state. \note If steerResponseStates is empty, omnipvd will not reflect any steer command response state. @see PxVehiclePvdAttributesCreate @see PxVehiclePvdObjectCreate @see PxVehiclePvdCommandResponseWrite */ void PxVehiclePvdCommandResponseRegister (const PxVehicleSizedArrayData<const PxVehicleBrakeCommandResponseParams>& brakeResponseParams, const PxVehicleSteerCommandResponseParams* steerResponseParams, const PxVehicleAckermannParams* ackermannParams, const PxVehicleArrayData<PxReal>& brakeResponseStates, const PxVehicleArrayData<PxReal>& steerResponseStates, const PxVehiclePvdAttributeHandles& attributeHandles, PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter); /** \brief Write brake and steer command response parameters to omnipvd. \param[in] axleDesc is a description of the wheels and axles of a vehicle. \param[in] brakeResponseParams is an array of brake command response parameters. \param[in] steerResponseParams describes the steer command response parameters. \param[in] ackermannParams defines the Ackermann steer correction. \param[in] brakeResponseStates is an array of brake response torques. \param[in] steerResponseStates is an array of steer response angles. \param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd. \param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance. \param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd. \note If brakeResponseParams is empty but a non-empty array was used in PxVehiclePvdCommandResponseRegister(), the brake command response parameters will not be updated in omnipvd. \note If steerResponseParams is non-NULL but a NULL value was used in PxVehiclePvdCommandResponseRegister(), the steer command parameters will not be updated in omnipvd. \note If ackermannParams is non-NULL but a NULL value was used in PxVehiclePvdCommandResponseRegister(), the Ackermann steer correction parameters will not be updated in omnipvd. \note If brakeResponseStates is empty but a non-empty array was used in PxVehiclePvdCommandResponseRegister(), the brake response states will not be updated in omnipvd. \note If steerResponseStates is empty but a non-empty array was used in PxVehiclePvdCommandResponseRegister(), the steer response states will not be updated in omnipvd. \note omniWriter must be the same instance used in PxVehiclePvdCommandResponseRegister(). @see PxVehiclePvdAttributesCreate @see PxVehiclePvdObjectCreate @see PxVehiclePvdCommandResponseRegister */ void PxVehiclePvdCommandResponseWrite (const PxVehicleAxleDescription& axleDesc, const PxVehicleSizedArrayData<const PxVehicleBrakeCommandResponseParams>& brakeResponseParams, const PxVehicleSteerCommandResponseParams* steerResponseParams, const PxVehicleAckermannParams* ackermannParams, const PxVehicleArrayData<PxReal>& brakeResponseStates, const PxVehicleArrayData<PxReal>& steerResponseStates, const PxVehiclePvdAttributeHandles& attributeHandles, const PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter); /** \brief Register object instances in omnipvd that will be used to reflect wheel attachment data such as tires, suspensions and wheels. \param[in] axleDesc is a description of the wheels and axles of a vehicle. \param[in] wheelParams is an array of wheel parameters. \param[in] wheelActuationStates is an array of wheel actuation states. \param[in] wheelRigidBody1dStates is an array of wheel rigid body states. \param[in] wheelLocalPoses is an array of wheel local poses. \param[in] roadGeometryStates is an array of road geometry states. \param[in] suspParams is an array of suspension parameters. \param[in] suspCompParams is an array of suspension compliance parameters. \param[in] suspForceParams is an array of suspension force parameters. \param[in] suspStates is an array of suspension states. \param[in] suspCompStates is an array of suspension compliance states. \param[in] suspForces is an array of suspension forces. \param[in] tireForceParams is an array of tire force parameters. \param[in] tireDirectionStates is an array of tire direction states. \param[in] tireSpeedStates is an array of tire speed states. \param[in] tireSlipStates is an array of tire slip states. \param[in] tireStickyStates is an array of tire sticky states. \param[in] tireGripStates is an array of tire grip states. \param[in] tireCamberStates is an array of tire camber states. \param[in] tireForces is an array of tire forces. \param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd. \param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance. \param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd. \note If any array is empty, the corresponding data will not be reflected in omnipvd. \note Each array must either be empty or contain an entry for each wheel present in axleDesc. @see PxVehiclePvdAttributesCreate @see PxVehiclePvdObjectCreate @see PxVehiclePvdWheelAttachmentsWrite */ void PxVehiclePvdWheelAttachmentsRegister (const PxVehicleAxleDescription& axleDesc, const PxVehicleArrayData<const PxVehicleWheelParams>& wheelParams, const PxVehicleArrayData<const PxVehicleWheelActuationState>& wheelActuationStates, const PxVehicleArrayData<const PxVehicleWheelRigidBody1dState>& wheelRigidBody1dStates, const PxVehicleArrayData<const PxVehicleWheelLocalPose>& wheelLocalPoses, const PxVehicleArrayData<const PxVehicleRoadGeometryState>& roadGeometryStates, const PxVehicleArrayData<const PxVehicleSuspensionParams>& suspParams, const PxVehicleArrayData<const PxVehicleSuspensionComplianceParams>& suspCompParams, const PxVehicleArrayData<const PxVehicleSuspensionForceParams>& suspForceParams, const PxVehicleArrayData<const PxVehicleSuspensionState>& suspStates, const PxVehicleArrayData<const PxVehicleSuspensionComplianceState>& suspCompStates, const PxVehicleArrayData<const PxVehicleSuspensionForce>& suspForces, const PxVehicleArrayData<const PxVehicleTireForceParams>& tireForceParams, const PxVehicleArrayData<const PxVehicleTireDirectionState>& tireDirectionStates, const PxVehicleArrayData<const PxVehicleTireSpeedState>& tireSpeedStates, const PxVehicleArrayData<const PxVehicleTireSlipState>& tireSlipStates, const PxVehicleArrayData<const PxVehicleTireStickyState>& tireStickyStates, const PxVehicleArrayData<const PxVehicleTireGripState>& tireGripStates, const PxVehicleArrayData<const PxVehicleTireCamberAngleState>& tireCamberStates, const PxVehicleArrayData<const PxVehicleTireForce>& tireForces, const PxVehiclePvdAttributeHandles& attributeHandles, PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter); /** \brief Write wheel attachment data such as tire, suspension and wheel data to omnipvd. \param[in] axleDesc is a description of the wheels and axles of a vehicle. \param[in] wheelParams is an array of wheel parameters. \param[in] wheelActuationStates is an array of wheel actuation states. \param[in] wheelRigidBody1dStates is an array of wheel rigid body states. \param[in] wheelLocalPoses is an array of wheel local poses. \param[in] roadGeometryStates is an array of road geometry states. \param[in] suspParams is an array of suspension parameters. \param[in] suspCompParams is an array of suspension compliance parameters. \param[in] suspForceParams is an array of suspension force parameters. \param[in] suspStates is an array of suspension states. \param[in] suspCompStates is an array of suspension compliance states. \param[in] suspForces is an array of suspension forces. \param[in] tireForceParams is an array of tire force parameters. \param[in] tireDirectionStates is an array of tire direction states. \param[in] tireSpeedStates is an array of tire speed states. \param[in] tireSlipStates is an array of tire slip states. \param[in] tireStickyStates is an array of tire sticky states. \param[in] tireGripStates is an array of tire grip states. \param[in] tireCamberStates is an array of tire camber states. \param[in] tireForces is an array of tire forces. \param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd. \param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance. \param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd. \note If any array is empty but the corresponding argument in PxVehiclePvdWheelAttachmentsRegister was not empty, the corresponding data will not be updated in omnipvd. \note Each array must either be empty or contain an entry for each wheel present in axleDesc. @see PxVehiclePvdAttributesCreate @see PxVehiclePvdObjectCreate @see PxVehiclePvdWheelAttachmentsRegister */ void PxVehiclePvdWheelAttachmentsWrite (const PxVehicleAxleDescription& axleDesc, const PxVehicleArrayData<const PxVehicleWheelParams>& wheelParams, const PxVehicleArrayData<const PxVehicleWheelActuationState>& wheelActuationStates, const PxVehicleArrayData<const PxVehicleWheelRigidBody1dState>& wheelRigidBody1dStates, const PxVehicleArrayData<const PxVehicleWheelLocalPose>& wheelLocalPoses, const PxVehicleArrayData<const PxVehicleRoadGeometryState>& roadGeometryStates, const PxVehicleArrayData<const PxVehicleSuspensionParams>& suspParams, const PxVehicleArrayData<const PxVehicleSuspensionComplianceParams>& suspCompParams, const PxVehicleArrayData<const PxVehicleSuspensionForceParams>& suspForceParams, const PxVehicleArrayData<const PxVehicleSuspensionState>& suspStates, const PxVehicleArrayData<const PxVehicleSuspensionComplianceState>& suspCompStates, const PxVehicleArrayData<const PxVehicleSuspensionForce>& suspForces, const PxVehicleArrayData<const PxVehicleTireForceParams>& tireForceParams, const PxVehicleArrayData<const PxVehicleTireDirectionState>& tireDirectionStates, const PxVehicleArrayData<const PxVehicleTireSpeedState>& tireSpeedStates, const PxVehicleArrayData<const PxVehicleTireSlipState>& tireSlipStates, const PxVehicleArrayData<const PxVehicleTireStickyState>& tireStickyStates, const PxVehicleArrayData<const PxVehicleTireGripState>& tireGripStates, const PxVehicleArrayData<const PxVehicleTireCamberAngleState>& tireCamberStates, const PxVehicleArrayData<const PxVehicleTireForce>& tireForces, const PxVehiclePvdAttributeHandles& attributeHandles, const PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter); /** \brief Register object instances in omnipvd that will be used to reflect the antiroll bars of a vehicle instance. \param[in] antiRollForceParams is an array of antiroll parameters. \param[in] antiRollTorque describes the instantaneous accumulated torque from all antiroll bas. \param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd. \param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance. \param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd. \note If antiRollForceParams is empty, the corresponding data will not be reflected in omnipvd. \note If antiRollTorque is NULL, the corresponding data will not be reflected in omnipvd. @see PxVehiclePvdAttributesCreate @see PxVehiclePvdObjectCreate @see PxVehiclePvdAntiRollsWrite */ void PxVehiclePvdAntiRollsRegister (const PxVehicleSizedArrayData<const PxVehicleAntiRollForceParams>& antiRollForceParams, const PxVehicleAntiRollTorque* antiRollTorque, const PxVehiclePvdAttributeHandles& attributeHandles, PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter); /** \brief Write antiroll data to omnipvd. \param[in] antiRollForceParams is an array of antiroll parameters. \param[in] antiRollTorque describes the instantaneous accumulated torque from all antiroll bas. \param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd. \param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance. \param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd. \note If antiRollForceParams is empty but the corresponding argument was not empty, the corresponding data will not be updated in omnipvd. \note If antiRollTorque is NULL but the corresponding argument was not NULL, the corresponding data will not be updated in omnipvd. @see PxVehiclePvdAttributesCreate @see PxVehiclePvdObjectCreate @see PxVehiclePvdAntiRollsRegister */ void PxVehiclePvdAntiRollsWrite (const PxVehicleSizedArrayData<const PxVehicleAntiRollForceParams>& antiRollForceParams, const PxVehicleAntiRollTorque* antiRollTorque, const PxVehiclePvdAttributeHandles& attributeHandles, const PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter); /** \brief Register object instances in omnipvd that will be used to reflect the direct drivetrain of a vehicle instance. \param[in] commandState describes the control values applied to the vehicle. \param[in] transmissionCommandState describes the state of the direct drive transmission. \param[in] directDriveThrottleResponseParams describes the vehicle's torque response to a throttle command. \param[in] directDriveThrottleResponseState is the instantaneous torque response of each wheel to a throttle command. \param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd. \param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance. \param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd. \note If commandState is NULL, the corresponding data will not be reflected in omnipvd. \note If transmissionCommandState is NULL, the corresponding data will not be reflected in omnipvd. \note If directDriveThrottleResponseParams is NULL, the corresponding data will not be reflected in omnipvd. \note If directDriveThrottleResponseState is empty, the corresponding data will not be reflected in omnipvd. @see PxVehiclePvdAttributesCreate @see PxVehiclePvdObjectCreate @see PxVehiclePvdDirectDrivetrainWrite */ void PxVehiclePvdDirectDrivetrainRegister (const PxVehicleCommandState* commandState, const PxVehicleDirectDriveTransmissionCommandState* transmissionCommandState, const PxVehicleDirectDriveThrottleCommandResponseParams* directDriveThrottleResponseParams, const PxVehicleArrayData<PxReal>& directDriveThrottleResponseState, const PxVehiclePvdAttributeHandles& attributeHandles, PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter); /** \brief Write direct drivetrain data to omnipvd. \param[in] axleDesc is a description of the wheels and axles of a vehicle. \param[in] commandState describes the control values applied to the vehicle. \param[in] transmissionCommandState describes the state of the direct drive transmission. \param[in] directDriveThrottleResponseParams describes the vehicle's torque response to a throttle command. \param[in] directDriveThrottleResponseState is the instantaneous torque response of each wheel to a throttle command. \param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd. \param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance. \param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd. \note If commandState is NULL but the corresponding entry in PxVehiclePvdDirectDrivetrainRegister() was not NULL, the corresponding data will not be updated in omnipvd. \note If transmissionCommandState is NULL but the corresponding entry in PxVehiclePvdDirectDrivetrainRegister() was not NULL, the corresponding data will not be updated in omnipvd. \note If directDriveThrottleResponseParams is NULL but the corresponding entry in PxVehiclePvdDirectDrivetrainRegister() was not NULL, the corresponding data will not be updated in omnipvd. \note If directDriveThrottleResponseState is empty but the corresponding entry in PxVehiclePvdDirectDrivetrainRegister() was not empty, the corresponding data will not be updated in omnipvd. @see PxVehiclePvdAttributesCreate @see PxVehiclePvdObjectCreate @see PxVehiclePvdDirectDrivetrainRegister */ void PxVehiclePvdDirectDrivetrainWrite (const PxVehicleAxleDescription& axleDesc, const PxVehicleCommandState* commandState, const PxVehicleDirectDriveTransmissionCommandState* transmissionCommandState, const PxVehicleDirectDriveThrottleCommandResponseParams* directDriveThrottleResponseParams, const PxVehicleArrayData<PxReal>& directDriveThrottleResponseState, const PxVehiclePvdAttributeHandles& attributeHandles, const PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter); /** \brief Register object instances in omnipvd that will be used to reflect the engine drivetrain of a vehicle instance. \param[in] commandState describes the control values applied to the vehicle. \param[in] engineDriveTransmissionCommandState describes the state of the engine drive transmission. \param[in] tankDriveTransmissionCommandState describes the state of the tank drive transmission. \param[in] clutchResponseParams describes the vehicle's response to a clutch command. \param[in] clutchParams describes the vehicle's clutch. \param[in] engineParams describes the engine. \param[in] gearboxParams describes the gearbox. \param[in] autoboxParams describes the automatic gearbox. \param[in] multiWheelDiffParams describes a multiwheel differential without limited slip compensation. \param[in] fourWheelDiffPrams describes a differential that delivers torque to four drive wheels with limited slip compensation. \param[in] tankDiffParams describes the operation of the tank differential. \param[in] clutchResponseState is the instantaneous reponse of the clutch to a clutch command. \param[in] throttleResponseState is the instantaneous response to a throttle command. \param[in] engineState is the instantaneous state of the engine. \param[in] gearboxState is the instantaneous state of the gearbox. \param[in] autoboxState is the instantaneous state of the automatic gearbox. \param[in] diffState is the instantaneous state of the differential. \param[in] clutchSlipState is the instantaneous slip recorded at the clutch. \param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd. \param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance. \param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd. \note If any pointer is NULL, the corresponding data will not be reflected in omnipvd. \note At most one of engineDriveTransmissionCommandState and tankDriveTransmissionCommandState is expected to be non-NULL. \note At most one of multiWheelDiffParams, fourWheelDiffParams and tankDiffParams is expected to be non-NULL. @see PxVehiclePvdAttributesCreate @see PxVehiclePvdObjectCreate @see PxVehiclePvdEngineDrivetrainWrite */ void PxVehiclePvdEngineDrivetrainRegister (const PxVehicleCommandState* commandState, const PxVehicleEngineDriveTransmissionCommandState* engineDriveTransmissionCommandState, const PxVehicleTankDriveTransmissionCommandState* tankDriveTransmissionCommandState, const PxVehicleClutchCommandResponseParams* clutchResponseParams, const PxVehicleClutchParams* clutchParams, const PxVehicleEngineParams* engineParams, const PxVehicleGearboxParams* gearboxParams, const PxVehicleAutoboxParams* autoboxParams, const PxVehicleMultiWheelDriveDifferentialParams* multiWheelDiffParams, const PxVehicleFourWheelDriveDifferentialParams* fourWheelDiffPrams, const PxVehicleTankDriveDifferentialParams* tankDiffParams, const PxVehicleClutchCommandResponseState* clutchResponseState, const PxVehicleEngineDriveThrottleCommandResponseState* throttleResponseState, const PxVehicleEngineState* engineState, const PxVehicleGearboxState* gearboxState, const PxVehicleAutoboxState* autoboxState, const PxVehicleDifferentialState* diffState, const PxVehicleClutchSlipState* clutchSlipState, const PxVehiclePvdAttributeHandles& attributeHandles, PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter); /** \brief Write engine drivetrain data of a vehicle instance to omnipvd. \param[in] commandState describes the control values applied to the vehicle. \param[in] engineDriveTransmissionCommandState describes the state of the engine drive transmission. \param[in] tankDriveTransmissionCommandState describes the state of the tank drive transmission. \param[in] clutchResponseParams describes the vehicle's response to a clutch command. \param[in] clutchParams describes the vehicle's clutch. \param[in] engineParams describes the engine. \param[in] gearboxParams describes the gearbox. \param[in] autoboxParams describes the automatic gearbox. \param[in] multiWheelDiffParams describes a multiwheel differential without limited slip compensation. \param[in] fourWheelDiffParams describes a differential that delivers torque to four drive wheels with limited slip compensation. \param[in] tankDiffParams describes the operation of the tank differential. \param[in] clutchResponseState is the instantaneous reponse of the clutch to a clutch command. \param[in] throttleResponseState is the instantaneous response to a throttle command. \param[in] engineState is the instantaneous state of the engine. \param[in] gearboxState is the instantaneous state of the gearbox. \param[in] autoboxState is the instantaneous state of the automatic gearbox. \param[in] diffState is the instantaneous state of the differential. \param[in] clutchSlipState is the instantaneous slip recorded at the clutch. \param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd. \param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance. \param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd. \note If any pointer is NULL and the corresponding argument in PxVehiclePvdEngineDrivetrainRegister() was not NULL, the corresponding data will not be reflected in omnipvd. \note At most one of engineDriveTransmissionCommandState and tankDriveTransmissionCommandState is expected to be non-NULL. \note At most one of multiWheelDiffParams, fourWheelDiffParams and tankDiffParams is expected to be non-NULL. @see PxVehiclePvdAttributesCreate @see PxVehiclePvdObjectCreate @see PxVehiclePvdEngineDrivetrainRegister */ void PxVehiclePvdEngineDrivetrainWrite (const PxVehicleCommandState* commandState, const PxVehicleEngineDriveTransmissionCommandState* engineDriveTransmissionCommandState, const PxVehicleTankDriveTransmissionCommandState* tankDriveTransmissionCommandState, const PxVehicleClutchCommandResponseParams* clutchResponseParams, const PxVehicleClutchParams* clutchParams, const PxVehicleEngineParams* engineParams, const PxVehicleGearboxParams* gearboxParams, const PxVehicleAutoboxParams* autoboxParams, const PxVehicleMultiWheelDriveDifferentialParams* multiWheelDiffParams, const PxVehicleFourWheelDriveDifferentialParams* fourWheelDiffParams, const PxVehicleTankDriveDifferentialParams* tankDiffParams, const PxVehicleClutchCommandResponseState* clutchResponseState, const PxVehicleEngineDriveThrottleCommandResponseState* throttleResponseState, const PxVehicleEngineState* engineState, const PxVehicleGearboxState* gearboxState, const PxVehicleAutoboxState* autoboxState, const PxVehicleDifferentialState* diffState, const PxVehicleClutchSlipState* clutchSlipState, const PxVehiclePvdAttributeHandles& attributeHandles, const PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter); /** \brief Register per wheel attachment data that involves the vehicle's integration with a PhysX scene. \param[in] axleDesc is a description of the wheels and axles of a vehicle. \param[in] physxSuspLimitConstraintParams describes the method used by PhysX to enforce suspension travel limits. \param[in] physxMaterialFrictionParams describes the friction response of each wheel to a set of PxMaterial instances. \param[in] physxActor describes the PxRigidActor and PxShape instances that are used to represent the vehicle's rigid body and wheel shapes in PhysX. \param[in] physxRoadGeometryQueryParams describes the physx scene query method used to place each wheel on the ground. \param[in] physxRoadGeomState is an array of per wheel physx scene query results. \param[in] physxConstraintStates is an array of constraints states used by PhysX to enforce sticky tire and suspension travel limit constraints. \param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd. \param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance. \param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd. \note If any array is empty, the corresponding data will not be reflected in omnipvd. \note If physxActor is NULL, the corresponding data will not be reflected in omnipvd. \note If physxRoadGeometryQueryParams is NULL, the corresponding data will not be reflected in omnipvd. \note Each array must either be empty or contain an entry for each wheel present in axleDesc. @see PxVehiclePvdAttributesCreate @see PxVehiclePvdObjectCreate @see PxVehiclePvdPhysXWheelAttachmentWrite */ void PxVehiclePvdPhysXWheelAttachmentRegister (const PxVehicleAxleDescription& axleDesc, const PxVehicleArrayData<const PxVehiclePhysXSuspensionLimitConstraintParams>& physxSuspLimitConstraintParams, const PxVehicleArrayData<const PxVehiclePhysXMaterialFrictionParams>& physxMaterialFrictionParams, const PxVehiclePhysXActor* physxActor, const PxVehiclePhysXRoadGeometryQueryParams* physxRoadGeometryQueryParams, const PxVehicleArrayData<const PxVehiclePhysXRoadGeometryQueryState>& physxRoadGeomState, const PxVehicleArrayData<const PxVehiclePhysXConstraintState>& physxConstraintStates, const PxVehiclePvdAttributeHandles& attributeHandles, PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter); /** \brief Write to omnipvd the per wheel attachment data that involves the vehicle's integration with a PhysX scene. \param[in] axleDesc is a description of the wheels and axles of a vehicle. \param[in] physxSuspLimitConstraintParams describes the method used by PhysX to enforce suspension travel limits. \param[in] physxMaterialFrictionParams describes the friction response of each wheel to a set of PxMaterial instances. \param[in] physxActor describes the PxShape instances that are used to represent the vehicle's wheel shapes in PhysX. \param[in] physxRoadGeometryQueryParams describes the physx scene query method used to place each wheel on the ground. \param[in] physxRoadGeomState is an array of per wheel physx scene query results. \param[in] physxConstraintStates is an array of constraints states used by PhysX to enforce sticky tire and suspension travel limit constraints. \param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd. \param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance. \param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd. \note If any array is empty but the corresponding array in PxVehiclePvdPhysXWheelAttachmentRegister() was not empty, the corresponding data will not be updated in omnipvd. \note If physxActor is NULL but the corresponding argument in PxVehiclePvdPhysXWheelAttachmentRegister was not NULL, the corresponding data will not be reflected in omnipvd. \note If physxRoadGeometryQueryParams is NULL but the corresponding argument in PxVehiclePvdPhysXWheelAttachmentRegister was not NULL, the corresponding data will not be reflected in omnipvd. \note Each array must either be empty or contain an entry for each wheel present in axleDesc. @see PxVehiclePvdAttributesCreate @see PxVehiclePvdObjectCreate @see PxVehiclePvdPhysXWheelAttachmentWrite */ void PxVehiclePvdPhysXWheelAttachmentWrite (const PxVehicleAxleDescription& axleDesc, const PxVehicleArrayData<const PxVehiclePhysXSuspensionLimitConstraintParams>& physxSuspLimitConstraintParams, const PxVehicleArrayData<const PxVehiclePhysXMaterialFrictionParams>& physxMaterialFrictionParams, const PxVehiclePhysXActor* physxActor, const PxVehiclePhysXRoadGeometryQueryParams* physxRoadGeometryQueryParams, const PxVehicleArrayData<const PxVehiclePhysXRoadGeometryQueryState>& physxRoadGeomState, const PxVehicleArrayData<const PxVehiclePhysXConstraintState>& physxConstraintStates, const PxVehiclePvdAttributeHandles& attributeHandles, const PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter); /** \brief Register the PxRigidActor instance that represents the vehicle's rigid body in a PhysX scene. \param[in] physxActor describes the PxRigidActor instance that is used to represent the vehicle's rigid body in PhysX. \param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd. \param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance. \param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd. \note If physxActor is NULL, the corresponding data will not be reflected in omnipvd. @see PxVehiclePvdAttributesCreate @see PxVehiclePvdObjectCreate @see PxVehiclePvdPhysXRigidActorWrite */ void PxVehiclePvdPhysXRigidActorRegister (const PxVehiclePhysXActor* physxActor, const PxVehiclePvdAttributeHandles& attributeHandles, PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter); /** \brief Write the PxRigidActor instance to omnipvd. \param[in] physxActor describes the PxRigidActor instance that is used to represent the vehicle's rigid body in PhysX. \param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd. \param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance. \param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd. \note If physxActor is NULL and the corresponding argument in PxVehiclePvdPhysXRigidActorRegister was not NULL, the corresponding data will not be updated in omnipvd. @see PxVehiclePvdAttributesCreate @see PxVehiclePvdObjectCreate @see PxVehiclePvdPhysXRigidActorRegister */ void PxVehiclePvdPhysXRigidActorWrite (const PxVehiclePhysXActor* physxActor, const PxVehiclePvdAttributeHandles& attributeHandles, const PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter); /** \brief Register the PhysX related steer state class. \param[in] physxSteerState describes the PxVehiclePhysXSteerState instance that holds steer related state information. \param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd. \param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance. \param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd. \note If physxSteerState is NULL, the corresponding data will not be reflected in omnipvd. @see PxVehiclePvdAttributesCreate @see PxVehiclePvdObjectCreate @see PxVehiclePvdPhysXSteerStateWrite */ void PxVehiclePvdPhysXSteerStateRegister (const PxVehiclePhysXSteerState* physxSteerState, const PxVehiclePvdAttributeHandles& attributeHandles, PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter); /** \brief Write the PxVehiclePhysXSteerState instance to omnipvd. \param[in] physxSteerState describes the PxVehiclePhysXSteerState instance that holds steer related state information. \param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd. \param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance. \param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd. \note If physxSteerState is NULL and the corresponding argument in PxVehiclePvdPhysXSteerStateRegister was not NULL, the corresponding data will not be updated in omnipvd. @see PxVehiclePvdAttributesCreate @see PxVehiclePvdObjectCreate @see PxVehiclePvdPhysXSteerStateRegister */ void PxVehiclePvdPhysXSteerStateWrite (const PxVehiclePhysXSteerState* physxSteerState, const PxVehiclePvdAttributeHandles& attributeHandles, const PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter); #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
42,550
C
65.589984
192
0.842374
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/pvd/PxVehiclePvdHelpers.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "foundation/PxSimpleTypes.h" class OmniPvdWriter; namespace physx { class PxAllocatorCallback; namespace vehicle2 { struct PxVehiclePvdAttributeHandles; struct PxVehiclePvdObjectHandles; } } #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif /** \brief Create the attribute handles necessary to reflect vehicles in omnipvd. \param[in] allocator is used to allocate the memory used to store the attribute handles. \param[in] omniWriter is used to register the attribute handles with omnipvd. @see PxVehicleSimulationContext @see PxVehiclePVDComponent @see PxVehiclePvdAttributesRelease */ PxVehiclePvdAttributeHandles* PxVehiclePvdAttributesCreate (PxAllocatorCallback& allocator, OmniPvdWriter& omniWriter); /** \brief Destory the attribute handles created by PxVehiclePvdAttributesCreate(). \param[in] allocator must be the instance used by PxVehiclePvdObjectCreate(). \param[in] attributeHandles is the PxVehiclePvdAttributeHandles created by PxVehiclePvdAttributesCreate(). @see PxVehiclePvdAttributesCreate */ void PxVehiclePvdAttributesRelease (PxAllocatorCallback& allocator, PxVehiclePvdAttributeHandles& attributeHandles); /** \brief Create omnipvd objects that will be used to reflect an individual veicle in omnipvd. \param[in] nbWheels must be greater than or equal to the number of wheels on the vehicle. \param[in] nbAntirolls must be greater than or equal to the number of antiroll bars on the vehicle. \param[in] maxNbPhysxMaterialFrictions must be greater than or equal to the number of PxPhysXMaterialFriction instances associated with any wheel of the vehicle. \param[in] contextHandle is typically used to associated vehicles with a particular scene or group. \param[in] allocator is used to allocate the memory used to store handles to the created omnipvd objects. \note PxVehiclePvdObjectCreate() must be called after PxVehiclePvdAttributesCreate(). @see PxVehicleAxleDescription @see PxVehicleAntiRollForceParams @see PxVehiclePhysXMaterialFrictionParams @see PxVehiclePVDComponent @see PxVehiclePvdAttributesCreate */ PxVehiclePvdObjectHandles* PxVehiclePvdObjectCreate (const PxU32 nbWheels, const PxU32 nbAntirolls, const PxU32 maxNbPhysxMaterialFrictions, const PxU64 contextHandle, PxAllocatorCallback& allocator); /** \brief Destroy the PxVehiclePvdObjectHandles instance created by PxVehiclePvdObjectCreate(). \param[in] omniWriter is used to register the attribute handles with omnipvd. \param[in] allocator must be the instance used by PxVehiclePvdObjectCreate(). \param[in] objectHandles is the PxVehiclePvdObjectHandles that was created by PxVehiclePvdObjectCreate(). */ void PxVehiclePvdObjectRelease (OmniPvdWriter& omniWriter, PxAllocatorCallback& allocator, PxVehiclePvdObjectHandles& objectHandles); #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
4,592
C
41.527777
161
0.802918
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/pvd/PxVehiclePvdComponents.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "vehicle2/PxVehicleComponent.h" #include "vehicle2/PxVehicleParams.h" #include "PxVehiclePvdFunctions.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif #define VEHICLE_FLOAT_ARRAY_DATA(b) PxVehicleArrayData<PxReal> b; b.setEmpty(); #define VEHICLE_ARRAY_DATA(a, b) PxVehicleArrayData<const a> b; b.setEmpty(); #define VEHICLE_SIZED_ARRAY_DATA(a, b) PxVehicleSizedArrayData<const a> b; b.setEmpty(); class PxVehiclePVDComponent : public PxVehicleComponent { public: PxVehiclePVDComponent() : PxVehicleComponent() , firstTime(true) {} virtual ~PxVehiclePVDComponent() {} virtual void getDataForPVDComponent( const PxVehicleAxleDescription*& axleDescription, const PxVehicleRigidBodyParams*& rbodyParams, const PxVehicleRigidBodyState*& rbodyState, const PxVehicleSuspensionStateCalculationParams*& suspStateCalcParams, PxVehicleSizedArrayData<const PxVehicleBrakeCommandResponseParams>& brakeResponseParams, const PxVehicleSteerCommandResponseParams*& steerResponseParams, const PxVehicleAckermannParams*& ackermannParams, PxVehicleArrayData<PxReal>& brakeResponseStates, PxVehicleArrayData<PxReal>& steerResponseStates, PxVehicleArrayData<const PxVehicleWheelParams>& wheelParams, PxVehicleArrayData<const PxVehicleWheelActuationState>& wheelActuationStates, PxVehicleArrayData<const PxVehicleWheelRigidBody1dState>& wheelRigidBody1dStates, PxVehicleArrayData<const PxVehicleWheelLocalPose>& wheelLocalPoses, PxVehicleArrayData<const PxVehicleRoadGeometryState>& roadGeomStates, PxVehicleArrayData<const PxVehicleSuspensionParams>& suspParams, PxVehicleArrayData<const PxVehicleSuspensionComplianceParams>& suspCompParams, PxVehicleArrayData<const PxVehicleSuspensionForceParams>& suspForceParams, PxVehicleArrayData<const PxVehicleSuspensionState>& suspStates, PxVehicleArrayData<const PxVehicleSuspensionComplianceState>& suspCompStates, PxVehicleArrayData<const PxVehicleSuspensionForce>& suspForces, PxVehicleArrayData<const PxVehicleTireForceParams>& tireForceParams, PxVehicleArrayData<const PxVehicleTireDirectionState>& tireDirectionStates, PxVehicleArrayData<const PxVehicleTireSpeedState>& tireSpeedStates, PxVehicleArrayData<const PxVehicleTireSlipState>& tireSlipStates, PxVehicleArrayData<const PxVehicleTireStickyState>& tireStickyStates, PxVehicleArrayData<const PxVehicleTireGripState>& tireGripStates, PxVehicleArrayData<const PxVehicleTireCamberAngleState>& tireCamberStates, PxVehicleArrayData<const PxVehicleTireForce>& tireForces, PxVehicleSizedArrayData<const PxVehicleAntiRollForceParams>& antiRollForceParams, const PxVehicleAntiRollTorque*& antiRollTorque, const PxVehicleCommandState*& commandState, const PxVehicleDirectDriveThrottleCommandResponseParams*& directDriveThrottleResponseParams, const PxVehicleDirectDriveTransmissionCommandState*& directDriveTransmissionState, PxVehicleArrayData<PxReal>& directDrivethrottleResponseState, const PxVehicleClutchCommandResponseParams*& clutchResponseParams, const PxVehicleClutchParams*& clutchParams, const PxVehicleEngineParams*& engineParams, const PxVehicleGearboxParams*& gearboxParams, const PxVehicleAutoboxParams*& autoboxParams, const PxVehicleMultiWheelDriveDifferentialParams*& multiWheelDiffParams, const PxVehicleFourWheelDriveDifferentialParams*& fourWheelDiffParams, const PxVehicleTankDriveDifferentialParams*& tankDiffParams, const PxVehicleEngineDriveTransmissionCommandState*& engineDriveTransmissionState, const PxVehicleTankDriveTransmissionCommandState*& tankDriveTransmissionState, const PxVehicleClutchCommandResponseState*& clutchResponseState, const PxVehicleEngineDriveThrottleCommandResponseState*& engineDriveThrottleResponseState, const PxVehicleEngineState*& engineState, const PxVehicleGearboxState*& gearboxState, const PxVehicleAutoboxState*& autoboxState, const PxVehicleDifferentialState*& diffState, const PxVehicleClutchSlipState*& clutchSlipState, PxVehicleArrayData<const PxVehiclePhysXSuspensionLimitConstraintParams>& physxConstraintParams, PxVehicleArrayData<const PxVehiclePhysXMaterialFrictionParams>& physxMaterialFrictionParams, const PxVehiclePhysXActor*& physxActor, const PxVehiclePhysXRoadGeometryQueryParams*& physxRoadGeomQryParams, PxVehicleArrayData<const PxVehiclePhysXRoadGeometryQueryState>& physxRoadGeomStates, PxVehicleArrayData<const PxVehiclePhysXConstraintState>& physxConstraintStates, const PxVehiclePhysXSteerState*& physxSteerState, PxVehiclePvdObjectHandles*& objectHandles) = 0; virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context) { PX_UNUSED(dt); PX_UNUSED(context); OmniPvdWriter* pvdWriter = context.pvdContext.writer; if(!context.pvdContext.attributeHandles || !pvdWriter) return true; const PxVehicleAxleDescription* axleDesc = NULL; const PxVehicleRigidBodyParams* rbodyParams = NULL; const PxVehicleRigidBodyState* rbodyState = NULL; const PxVehicleSuspensionStateCalculationParams* suspStateCalcParams = NULL; VEHICLE_SIZED_ARRAY_DATA(PxVehicleBrakeCommandResponseParams, brakeResponseParams); const PxVehicleSteerCommandResponseParams* steerResponseParams = NULL; const PxVehicleAckermannParams* ackermannParams = NULL; VEHICLE_FLOAT_ARRAY_DATA(brakeResponseStates); VEHICLE_FLOAT_ARRAY_DATA(steerResponseStates); VEHICLE_ARRAY_DATA(PxVehicleWheelParams, wheelParams); VEHICLE_ARRAY_DATA(PxVehicleWheelActuationState, wheelActuationStates); VEHICLE_ARRAY_DATA(PxVehicleWheelRigidBody1dState, wheelRigidBody1dStates); VEHICLE_ARRAY_DATA(PxVehicleWheelLocalPose, wheelLocalPoses); VEHICLE_ARRAY_DATA(PxVehicleRoadGeometryState, roadGeomStates); VEHICLE_ARRAY_DATA(PxVehicleSuspensionParams, suspParams); VEHICLE_ARRAY_DATA(PxVehicleSuspensionComplianceParams, suspComplianceParams); VEHICLE_ARRAY_DATA(PxVehicleSuspensionForceParams, suspForceParams); VEHICLE_ARRAY_DATA(PxVehicleSuspensionState, suspStates); VEHICLE_ARRAY_DATA(PxVehicleSuspensionComplianceState, suspComplianceStates); VEHICLE_ARRAY_DATA(PxVehicleSuspensionForce, suspForces); VEHICLE_ARRAY_DATA(PxVehicleTireForceParams, tireForceParams); VEHICLE_ARRAY_DATA(PxVehicleTireDirectionState, tireDirectionStates); VEHICLE_ARRAY_DATA(PxVehicleTireSpeedState, tireSpeedStates); VEHICLE_ARRAY_DATA(PxVehicleTireSlipState, tireSlipStates); VEHICLE_ARRAY_DATA(PxVehicleTireStickyState, tireStickyStates); VEHICLE_ARRAY_DATA(PxVehicleTireGripState, tireGripStates); VEHICLE_ARRAY_DATA(PxVehicleTireCamberAngleState, tireCamberStates); VEHICLE_ARRAY_DATA(PxVehicleTireForce, tireForces); VEHICLE_SIZED_ARRAY_DATA(PxVehicleAntiRollForceParams, antiRollParams); const PxVehicleAntiRollTorque* antiRollTorque = NULL; const PxVehicleCommandState* commandState = NULL; const PxVehicleDirectDriveThrottleCommandResponseParams* directDriveThrottleResponseParams = NULL; const PxVehicleDirectDriveTransmissionCommandState* directDriveTransmissionState = NULL; VEHICLE_FLOAT_ARRAY_DATA(directDrivethrottleResponseState); const PxVehicleClutchCommandResponseParams* clutchResponseParams = NULL; const PxVehicleClutchParams* clutchParams = NULL; const PxVehicleEngineParams* engineParams = NULL; const PxVehicleGearboxParams* gearboxParams = NULL; const PxVehicleAutoboxParams* autoboxParams = NULL; const PxVehicleMultiWheelDriveDifferentialParams* multiWheelDiffParams = NULL; const PxVehicleFourWheelDriveDifferentialParams* fourWheelDiffParams = NULL; const PxVehicleTankDriveDifferentialParams* tankDiffParams = NULL; const PxVehicleEngineDriveTransmissionCommandState* engineDriveTransmissionCommandState = NULL; const PxVehicleTankDriveTransmissionCommandState* tankDriveTransmissionCommandState = NULL; const PxVehicleClutchCommandResponseState* clutchResponseState = NULL; const PxVehicleEngineDriveThrottleCommandResponseState* throttleResponseState = NULL; const PxVehicleEngineState* engineState = NULL; const PxVehicleGearboxState* gearboxState = NULL; const PxVehicleAutoboxState* autoboxState = NULL; const PxVehicleDifferentialState* diffState = NULL; const PxVehicleClutchSlipState* clutchSlipState = NULL; VEHICLE_ARRAY_DATA(PxVehiclePhysXSuspensionLimitConstraintParams, physxConstraintParams); VEHICLE_ARRAY_DATA(PxVehiclePhysXMaterialFrictionParams, physxMaterialFrictionParams); const PxVehiclePhysXActor* physxActor = NULL; const PxVehiclePhysXRoadGeometryQueryParams* physxRoadGeomQryParams = NULL; VEHICLE_ARRAY_DATA(PxVehiclePhysXRoadGeometryQueryState, physxRoadGeomStates); VEHICLE_ARRAY_DATA(PxVehiclePhysXConstraintState, physxConstraintStates); const PxVehiclePhysXSteerState* physxSteerState = NULL; PxVehiclePvdObjectHandles* omniPvdObjectHandles = NULL; getDataForPVDComponent( axleDesc, rbodyParams, rbodyState, suspStateCalcParams, brakeResponseParams, steerResponseParams, ackermannParams, brakeResponseStates, steerResponseStates, wheelParams, wheelActuationStates, wheelRigidBody1dStates, wheelLocalPoses, roadGeomStates, suspParams, suspComplianceParams, suspForceParams, suspStates, suspComplianceStates, suspForces, tireForceParams, tireDirectionStates, tireSpeedStates, tireSlipStates, tireStickyStates, tireGripStates, tireCamberStates, tireForces, antiRollParams, antiRollTorque, commandState, directDriveThrottleResponseParams, directDriveTransmissionState, directDrivethrottleResponseState, clutchResponseParams, clutchParams, engineParams, gearboxParams, autoboxParams, multiWheelDiffParams, fourWheelDiffParams, tankDiffParams, engineDriveTransmissionCommandState, tankDriveTransmissionCommandState, clutchResponseState, throttleResponseState, engineState, gearboxState, autoboxState, diffState, clutchSlipState, physxConstraintParams, physxMaterialFrictionParams, physxActor, physxRoadGeomQryParams, physxRoadGeomStates, physxConstraintStates, physxSteerState, omniPvdObjectHandles); if(!omniPvdObjectHandles) return true; if(firstTime) { PxVehiclePvdRigidBodyRegister( rbodyParams, rbodyState, *context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter); PxVehiclePvdSuspensionStateCalculationParamsRegister( suspStateCalcParams, *context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter); PxVehiclePvdCommandResponseRegister( brakeResponseParams, steerResponseParams, ackermannParams, brakeResponseStates, steerResponseStates, *context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter); PxVehiclePvdWheelAttachmentsRegister( *axleDesc, wheelParams, wheelActuationStates, wheelRigidBody1dStates, wheelLocalPoses, roadGeomStates, suspParams, suspComplianceParams, suspForceParams, suspStates, suspComplianceStates, suspForces, tireForceParams, tireDirectionStates, tireSpeedStates, tireSlipStates, tireStickyStates, tireGripStates, tireCamberStates, tireForces, *context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter); PxVehiclePvdAntiRollsRegister( antiRollParams, antiRollTorque, *context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter); if (engineParams) { PxVehiclePvdEngineDrivetrainRegister( commandState, engineDriveTransmissionCommandState, tankDriveTransmissionCommandState, clutchResponseParams, clutchParams, engineParams, gearboxParams, autoboxParams, multiWheelDiffParams, fourWheelDiffParams, tankDiffParams, clutchResponseState, throttleResponseState, engineState, gearboxState, autoboxState, diffState, clutchSlipState, *context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter); } else { PxVehiclePvdDirectDrivetrainRegister( commandState, directDriveTransmissionState, directDriveThrottleResponseParams, directDrivethrottleResponseState, *context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter); } PxVehiclePvdPhysXWheelAttachmentRegister( *axleDesc, physxConstraintParams, physxMaterialFrictionParams, physxActor, physxRoadGeomQryParams, physxRoadGeomStates, physxConstraintStates, *context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter); PxVehiclePvdPhysXRigidActorRegister( physxActor, *context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter); PxVehiclePvdPhysXSteerStateRegister( physxSteerState, *context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter); firstTime = false; } PxVehiclePvdRigidBodyWrite( rbodyParams, rbodyState, *context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter); PxVehiclePvdSuspensionStateCalculationParamsWrite( suspStateCalcParams, *context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter); PxVehiclePvdCommandResponseWrite( *axleDesc, brakeResponseParams, steerResponseParams, ackermannParams, brakeResponseStates, steerResponseStates, *context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter); PxVehiclePvdWheelAttachmentsWrite( *axleDesc, wheelParams, wheelActuationStates, wheelRigidBody1dStates, wheelLocalPoses, roadGeomStates, suspParams, suspComplianceParams, suspForceParams, suspStates, suspComplianceStates, suspForces, tireForceParams, tireDirectionStates, tireSpeedStates, tireSlipStates, tireStickyStates, tireGripStates, tireCamberStates, tireForces, *context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter); PxVehiclePvdAntiRollsWrite( antiRollParams, antiRollTorque, *context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter); if (engineParams) { PxVehiclePvdEngineDrivetrainWrite( commandState, engineDriveTransmissionCommandState, tankDriveTransmissionCommandState, clutchResponseParams, clutchParams, engineParams, gearboxParams, autoboxParams, multiWheelDiffParams, fourWheelDiffParams, tankDiffParams, clutchResponseState, throttleResponseState, engineState, gearboxState, autoboxState, diffState, clutchSlipState, *context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter); } else { PxVehiclePvdDirectDrivetrainWrite( *axleDesc, commandState, directDriveTransmissionState, directDriveThrottleResponseParams, directDrivethrottleResponseState, *context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter); } PxVehiclePvdPhysXWheelAttachmentWrite( *axleDesc, physxConstraintParams, physxMaterialFrictionParams, physxActor, physxRoadGeomQryParams, physxRoadGeomStates, physxConstraintStates, *context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter); PxVehiclePvdPhysXRigidActorWrite( physxActor, *context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter); PxVehiclePvdPhysXSteerStateWrite( physxSteerState, *context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter); return true; } private: bool firstTime; }; #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
16,980
C
46.699438
117
0.824912
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/steering/PxVehicleSteeringFunctions.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "foundation/PxPreprocessor.h" #include "foundation/PxSimpleTypes.h" #include "vehicle2/PxVehicleParams.h" #include "PxVehicleSteeringParams.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif struct PxVehicleCommandState; /** \brief Compute the yaw angle response to a steer command. \param[in] steer is the input steer command value. \param[in] longitudinalSpeed is the longitudinal speed of the vehicle. \param[in] wheelId specifies the wheel to have its steer response computed. \param[in] steerResponseParmas specifies the per wheel yaw angle response to the steer command as a nonlinear function of steer command and longitudinal speed. \param[out] steerResponseState is the yaw angle response to the input steer command. */ void PxVehicleSteerCommandResponseUpdate (const PxReal steer, const PxReal longitudinalSpeed, const PxU32 wheelId, const PxVehicleSteerCommandResponseParams& steerResponseParmas, PxReal& steerResponseState); /** \brief Account for Ackermann correction by modifying the per wheel steer response multipliers to engineer an asymmetric steer response across axles. \param[in] steer is the input steer command value. \param[in] steerResponseParmas describes the maximum response and a response multiplier per axle. \param[in] ackermannParams is an array that describes the wheels affected by Ackerman steer correction. \param[in,out] steerResponseStates contains the corrected per wheel steer response multipliers that take account of Ackermann steer correction. */ void PxVehicleAckermannSteerUpdate (const PxReal steer, const PxVehicleSteerCommandResponseParams& steerResponseParmas, const PxVehicleSizedArrayData<const PxVehicleAckermannParams>& ackermannParams, PxVehicleArrayData<PxReal>& steerResponseStates); #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
3,599
C
43.444444
159
0.789664
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/steering/PxVehicleSteeringParams.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "foundation/PxFoundation.h" #include "vehicle2/PxVehicleParams.h" #include "vehicle2/commands/PxVehicleCommandParams.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif struct PxVehicleFrame; struct PxVehicleScale; /** \brief Distribute a steer response to the wheels of a vehicle. \note The steer angle applied to each wheel on the ith wheel is steerCommand * maxResponse * wheelResponseMultipliers[i]. \note A typical use case is to set maxResponse to be the vehicle's maximum achievable steer angle that occurs when the steer command is equal to 1.0. The array wheelResponseMultipliers[i] would then be used to specify the maximum achievable steer angle per wheel as a fractional multiplier of the vehicle's maximum achievable steer angle. */ struct PxVehicleSteerCommandResponseParams : public PxVehicleCommandResponseParams { PX_FORCE_INLINE PxVehicleSteerCommandResponseParams transformAndScale( const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const { PX_UNUSED(srcFrame); PX_UNUSED(trgFrame); PX_UNUSED(srcScale); PX_UNUSED(trgScale); return *this; } PX_FORCE_INLINE bool isValid(const PxVehicleAxleDescription& axleDesc) const { if (!axleDesc.isValid()) return false; for (PxU32 i = 0; i < axleDesc.nbWheels; i++) { PX_CHECK_AND_RETURN_VAL(PxAbs(maxResponse*wheelResponseMultipliers[axleDesc.wheelIdsInAxleOrder[i]]) <= PxPi, "PxVehicleSteerCommandResponseParams.maxResponse*PxVehicleSteerCommandResponseParams.wheelResponseMultipliers[i] must be in range [-Pi, Pi]", false); } return true; } }; /** \brief A description of a single axle that is to be affected by Ackermann steer correction. */ struct PxVehicleAckermannParams { PxU32 wheelIds[2]; //!< wheelIds[0] is the id of the wheel that is negative along the lateral axis, wheelIds[1] is the wheel id that is positive along the lateral axis. PxReal wheelBase; //!< wheelBase is the longitudinal distance between the axle that is affected by Ackermann correction and a reference axle. PxReal trackWidth; //!< trackWidth is the width of the axle specified by #wheelIds PxReal strength; //!< is the strength of the correction with 0 denoting no correction and 1 denoting perfect correction. PX_FORCE_INLINE bool isValid(const PxVehicleAxleDescription& axleDesc) const { PX_CHECK_AND_RETURN_VAL(0.0f == strength || wheelIds[0] < axleDesc.getNbWheels(), "PxVehicleAckermannParams.wheelIds[0] must be valid wheel", false); PX_CHECK_AND_RETURN_VAL(0.0f == strength || wheelIds[1] < axleDesc.getNbWheels(), "PxVehicleAckermannParams.wheelIds[1] must be a valid wheel", false); PX_CHECK_AND_RETURN_VAL(0.0f == strength || wheelIds[0] != wheelIds[1], "PxVehicleAckermannParams.wheelIds[0] and PxVehicleAckermannParams.wheelIds[1] must reference two different wheels", false); PX_CHECK_AND_RETURN_VAL(0.0f == strength || wheelBase > 0.0f, "PxVehicleAckermannParams.wheelBase must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(0.0f == strength || trackWidth > 0.0f, "PxVehicleAckermannParams.trackWidth must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(strength >= 0.0f && strength <= 1.0f, "PxVehicleAckermannParams.strength must be in range [0,1]", false); PX_UNUSED(axleDesc); return true; } PX_FORCE_INLINE PxVehicleAckermannParams transformAndScale( const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const { PX_UNUSED(srcFrame); PX_UNUSED(trgFrame); PxVehicleAckermannParams r = *this; const PxReal scale = trgScale.scale / srcScale.scale; r.wheelBase *= scale; r.trackWidth *= scale; return r; } }; #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
5,575
C
44.333333
198
0.763408
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/commands/PxVehicleCommandStates.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "foundation/PxPreprocessor.h" #include "foundation/PxSimpleTypes.h" #include "foundation/PxMemory.h" #include "vehicle2/PxVehicleLimits.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif /** \brief A description of the state of commands that are applied to the vehicle \note brakes[0] and brakes[1] may be used to distinguish brake and handbrake controls. */ struct PxVehicleCommandState { PxReal brakes[2]; //!< The instantaneous state of the brake controllers in range [0,1] with 1 denoting fully pressed and 0 fully depressed. PxU32 nbBrakes; //|< The number of brake commands. PxReal throttle; //!< The instantaneous state of the throttle controller in range [0,1] with 1 denoting fully pressed and 0 fully depressed. PxReal steer; //!< The instantaneous state of the steer controller in range [-1,1]. PX_FORCE_INLINE void setToDefault() { PxMemZero(this, sizeof(PxVehicleCommandState)); } }; /** \brief A description of the state of transmission-related commands that are applied to a vehicle with direct drive. */ struct PxVehicleDirectDriveTransmissionCommandState { /** \brief Direct drive vehicles only have reverse, neutral or forward gear. */ enum Enum { eREVERSE = 0, eNEUTRAL, eFORWARD }; Enum gear; //!< The desired gear of the input gear controller. PX_FORCE_INLINE void setToDefault() { PxMemZero(this, sizeof(PxVehicleDirectDriveTransmissionCommandState)); } }; /** \brief A description of the state of transmission-related commands that are applied to a vehicle with engine drive. */ struct PxVehicleEngineDriveTransmissionCommandState { enum Enum { /** \brief Special gear value to denote the automatic shift mode (often referred to as DRIVE). When using automatic transmission, setting this value as target gear will enable automatic gear shifts between first and highest gear. If the current gear is a reverse gear or the neutral gear, then this value will trigger a shift to first gear. If this value is used even though there is no automatic transmission available, the gear state will remain unchanged. */ eAUTOMATIC_GEAR = 0xff }; PxReal clutch; //!< The instantaneous state of the clutch controller in range [0,1] with 1 denoting fully pressed and 0 fully depressed. PxU32 targetGear; //!< The desired gear of the input gear controller. PX_FORCE_INLINE void setToDefault() { PxMemZero(this, sizeof(PxVehicleEngineDriveTransmissionCommandState)); } }; /** \brief A description of the state of transmission-related commands that are applied to a vehicle with tank drive. */ struct PxVehicleTankDriveTransmissionCommandState : public PxVehicleEngineDriveTransmissionCommandState { /** \brief The wheels of each tank track are either all connected to thrusts[0] or all connected to thrusts[1]. \note The thrust commands are used to divert torque from the engine to the wheels of the tank tracks controlled by each thrust. \note thrusts[0] and thrusts[1] are in range [-1,1] with the sign dictating whether the thrust will be applied positively or negatively with respect to the gearing ratio. */ PxReal thrusts[2]; PX_FORCE_INLINE void setToDefault() { PxMemZero(this, sizeof(PxVehicleTankDriveTransmissionCommandState)); } }; #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
5,088
C
35.092198
171
0.760024
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/commands/PxVehicleCommandHelpers.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "vehicle2/PxVehicleParams.h" #include "PxVehicleCommandParams.h" #include "PxVehicleCommandStates.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif /** \brief Compute the linear response to a command. \param[in] command is a normalised command value. \param[in] wheelId specifies the wheel that is to respond to the command. \param[in] responseParams specifies the wheel responses for all wheels on a vehicle. \return The linear response of the specified wheel to the command. */ PX_FORCE_INLINE PxReal PxVehicleLinearResponseCompute (const PxReal command, const PxU32 wheelId, const PxVehicleCommandResponseParams& responseParams) { return command*responseParams.maxResponse*responseParams.wheelResponseMultipliers[wheelId]; } /** \brief Compute the non-linear response to a command. \param[in] command is a normalised command value. \param[in] longitudinalSpeed is the longitudional speed of the vehicle. \param[in] wheelId specifies the wheel that is to respond to the command. \param[in] responseParams specifies the wheel responses for all wheels on a vehicle. \note responseParams is used to compute an interpolated normalized response to the combination of command and longitudinalSpeed. The interpolated normalized response is then used in place of the command as input to PxVehicleComputeLinearResponse(). */ PxReal PxVehicleNonLinearResponseCompute (const PxReal command, const PxReal longitudinalSpeed, const PxU32 wheelId, const PxVehicleCommandResponseParams& responseParams); #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
3,347
C
42.480519
130
0.782193
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/commands/PxVehicleCommandParams.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "foundation/PxFoundation.h" #include "vehicle2/PxVehicleLimits.h" #include "vehicle2/PxVehicleParams.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif /** \brief Each command value may be associated with a table specifying a normalized response as a function of longitudinal speed. Multiple instances of PxVehicleCommandValueResponseTable allow a normalized response to be authored as a multi-variate piecewise polynomial with normalized command response expressed as a nonlinear function of command value and speed. */ struct PxVehicleCommandValueResponseTable { enum Enum { eMAX_NB_SPEED_RESPONSES = 64 }; /** \brief The command value associated with the table of speed responses. */ PxReal commandValue; /** \brief A lookup table specifying the normalised response to the specified command value as a function of longitudinal speed. \note Each entry in the speedResponses table must be of the form (speed, normalizedResponse). \note The longitudinal speeds in the table must form a strictly increasing series. \note The normalized responses must be in range [0, 1]. */ PxVehicleFixedSizeLookupTable<PxReal, eMAX_NB_SPEED_RESPONSES> speedResponses; }; /** \note Brake, drive and steer response typically reduce at increased longitudinal speed. Moreover, response to a brake, throttle or steer command is typically nonlinear and may be subject to dead zones where response is constant with either zero or non-zero response. PxVehicleCommandNonLinearResponseParams allows command responses to be authored as multi-variate piecewise polynomials with normalized command response a function of command value and longitudinal speed. */ class PxVehicleCommandNonLinearResponseParams { public: enum Enum { eMAX_NB_COMMAND_VALUES = 8 }; PxVehicleCommandNonLinearResponseParams() : nbSpeedResponses(0), nbCommandValues(0) { } void clear() { nbCommandValues = 0; nbSpeedResponses = 0; } /** \brief Add a table of normalised response vs speed and associated it with a specified command value. \note commandValueSpeedResponses must be authored as a series of strictly increasing speeds with form {speed, normalizedResponse} \note The responses added must form a series of strictly increasing command values. */ bool addResponse(const PxVehicleCommandValueResponseTable& commandValueSpeedResponses) { const PxReal commandValue = commandValueSpeedResponses.commandValue; const PxReal* speeds = commandValueSpeedResponses.speedResponses.xVals; const PxReal* responses = commandValueSpeedResponses.speedResponses.yVals; const PxU16 nb = PxU16(commandValueSpeedResponses.speedResponses.nbDataPairs); PX_CHECK_AND_RETURN_VAL(commandValue >= 0.0f && commandValue <= 1.0f, "PxVehicleCommandAndResponseTable::commandValue must be in range [0, 1]", false); PX_CHECK_AND_RETURN_VAL(nbCommandValues < eMAX_NB_COMMAND_VALUES, "PxVehicleNonLinearCommandResponse::addResponse - exceeded maximum number of command responses", false); PX_CHECK_AND_RETURN_VAL(((nbSpeedResponses + nb) <= PxVehicleCommandValueResponseTable::eMAX_NB_SPEED_RESPONSES), "PxVehicleNonLinearCommandResponse::addResponse - exceeded maximum number of command responses", false); PX_CHECK_AND_RETURN_VAL((0 == nbCommandValues) || (commandValue > commandValues[nbCommandValues - 1]), "PxVehicleNonLinearCommandResponse::addResponse - command must be part of a strictly increasing series", false); PX_CHECK_AND_RETURN_VAL(nb > 0, "PxVehicleNonLinearCommandResponse::addResponse - each command response must have at least 1 point", false); #if PX_CHECKED for (PxU32 i = 1; i < nb; i++) { PX_CHECK_AND_RETURN_VAL(speeds[i] > speeds[i - 1], "PxVehicleNonLinearCommandResponse::addResponse - speeds array must be a strictly increasing series", false); PX_CHECK_AND_RETURN_VAL(responses[i] >= 0.0f && responses[i] <= 1.0f , "PxVehicleNonLinearCommandResponse::addResponse - response must be in range [0, 1]", false); } #endif commandValues[nbCommandValues] = commandValue; nbSpeedResponsesPerCommandValue[nbCommandValues] = nb; speedResponsesPerCommandValue[nbCommandValues] = nbSpeedResponses; PxMemCopy(speedResponses + 2 * nbSpeedResponses, speeds, sizeof(PxReal)*nb); PxMemCopy(speedResponses + 2 * nbSpeedResponses + nb, responses, sizeof(PxReal)*nb); nbCommandValues++; nbSpeedResponses += nb; return true; } public: /** \brief A ragged array of speeds and normalized responses. */ PxReal speedResponses[PxVehicleCommandValueResponseTable::eMAX_NB_SPEED_RESPONSES * 2]; /** \brief The number of speeds and normalized responses. */ PxU16 nbSpeedResponses; /** \brief The table of speed responses for the ith command value begins at speedResponses[2*speedResponsesPerCommandValue[i]] */ PxU16 speedResponsesPerCommandValue[eMAX_NB_COMMAND_VALUES]; /** \brief The ith command value has N speed responses with N = nbSpeedRenponsesPerCommandValue[i]. */ PxU16 nbSpeedResponsesPerCommandValue[eMAX_NB_COMMAND_VALUES]; /** \brief The command values. */ PxReal commandValues[eMAX_NB_COMMAND_VALUES]; /** \brief The number of command values. */ PxU16 nbCommandValues; }; /** \brief A description of the per wheel response to an input command. */ struct PxVehicleCommandResponseParams { /** \brief A nonlinear response to command value expressed as a lookup table of normalized response as a function of command value and longitudinal speed. \note The effect of the default state of nonlinearResponse is a linear response to command value that is independent of longitudinal speed. */ PxVehicleCommandNonLinearResponseParams nonlinearResponse; /** \brief A description of the per wheel response multiplier to an input command. */ PxReal wheelResponseMultipliers[PxVehicleLimits::eMAX_NB_WHEELS]; /** \brief The maximum response that occurs when the wheel response multiplier has value 1.0 and nonlinearResponse is in the default state of linear response. */ PxF32 maxResponse; }; #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
7,828
C
37.566502
220
0.773633
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/physxConstraints/PxVehiclePhysXConstraintParams.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "foundation/PxFoundation.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif struct PxVehicleFrame; struct PxVehicleScale; /** \brief A description of the PhysX models employed to resolve suspension limit constraints. @see PxVehiclePhysXConstraintState */ struct PxVehiclePhysXSuspensionLimitConstraintParams { /** \brief restitution is used by the restitution model used to generate a target velocity when resolving suspension limit constraints. \note A value of 0.0 means that the restitution model is not employed. \note Restitution has no effect if directionForSuspensionLimitConstraint has value Enum::eNONE. @see Px1DConstraintFlag::eRESTITUTION @see Px1DConstraint::RestitutionModifiers::restitution */ PxReal restitution; /** \brief Set the direction to apply a constraint impulse when the suspension cannot place the wheel on the ground and simultaneously respect the limits of suspension travel. The choices are to push along the ground normal to resolve the geometric error or to push along the suspension direction. The former choice can be thought of as mimicing a force applied by the tire's contact with the ground, while the latter can be thought of as mimicing a force arising from a suspension limit spring. When the ground normal and the suspension direction are approximately aligned, both do an equivalent job of maintaining the wheel above the ground. When the vehicle is on its side, eSUSPENSION does a better job of keeping the wheels above the ground but comes at the cost of an unnaturally strong torque that can lead to unwanted self-righting behaviour. eROAD_GEOMETRY_NORMAL is a good choice to avoid self-righting behaviour and still do a reasonable job at maintaining the wheel above the ground in the event that the vehicle is tending towards a roll onto its side. eNONE should be chosen if it is desired that no extra impulse is applied when the suspension alone cannot keep the wheels above the ground plane. */ enum DirectionSpecifier { eSUSPENSION, eROAD_GEOMETRY_NORMAL, eNONE }; DirectionSpecifier directionForSuspensionLimitConstraint; PX_FORCE_INLINE PxVehiclePhysXSuspensionLimitConstraintParams transformAndScale( const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const { PX_UNUSED(srcFrame); PX_UNUSED(trgFrame); PX_UNUSED(srcScale); PX_UNUSED(trgScale); return *this; } PX_FORCE_INLINE bool isValid() const { PX_CHECK_AND_RETURN_VAL( PxVehiclePhysXSuspensionLimitConstraintParams::eSUSPENSION == directionForSuspensionLimitConstraint || PxVehiclePhysXSuspensionLimitConstraintParams::eROAD_GEOMETRY_NORMAL == directionForSuspensionLimitConstraint || PxVehiclePhysXSuspensionLimitConstraintParams::eNONE == directionForSuspensionLimitConstraint, "PxVehiclePhysXSuspensionLimitConstraintParams.directionForSuspensionLimitConstraint must have legal value", false); PX_CHECK_AND_RETURN_VAL(restitution >= 0.0f && restitution <= 1.0f, "PxVehiclePhysXSuspensionLimitConstraintParams.restitution must be in range [0, 1]", false); return true; } }; #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
4,988
C
43.945946
214
0.787089
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/physxConstraints/PxVehiclePhysXConstraintStates.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "foundation/PxAssert.h" #include "foundation/PxTransform.h" #include "extensions/PxConstraintExt.h" #include "vehicle2/PxVehicleLimits.h" #include "vehicle2/tire/PxVehicleTireStates.h" #include "PxConstraint.h" #include "PxConstraintDesc.h" #if !PX_DOXYGEN namespace physx { class PxConstraint; namespace vehicle2 { #endif /** \brief A description of the number of PxConstraintConnector instances per vehicle required to maintain suspension limit and sticky tire instances. */ struct PxVehiclePhysXConstraintLimits { enum Enum { eNB_DOFS_PER_PXCONSTRAINT = 12, eNB_DOFS_PER_WHEEL = 3, eNB_WHEELS_PER_PXCONSTRAINT = eNB_DOFS_PER_PXCONSTRAINT / eNB_DOFS_PER_WHEEL, eNB_CONSTRAINTS_PER_VEHICLE = (PxVehicleLimits::eMAX_NB_WHEELS + (eNB_WHEELS_PER_PXCONSTRAINT - 1)) / (eNB_WHEELS_PER_PXCONSTRAINT) }; }; /** \brief PxVehiclePhysXConstraintState is a data structure used to write constraint data to the internal state of the associated PxScene. @see Px1dConstraint */ struct PxVehiclePhysXConstraintState { /** \brief a boolean describing whether to trigger a low speed constraint along the tire longitudinal and lateral directions. */ bool tireActiveStatus[PxVehicleTireDirectionModes::eMAX_NB_PLANAR_DIRECTIONS]; /** \brief linear component of velocity jacobian in world space for the tire's longitudinal and lateral directions. */ PxVec3 tireLinears[PxVehicleTireDirectionModes::eMAX_NB_PLANAR_DIRECTIONS]; /** \brief angular component of velocity jacobian in world space for the tire's longitudinal and lateral directions. */ PxVec3 tireAngulars[PxVehicleTireDirectionModes::eMAX_NB_PLANAR_DIRECTIONS]; /** \brief damping coefficient applied to the tire's longitudinal and lateral velocities. The constraint sets a target velocity of 0 and the damping coefficient will impact the size of the impulse applied to reach the target. Since damping acts as a stiffness with respect to the velocity, too large a value can cause instabilities. */ PxReal tireDamping[PxVehicleTireDirectionModes::eMAX_NB_PLANAR_DIRECTIONS]; /** \brief a boolean describing whether to trigger a suspension limit constraint. */ bool suspActiveStatus; /** \brief linear component of velocity jacobian in the world frame. */ PxVec3 suspLinear; /** \brief angular component of velocity jacobian in the world frame. */ PxVec3 suspAngular; /** \brief the excess suspension compression to be resolved by the constraint that cannot be resolved due to the travel limit of the suspension spring. \note The expected error value is the excess suspension compression projected onto the ground plane normal and should have a negative sign. */ PxReal suspGeometricError; /** \brief restitution value of the restitution model used to generate a target velocity that will resolve the geometric error. \note A value of 0.0 means that the restitution model is not employed. @see Px1DConstraintFlag::eRESTITUTION @see Px1DConstraint::RestitutionModifiers::restitution */ PxReal restitution; PX_FORCE_INLINE void setToDefault() { PxMemZero(this, sizeof(PxVehiclePhysXConstraintState)); } }; //TAG:solverprepshader PX_FORCE_INLINE PxU32 vehicleConstraintSolverPrep (Px1DConstraint* constraints, PxVec3p& body0WorldOffset, PxU32 maxConstraints, PxConstraintInvMassScale&, const void* constantBlock, const PxTransform& bodyAToWorld, const PxTransform& bodyBToWorld, bool, PxVec3p& cA2w, PxVec3p& cB2w) { PX_UNUSED(maxConstraints); PX_UNUSED(body0WorldOffset); PX_UNUSED(bodyBToWorld); PX_ASSERT(bodyAToWorld.isValid()); PX_ASSERT(bodyBToWorld.isValid()); const PxVehiclePhysXConstraintState* data = static_cast<const PxVehiclePhysXConstraintState*>(constantBlock); PxU32 numActive = 0; //KS - the TGS solver will use raXn to try to add to the angular part of the linear constraints. //We overcome this by setting the ra and rb offsets to be 0. cA2w = bodyAToWorld.p; cB2w = bodyBToWorld.p; // note: this is only needed for PxSolverType::eTGS and even then it should not have an effect as // long as a constraint raises Px1DConstraintFlag::eANGULAR_CONSTRAINT //Susp limit constraints. for (PxU32 i = 0; i < PxVehiclePhysXConstraintLimits::eNB_WHEELS_PER_PXCONSTRAINT; i++) { if (data[i].suspActiveStatus) { // Going beyond max suspension compression should be treated similar to rigid body contacts. // Thus setting up constraints that try to emulate such contacts. // // linear l = contact normal = n // angular a = suspension force application offset x contact normal = cross(r, n) // // velocity at contact: // vl: part from linear vehicle velocity v // vl = dot(n, v) = dot(l, v) // // va: part from angular vehicle velocity w // va = dot(n, cross(w, r)) = dot(w, cross(r, n)) = dot(w, a) // // ve: part from excess suspension compression // ve = (geomError / dt) (note: geomError is expected to be negative here) // // velocity target vt = vl + va + ve // => should become 0 by applying positive impulse along l. If vt is positive, // nothing will happen as a negative impulse would have to be applied (but // min impulse is set to 0). If vt is negative, a positive impulse will get // applied to push vt towards 0. // Px1DConstraint& p = constraints[numActive]; p.linear0 = data[i].suspLinear; p.angular0 = data[i].suspAngular; p.geometricError = data[i].suspGeometricError; p.linear1 = PxVec3(0); p.angular1 = PxVec3(0); p.minImpulse = 0; p.maxImpulse = FLT_MAX; p.velocityTarget = 0; p.solveHint = PxConstraintSolveHint::eINEQUALITY; // note: this is only needed for PxSolverType::eTGS to not have the angular part // be modified based on the linear part during substeps. Basically, it will // disable the constraint re-projection etc. to emulate PxSolverType::ePGS. p.flags |= Px1DConstraintFlag::eANGULAR_CONSTRAINT; if (data[i].restitution > 0.0f) { p.flags |= Px1DConstraintFlag::eRESTITUTION; p.mods.bounce.restitution = data[i].restitution; p.mods.bounce.velocityThreshold = -FLT_MAX; } numActive++; } } //Sticky tire friction constraints. for (PxU32 i = 0; i < PxVehiclePhysXConstraintLimits::eNB_WHEELS_PER_PXCONSTRAINT; i++) { if (data[i].tireActiveStatus[PxVehicleTireDirectionModes::eLONGITUDINAL]) { Px1DConstraint& p = constraints[numActive]; p.linear0 = data[i].tireLinears[PxVehicleTireDirectionModes::eLONGITUDINAL]; p.angular0 = data[i].tireAngulars[PxVehicleTireDirectionModes::eLONGITUDINAL]; p.geometricError = 0.0f; p.linear1 = PxVec3(0); p.angular1 = PxVec3(0); p.minImpulse = -FLT_MAX; p.maxImpulse = FLT_MAX; p.velocityTarget = 0.0f; p.mods.spring.damping = data[i].tireDamping[PxVehicleTireDirectionModes::eLONGITUDINAL]; // note: no stiffness specified as this will have no effect with geometricError=0 p.flags = Px1DConstraintFlag::eSPRING | Px1DConstraintFlag::eACCELERATION_SPRING; p.flags |= Px1DConstraintFlag::eANGULAR_CONSTRAINT; // see explanation of same flag usage further above numActive++; } } //Sticky tire friction constraints. for (PxU32 i = 0; i < PxVehiclePhysXConstraintLimits::eNB_WHEELS_PER_PXCONSTRAINT; i++) { if (data[i].tireActiveStatus[PxVehicleTireDirectionModes::eLATERAL]) { Px1DConstraint& p = constraints[numActive]; p.linear0 = data[i].tireLinears[PxVehicleTireDirectionModes::eLATERAL]; p.angular0 = data[i].tireAngulars[PxVehicleTireDirectionModes::eLATERAL]; p.geometricError = 0.0f; p.linear1 = PxVec3(0); p.angular1 = PxVec3(0); p.minImpulse = -FLT_MAX; p.maxImpulse = FLT_MAX; p.velocityTarget = 0.0f; p.mods.spring.damping = data[i].tireDamping[PxVehicleTireDirectionModes::eLATERAL]; // note: no stiffness specified as this will have no effect with geometricError=0 p.flags = Px1DConstraintFlag::eSPRING | Px1DConstraintFlag::eACCELERATION_SPRING; p.flags |= Px1DConstraintFlag::eANGULAR_CONSTRAINT; // see explanation of same flag usage further above numActive++; } } return numActive; } PX_FORCE_INLINE void visualiseVehicleConstraint (PxConstraintVisualizer &viz, const void* constantBlock, const PxTransform& body0Transform, const PxTransform& body1Transform, PxU32 flags) { PX_UNUSED(&viz); PX_UNUSED(constantBlock); PX_UNUSED(body0Transform); PX_UNUSED(body1Transform); PX_UNUSED(flags); PX_ASSERT(body0Transform.isValid()); PX_ASSERT(body1Transform.isValid()); } class PxVehicleConstraintConnector : public PxConstraintConnector { public: PxVehicleConstraintConnector() : mVehicleConstraintState(NULL) {} PxVehicleConstraintConnector(PxVehiclePhysXConstraintState* vehicleConstraintState) : mVehicleConstraintState(vehicleConstraintState) {} ~PxVehicleConstraintConnector() {} void setConstraintState(PxVehiclePhysXConstraintState* constraintState) { mVehicleConstraintState = constraintState; } virtual void* prepareData() { return mVehicleConstraintState; } virtual const void* getConstantBlock() const { return mVehicleConstraintState; } virtual PxConstraintSolverPrep getPrep() const { return vehicleConstraintSolverPrep; } //Is this necessary if physx no longer supports double-buffering? virtual void onConstraintRelease() { } //Can be empty functions. virtual bool updatePvdProperties(physx::pvdsdk::PvdDataStream& pvdConnection, const PxConstraint* c, PxPvdUpdateType::Enum updateType) const { PX_UNUSED(pvdConnection); PX_UNUSED(c); PX_UNUSED(updateType); return true; } virtual void updateOmniPvdProperties() const { } virtual void onComShift(PxU32 actor) { PX_UNUSED(actor); } virtual void onOriginShift(const PxVec3& shift) { PX_UNUSED(shift); } virtual void* getExternalReference(PxU32& typeID) { typeID = PxConstraintExtIDs::eVEHICLE_JOINT; return this; } virtual PxBase* getSerializable() { return NULL; } private: PxVehiclePhysXConstraintState* mVehicleConstraintState; }; /** \brief A mapping between constraint state data and the associated PxConstraint instances. */ struct PxVehiclePhysXConstraints { /** \brief PxVehiclePhysXConstraintComponent writes to the constraintStates array and a callback invoked by PxScene::simulate() reads a portion from it for a block of wheels and writes that portion to an associated PxConstraint instance. */ PxVehiclePhysXConstraintState constraintStates[PxVehicleLimits::eMAX_NB_WHEELS]; /** \brief PxVehiclePhysXConstraintComponent writes to the constraintStates array and a callback invoked by PxScene::simulate() reads a portion from it for a block of wheels and writes that portion to an associated PxConstraint instance. */ PxConstraint* constraints[PxVehiclePhysXConstraintLimits::eNB_CONSTRAINTS_PER_VEHICLE]; /** \brief A constraint connector is necessary to connect each PxConstraint to a portion of the constraintStates array. */ PxVehicleConstraintConnector* constraintConnectors[PxVehiclePhysXConstraintLimits::eNB_CONSTRAINTS_PER_VEHICLE]; PX_FORCE_INLINE void setToDefault() { for (PxU32 i = 0; i < PxVehicleLimits::eMAX_NB_WHEELS; i++) { constraintStates[i].setToDefault(); } for(PxU32 i = 0; i < PxVehiclePhysXConstraintLimits::eNB_CONSTRAINTS_PER_VEHICLE; i++) { constraints[i] = NULL; constraintConnectors[i] = NULL; } } }; #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
13,146
C
35.723464
141
0.754298
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/physxConstraints/PxVehiclePhysXConstraintHelpers.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once #include "foundation/PxPreprocessor.h" /** \addtogroup vehicle2 @{ */ #if !PX_DOXYGEN namespace physx { class PxPhysics; class PxRigidBody; namespace vehicle2 { #endif struct PxVehicleAxleDescription; struct PxVehiclePhysXConstraints; /** \brief Instantiate the PhysX custom constraints. Custom constraints will resolve excess suspension compression and velocity constraints that serve as a replacement low speed tire model. \param[in] axleDescription describes the axles of the vehicle and the wheels on each axle. \param[in] physics is a PxPhysics instance. \param[in] physxActor is the vehicle's PhysX representation as a PxRigidBody \param[in] vehicleConstraints is a wrapper class that holds pointers to PhysX objects required to implement the custom constraint. */ void PxVehicleConstraintsCreate (const PxVehicleAxleDescription& axleDescription, PxPhysics& physics, PxRigidBody& physxActor, PxVehiclePhysXConstraints& vehicleConstraints); /** \brief To ensure the constraints are processed by the PhysX scene they are marked as dirty prior to each simulate step. \param[in] vehicleConstraints is a wrapper class that holds pointers to PhysX objects required to implement the custom constraint. @see PxVehicleConstraintsCreate */ void PxVehicleConstraintsDirtyStateUpdate (PxVehiclePhysXConstraints& vehicleConstraints); /** \brief Destroy the PhysX custom constraints. \param[in,out] vehicleConstraints describes the PhysX custom constraints to be released. @see PxVehicleConstraintsCreate */ void PxVehicleConstraintsDestroy (PxVehiclePhysXConstraints& vehicleConstraints); #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
3,392
C
35.483871
130
0.786851
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/physxConstraints/PxVehiclePhysXConstraintComponents.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "vehicle2/PxVehicleParams.h" #include "vehicle2/PxVehicleComponent.h" #include "vehicle2/roadGeometry/PxVehicleRoadGeometryState.h" #include "vehicle2/suspension/PxVehicleSuspensionParams.h" #include "vehicle2/suspension/PxVehicleSuspensionStates.h" #include "PxVehiclePhysXConstraintFunctions.h" #include "PxVehiclePhysXConstraintHelpers.h" #include "PxVehiclePhysXConstraintStates.h" #include "PxVehiclePhysXConstraintParams.h" #include "common/PxProfileZone.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif class PxVehiclePhysXConstraintComponent : public PxVehicleComponent { public: PxVehiclePhysXConstraintComponent() : PxVehicleComponent() {} virtual ~PxVehiclePhysXConstraintComponent() {} virtual void getDataForPhysXConstraintComponent( const PxVehicleAxleDescription*& axleDescription, const PxVehicleRigidBodyState*& rigidBodyState, PxVehicleArrayData<const PxVehicleSuspensionParams>& suspensionParams, PxVehicleArrayData<const PxVehiclePhysXSuspensionLimitConstraintParams>& suspensionLimitParams, PxVehicleArrayData<const PxVehicleSuspensionState>& suspensionStates, PxVehicleArrayData<const PxVehicleSuspensionComplianceState>& suspensionComplianceStates, PxVehicleArrayData<const PxVehicleRoadGeometryState>& wheelRoadGeomStates, PxVehicleArrayData<const PxVehicleTireDirectionState>& tireDirectionStates, PxVehicleArrayData<const PxVehicleTireStickyState>& tireStickyStates, PxVehiclePhysXConstraints*& constraints) = 0; virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context) { PX_UNUSED(dt); PX_UNUSED(context); PX_PROFILE_ZONE("PxVehiclePhysXConstraintComponent::update", 0); const PxVehicleAxleDescription* axleDescription; const PxVehicleRigidBodyState* rigidBodyState; PxVehicleArrayData<const PxVehicleSuspensionParams> suspensionParams; PxVehicleArrayData<const PxVehiclePhysXSuspensionLimitConstraintParams> suspensionLimitParams; PxVehicleArrayData<const PxVehicleSuspensionState> suspensionStates; PxVehicleArrayData<const PxVehicleSuspensionComplianceState> suspensionComplianceStates; PxVehicleArrayData<const PxVehicleRoadGeometryState> wheelRoadGeomStates; PxVehicleArrayData<const PxVehicleTireDirectionState> tireDirectionStates; PxVehicleArrayData<const PxVehicleTireStickyState> tireStickyStates; PxVehiclePhysXConstraints* constraints; getDataForPhysXConstraintComponent(axleDescription, rigidBodyState, suspensionParams, suspensionLimitParams, suspensionStates, suspensionComplianceStates, wheelRoadGeomStates, tireDirectionStates, tireStickyStates, constraints); PxVehicleConstraintsDirtyStateUpdate(*constraints); for (PxU32 i = 0; i < axleDescription->nbWheels; i++) { const PxU32 wheelId = axleDescription->wheelIdsInAxleOrder[i]; PxVehiclePhysXConstraintStatesUpdate( suspensionParams[wheelId], suspensionLimitParams[wheelId], suspensionStates[wheelId], suspensionComplianceStates[wheelId], wheelRoadGeomStates[wheelId].plane.n, context.tireStickyParams.stickyParams[PxVehicleTireDirectionModes::eLONGITUDINAL].damping, context.tireStickyParams.stickyParams[PxVehicleTireDirectionModes::eLATERAL].damping, tireDirectionStates[wheelId], tireStickyStates[wheelId], *rigidBodyState, constraints->constraintStates[wheelId]); } return true; } }; #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
5,188
C
40.846774
97
0.809946
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/physxConstraints/PxVehiclePhysXConstraintFunctions.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "foundation/PxVec3.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif struct PxVehicleSuspensionParams; struct PxVehiclePhysXSuspensionLimitConstraintParams; struct PxVehicleSuspensionState; struct PxVehicleSuspensionComplianceState; struct PxVehicleTireDirectionState; struct PxVehicleTireStickyState; struct PxVehicleRigidBodyState; struct PxVehiclePhysXConstraintState; /** \brief Read constraint data from the vehicle's internal state for a single wheel and write it to a structure that will be read by the associated PxScene and used to impose the constraints during the next PxScene::simulate() step. \param[in] suspensionParams describes the suspension frame. \param[in] suspensionLimitParams describes the restitution value applied to any constraint triggered by the suspension travel limit. \param[in] suspensionState describes the excess suspension compression beyond the suspension travel limit that will be resolved with a constraint. \param[in] suspensionComplianceState describes the effect of suspension compliance on the effective application point of the suspension force. \param[in] groundPlaneNormal The normal direction of the ground plane the wheel is driving on. A normalized vector is expected. \param[in] tireStickyDampingLong The damping coefficient to use in the constraint to approach a zero target velocity along the longitudinal tire axis. \param[in] tireStickyDampingLat Same concept as tireStickyDampingLong but for the lateral tire axis. \param[in] tireDirectionState describes the longitudinal and lateral directions of the tire in the world frame. \param[in] tireStickyState describes the low speed state of the tire in the longitudinal and lateral directions. \param[in] rigidBodyState describes the pose of the rigid body. \param[out] constraintState is the data structure that will be read by the associated PxScene in the next call to PxScene::simulate(). \note Constraints include suspension constraints to account for suspension travel limit and sticky tire constraints that bring the vehicle to rest at low longitudinal and lateral speed. */ void PxVehiclePhysXConstraintStatesUpdate (const PxVehicleSuspensionParams& suspensionParams, const PxVehiclePhysXSuspensionLimitConstraintParams& suspensionLimitParams, const PxVehicleSuspensionState& suspensionState, const PxVehicleSuspensionComplianceState& suspensionComplianceState, const PxVec3& groundPlaneNormal, const PxReal tireStickyDampingLong, const PxReal tireStickyDampingLat, const PxVehicleTireDirectionState& tireDirectionState, const PxVehicleTireStickyState& tireStickyState, const PxVehicleRigidBodyState& rigidBodyState, PxVehiclePhysXConstraintState& constraintState); #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
4,563
C
48.075268
119
0.804734
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/physxRoadGeometry/PxVehiclePhysXRoadGeometryParams.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "foundation/PxFoundation.h" #include "PxQueryFiltering.h" #if !PX_DOXYGEN namespace physx { class PxMaterial; namespace vehicle2 { #endif struct PxVehicleFrame; struct PxVehicleScale; /** \brief PhysX scene queries may be raycasts or sweeps. \note eNONE will result in no PhysX scene query. This option will not overwrite the associated PxVehicleRoadGeometryState. */ struct PxVehiclePhysXRoadGeometryQueryType { enum Enum { eNONE = 0, //!< Info about the road geometry below the wheel is provided by the user eRAYCAST, //!< The road geometry below the wheel is analyzed using a raycast query eSWEEP, //!< The road geometry below the wheel is analyzed using a sweep query eMAX_NB }; }; /** \brief A description of type of PhysX scene query and the filter data to apply to the query. */ struct PxVehiclePhysXRoadGeometryQueryParams { /** \brief The default filter data to use for the physx scene query. If per wheel filter data is provided in #filterDataEntries, then this member will be ignored. @see PxSceneQuerySystemBase::raycast @see PxSceneQuerySystemBase::sweep */ PxQueryFilterData defaultFilterData; /** \brief Array of filter data entries (one per wheel) to use for the physx scene query. A null pointer is allowed in which case #defaultFilterData will be used for all wheels. @see PxSceneQuerySystemBase::raycast @see PxSceneQuerySystemBase::sweep */ PxQueryFilterData* filterDataEntries; /** \brief A filter callback to be used by the physx scene query \note A null pointer is allowed. @see PxSceneQuerySystemBase::raycast @see PxSceneQuerySystemBase::sweep */ PxQueryFilterCallback* filterCallback; /** \brief A description of the type of physx scene query to employ. @see PxSceneQuerySystemBase::raycast @see PxSceneQuerySystemBase::sweep */ PxVehiclePhysXRoadGeometryQueryType::Enum roadGeometryQueryType; PX_FORCE_INLINE PxVehiclePhysXRoadGeometryQueryParams transformAndScale( const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const { PX_UNUSED(srcFrame); PX_UNUSED(trgFrame); PX_UNUSED(srcScale); PX_UNUSED(trgScale); return *this; } PX_FORCE_INLINE bool isValid() const { PX_CHECK_AND_RETURN_VAL(roadGeometryQueryType < PxVehiclePhysXRoadGeometryQueryType::eMAX_NB, "PxVehiclePhysXRoadGeometryQueryParams.roadGeometryQueryType has illegal value", false); return true; } }; /** A mapping between PxMaterial and a friction value to be used by the tire model. @see PxVehiclePhysXMaterialFrictionParams */ struct PxVehiclePhysXMaterialFriction { /** \brief A PxMaterial instance that is to be mapped to a friction value. */ const PxMaterial* material; /** \brief A friction value that is to be mapped to a PxMaterial instance. \note friction must have value greater than or equal to zero. <b>Range:</b> [0, inf)<br> @see PxVehicleTireGripState::friction */ PxReal friction; PX_FORCE_INLINE bool isValid() const { PX_CHECK_AND_RETURN_VAL(friction >= 0.0f, "PxVehiclePhysXMaterialFriction.friction must be greater than or equal to zero", false); return true; } }; /** \brief A mappping between PxMaterial instance and friction for multiple PxMaterial intances. */ struct PxVehiclePhysXMaterialFrictionParams { PxVehiclePhysXMaterialFriction* materialFrictions; //!< An array of mappings between PxMaterial and friction. PxU32 nbMaterialFrictions; //!< The number of mappings between PxMaterial and friction. PxReal defaultFriction; //!< A default friction value to be used in the event that the PxMaterial under the tire is not found in the array #materialFrictions. PX_FORCE_INLINE bool isValid() const { for (PxU32 i = 0; i < nbMaterialFrictions; i++) { if (!materialFrictions[i].isValid()) return false; } PX_CHECK_AND_RETURN_VAL(defaultFriction >= 0.0f, "PxVehiclePhysXMaterialFrictionParams.defaultFriction must be greater than or equal to zero", false); return true; } }; #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
5,835
C
31.603352
184
0.762982
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/physxRoadGeometry/PxVehiclePhysXRoadGeometryComponents.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "vehicle2/PxVehicleParams.h" #include "vehicle2/PxVehicleComponent.h" #include "vehicle2/commands/PxVehicleCommandHelpers.h" #include "vehicle2/roadGeometry/PxVehicleRoadGeometryState.h" #include "vehicle2/suspension/PxVehicleSuspensionParams.h" #include "vehicle2/wheel/PxVehicleWheelParams.h" #include "vehicle2/physxRoadGeometry/PxVehiclePhysXRoadGeometryFunctions.h" #include "vehicle2/physxRoadGeometry/PxVehiclePhysXRoadGeometryParams.h" #include "vehicle2/physxRoadGeometry/PxVehiclePhysXRoadGeometryState.h" #include "common/PxProfileZone.h" #if !PX_DOXYGEN namespace physx { namespace vehicle2 { #endif class PxVehiclePhysXRoadGeometrySceneQueryComponent : public PxVehicleComponent { public: PxVehiclePhysXRoadGeometrySceneQueryComponent() : PxVehicleComponent() {} virtual ~PxVehiclePhysXRoadGeometrySceneQueryComponent() {} /** \brief Provide vehicle data items for this component. \param[out] axleDescription identifies the wheels on each axle. \param[out] roadGeomParams The road geometry parameters of the vehicle. \param[out] steerResponseStates The steer response state of the wheels. \param[out] rigidBodyState The pose, velocity etc. of the vehicle rigid body. \param[out] wheelParams The wheel parameters for the wheels. \param[out] suspensionParams The suspension parameters for the wheels. \param[out] materialFrictionParams The tire friction tables for the wheels. \param[out] roadGeometryStates The detected ground surface plane, friction value etc. for the wheels. \param[out] physxRoadGeometryStates Optional buffer to store additional information about the query (like actor/shape that got hit etc.). Set to empty if not desired. */ virtual void getDataForPhysXRoadGeometrySceneQueryComponent( const PxVehicleAxleDescription*& axleDescription, const PxVehiclePhysXRoadGeometryQueryParams*& roadGeomParams, PxVehicleArrayData<const PxReal>& steerResponseStates, const PxVehicleRigidBodyState*& rigidBodyState, PxVehicleArrayData<const PxVehicleWheelParams>& wheelParams, PxVehicleArrayData<const PxVehicleSuspensionParams>& suspensionParams, PxVehicleArrayData<const PxVehiclePhysXMaterialFrictionParams>& materialFrictionParams, PxVehicleArrayData<PxVehicleRoadGeometryState>& roadGeometryStates, PxVehicleArrayData<PxVehiclePhysXRoadGeometryQueryState>& physxRoadGeometryStates) = 0; virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context) { PX_UNUSED(dt); PX_PROFILE_ZONE("PxVehiclePhysXRoadGeometrySceneQueryComponent::update", 0); const PxVehicleAxleDescription* axleDescription; const PxVehiclePhysXRoadGeometryQueryParams* roadGeomParams; PxVehicleArrayData<const PxReal> steerResponseStates; const PxVehicleRigidBodyState* rigidBodyState; PxVehicleArrayData<const PxVehicleWheelParams> wheelParams; PxVehicleArrayData<const PxVehicleSuspensionParams> suspensionParams; PxVehicleArrayData<const PxVehiclePhysXMaterialFrictionParams> materialFrictionParams; PxVehicleArrayData<PxVehicleRoadGeometryState> roadGeometryStates; PxVehicleArrayData<PxVehiclePhysXRoadGeometryQueryState> physxRoadGeometryStates; getDataForPhysXRoadGeometrySceneQueryComponent(axleDescription, roadGeomParams, steerResponseStates, rigidBodyState, wheelParams, suspensionParams, materialFrictionParams, roadGeometryStates, physxRoadGeometryStates); if (context.getType() == PxVehicleSimulationContextType::ePHYSX) { const PxVehiclePhysXSimulationContext& physxContext = static_cast<const PxVehiclePhysXSimulationContext&>(context); for(PxU32 i = 0; i < axleDescription->nbWheels; i++) { const PxU32 wheelId = axleDescription->wheelIdsInAxleOrder[i]; const PxQueryFilterData* fdPtr = roadGeomParams->filterDataEntries ? (roadGeomParams->filterDataEntries + wheelId) : &roadGeomParams->defaultFilterData; PxVehiclePhysXRoadGeometryQueryUpdate( wheelParams[wheelId], suspensionParams[wheelId], roadGeomParams->roadGeometryQueryType, roadGeomParams->filterCallback, *fdPtr, materialFrictionParams[wheelId], steerResponseStates[wheelId], *rigidBodyState, *physxContext.physxScene, physxContext.physxUnitCylinderSweepMesh, context.frame, roadGeometryStates[wheelId], !physxRoadGeometryStates.isEmpty() ? &physxRoadGeometryStates[wheelId] : NULL); } } else { PX_ALWAYS_ASSERT(); for(PxU32 i = 0; i < axleDescription->nbWheels; i++) { const PxU32 wheelId = axleDescription->wheelIdsInAxleOrder[i]; roadGeometryStates[wheelId].setToDefault(); } } return true; } }; #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
6,419
C
42.087248
156
0.796697
NVIDIA-Omniverse/PhysX/physx/include/vehicle2/physxRoadGeometry/PxVehiclePhysXRoadGeometryFunctions.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #pragma once /** \addtogroup vehicle2 @{ */ #include "foundation/PxSimpleTypes.h" #include "vehicle2/physxRoadGeometry/PxVehiclePhysXRoadGeometryParams.h" #if !PX_DOXYGEN namespace physx { class PxScene; class PxConvexMesh; namespace vehicle2 { #endif struct PxVehicleWheelParams; struct PxVehicleSuspensionParams; struct PxVehiclePhysXRoadGeometryQueryState; struct PxVehicleRigidBodyState; struct PxVehicleFrame; struct PxVehicleRoadGeometryState; /** \brief Compute the plane of the road geometry under a wheel and the tire friction of the contact. \param[in] wheelParams describes the radius and halfwidth of the wheel. \param[in] suspParams describes the frame of the suspension and wheel and the maximum suspension travel. \param[in] queryType describes what type of PhysX scene query to use (see #PxVehiclePhysXRoadGeometryQueryType). If PxVehiclePhysXRoadGeometryQueryType::eNONE is used, no work will be done. \param[in] filterCallback describes the filter callback to use for the PhysX scene query. NULL is a valid input. \param[in] filterData describes the filter data to use for the PhysX scene query. \param[in] materialFrictionParams describes a mapping between PxMaterial and friction in order to compute a tire friction value. \param[in] wheelYawAngle is the yaw angle (in radians) of the wheel. \param[in] rigidBodyState describes the pose of the rigid body. \param[in] scene is the PhysX scene that will be queried by the scene query. \param[in] unitCylinderSweepMesh is a convex cylindrical mesh of unit radius and half-width to be used in the event that a sweep query is to be used. \param[in] frame describes the lateral, longitudinal and vertical axes and is used to scale unitCylinderSweepMesh by the wheel's radius and half-width. \param[out] roadGeomState contains the plane and friction of the road geometry under the wheel. \param[out] physxRoadGeometryState Optional buffer to store additional information about the query (like actor/shape that got hit etc.). Set to NULL if not needed. \note PxVehicleRoadGeometryState::hitState will have value false in the event that the there is no reachable road geometry under the wheel and true if there is reachable road geometry under the wheel. Road geometry is considered reachable if the suspension can elongate from its reference pose far enough to place wheel on the ground. */ void PxVehiclePhysXRoadGeometryQueryUpdate (const PxVehicleWheelParams& wheelParams, const PxVehicleSuspensionParams& suspParams, const PxVehiclePhysXRoadGeometryQueryType::Enum queryType, PxQueryFilterCallback* filterCallback, const PxQueryFilterData& filterData, const PxVehiclePhysXMaterialFrictionParams& materialFrictionParams, const PxReal wheelYawAngle, const PxVehicleRigidBodyState& rigidBodyState, const PxScene& scene, const PxConvexMesh* unitCylinderSweepMesh, const PxVehicleFrame& frame, PxVehicleRoadGeometryState& roadGeomState, PxVehiclePhysXRoadGeometryQueryState* physxRoadGeometryState); #if !PX_DOXYGEN } // namespace vehicle2 } // namespace physx #endif /** @} */
4,783
C
48.833333
143
0.795317
NVIDIA-Omniverse/PhysX/physx/include/cudamanager/PxCudaContextManager.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. #ifndef PX_CUDA_CONTEXT_MANAGER_H #define PX_CUDA_CONTEXT_MANAGER_H #include "foundation/PxPreprocessor.h" #if PX_SUPPORT_GPU_PHYSX #include "foundation/PxSimpleTypes.h" #include "foundation/PxErrorCallback.h" #include "foundation/PxFlags.h" #include "PxCudaTypes.h" #if !PX_DOXYGEN namespace physx { #endif class PxCudaContext; struct PxCudaInteropRegisterFlag { enum Enum { eNONE = 0x00, eREAD_ONLY = 0x01, eWRITE_DISCARD = 0x02, eSURFACE_LDST = 0x04, eTEXTURE_GATHER = 0x08 }; }; /** \brief An interface class that the user can implement in order for PhysX to use a user-defined device memory allocator. */ class PxDeviceAllocatorCallback { public: /** \brief Allocated device memory. \param[in] ptr Pointer to store the allocated address \param[in] size The amount of memory required \return A boolean indicates the operation succeed or fail */ virtual bool memAlloc(void** ptr, size_t size) = 0; /** \brief Frees device memory. \param[in] ptr The memory to free \return A boolean indicates the operation succeed or fail */ virtual bool memFree(void* ptr) = 0; protected: virtual ~PxDeviceAllocatorCallback() {} }; /** \brief collection of set bits defined in NxCudaInteropRegisterFlag. @see NxCudaInteropRegisterFlag */ typedef PxFlags<PxCudaInteropRegisterFlag::Enum, uint32_t> PxCudaInteropRegisterFlags; PX_FLAGS_OPERATORS(PxCudaInteropRegisterFlag::Enum, uint32_t) //! \brief Descriptor used to create a PxCudaContextManager class PxCudaContextManagerDesc { public: /** * \brief The CUDA context to manage * * If left NULL, the PxCudaContextManager will create a new context. If * graphicsDevice is also not NULL, this new CUDA context will be bound to * that graphics device, enabling the use of CUDA/Graphics interop features. * * If ctx is not NULL, the specified context must be applied to the thread * that is allocating the PxCudaContextManager at creation time (aka, it * cannot be popped). The PxCudaContextManager will take ownership of the * context until the manager is released. All access to the context must be * gated by lock acquisition. * * If the user provides a context for the PxCudaContextManager, the context * _must_ have either been created on the GPU ordinal returned by * PxGetSuggestedCudaDeviceOrdinal() or on your graphics device. */ CUcontext* ctx; /** * \brief D3D device pointer or OpenGl context handle * * Only applicable when ctx is NULL, thus forcing a new context to be * created. In that case, the created context will be bound to this * graphics device. */ void* graphicsDevice; /** * \brief Application-specific GUID * * If your application employs PhysX modules that use CUDA you need to use a GUID * so that patches for new architectures can be released for your game.You can obtain a GUID for your * application from Nvidia. */ const char* appGUID; /** * \brief Application-specific device memory allocator * * the application can implement an device memory allocator, which inherites PxDeviceAllocatorCallback, and * pass that to the PxCudaContextManagerDesc. The SDK will use that allocator to allocate device memory instead of * using the defaul CUDA device memory allocator. */ PxDeviceAllocatorCallback* deviceAllocator; PX_INLINE PxCudaContextManagerDesc() : ctx (NULL), graphicsDevice (NULL), appGUID (NULL), deviceAllocator (NULL) { } }; /** \brief A cuda kernel index providing an index to the cuda module and the function name */ struct PxKernelIndex { PxU32 moduleIndex; const char* functionName; }; /** * \brief Manages thread locks, and task scheduling for a CUDA context * * A PxCudaContextManager manages access to a single CUDA context, allowing it to * be shared between multiple scenes. * The context must be acquired from the manager before using any CUDA APIs unless stated differently. * * The PxCudaContextManager is based on the CUDA driver API and explicitly does not * support the CUDA runtime API (aka, CUDART). */ class PxCudaContextManager { public: /** * \brief Schedules clear operation for a device memory buffer on the specified stream * * The cuda context will get acquired automatically */ template<typename T> void clearDeviceBufferAsync(T* deviceBuffer, PxU32 numElements, CUstream stream, PxI32 value = 0) { clearDeviceBufferAsyncInternal(deviceBuffer, numElements * sizeof(T), stream, value); } /** * \brief Copies a device buffer to the host * * The cuda context will get acquired automatically */ template<typename T> void copyDToH(T* hostBuffer, const T* deviceBuffer, PxU32 numElements) { copyDToHInternal(hostBuffer, deviceBuffer, numElements * sizeof(T)); } /** * \brief Copies a host buffer to the device * * The cuda context will get acquired automatically */ template<typename T> void copyHToD(T* deviceBuffer, const T* hostBuffer, PxU32 numElements) { copyHToDInternal(deviceBuffer, hostBuffer, numElements * sizeof(T)); } /** * \brief Schedules device to host copy operation on the specified stream * * The cuda context will get acquired automatically */ template<typename T> void copyDToHAsync(T* hostBuffer, const T* deviceBuffer, PxU32 numElements, CUstream stream) { copyDToHAsyncInternal(hostBuffer, deviceBuffer, numElements * sizeof(T), stream); } /** * \brief Schedules host to device copy operation on the specified stream * * The cuda context will get acquired automatically */ template<typename T> void copyHToDAsync(T* deviceBuffer, const T* hostBuffer, PxU32 numElements, CUstream stream) { copyHToDAsyncInternal(deviceBuffer, hostBuffer, numElements * sizeof(T), stream); } /** * \brief Schedules device to device copy operation on the specified stream * * The cuda context will get acquired automatically */ template<typename T> void copyDToDAsync(T* dstDeviceBuffer, const T* srcDeviceBuffer, PxU32 numElements, CUstream stream) { copyDToDAsyncInternal(dstDeviceBuffer, srcDeviceBuffer, numElements * sizeof(T), stream); } /** * \brief Schedules a memset operation on the device on the specified stream. Only supported for 1 byte or 4 byte data types. * * The cuda context will get acquired automatically */ template<typename T> void memsetAsync(T* dstDeviceBuffer, const T& value, PxU32 numElements, CUstream stream) { PX_COMPILE_TIME_ASSERT(sizeof(value) == sizeof(PxU32) || sizeof(value) == sizeof(PxU8)); if (sizeof(value) == sizeof(PxU32)) memsetD32AsyncInternal(dstDeviceBuffer, reinterpret_cast<const PxU32&>(value), numElements, stream); else memsetD8AsyncInternal(dstDeviceBuffer, reinterpret_cast<const PxU8&>(value), numElements, stream); } /** * \brief Allocates a device buffer * * The cuda context will get acquired automatically */ template<typename T> void allocDeviceBuffer(T*& deviceBuffer, PxU32 numElements, const char* filename = __FILE__, PxI32 line = __LINE__) { void* ptr = allocDeviceBufferInternal(PxU64(numElements) * sizeof(T), filename, line); deviceBuffer = reinterpret_cast<T*>(ptr); } /** * \brief Allocates a device buffer and returns the pointer to the memory * * The cuda context will get acquired automatically */ template<typename T> T* allocDeviceBuffer(PxU32 numElements, const char* filename = __FILE__, PxI32 line = __LINE__) { void* ptr = allocDeviceBufferInternal(PxU64(numElements) * sizeof(T), filename, line); return reinterpret_cast<T*>(ptr); } /** * \brief Frees a device buffer * * The cuda context will get acquired automatically */ template<typename T> void freeDeviceBuffer(T*& deviceBuffer) { freeDeviceBufferInternal(deviceBuffer); deviceBuffer = NULL; } /** * \brief Allocates a pinned host buffer * * A pinned host buffer can be used on the gpu after getting a mapped device pointer from the pinned host buffer pointer, see getMappedDevicePtr * The cuda context will get acquired automatically * @see getMappedDevicePtr */ template<typename T> void allocPinnedHostBuffer(T*& pinnedHostBuffer, PxU32 numElements, const char* filename = __FILE__, PxI32 line = __LINE__) { void* ptr = allocPinnedHostBufferInternal(PxU64(numElements) * sizeof(T), filename, line); pinnedHostBuffer = reinterpret_cast<T*>(ptr); } /** * \brief Allocates a pinned host buffer and returns the pointer to the memory * * A pinned host buffer can be used on the gpu after getting a mapped device pointer from the pinned host buffer pointer, see getMappedDevicePtr * The cuda context will get acquired automatically * @see getMappedDevicePtr */ template<typename T> T* allocPinnedHostBuffer(PxU32 numElements, const char* filename = __FILE__, PxI32 line = __LINE__) { void* ptr = allocPinnedHostBufferInternal(PxU64(numElements) * sizeof(T), filename, line); return reinterpret_cast<T*>(ptr); } /** * \brief Frees a pinned host buffer * * The cuda context will get acquired automatically */ template<typename T> void freePinnedHostBuffer(T*& pinnedHostBuffer) { freePinnedHostBufferInternal(pinnedHostBuffer); pinnedHostBuffer = NULL; } /** * \brief Gets a mapped pointer from a pinned host buffer that can be used in cuda kernels directly * * Data access performance with a mapped pinned host pointer will be slower than using a device pointer directly * but the changes done in the kernel will be available on the host immediately. * The cuda context will get acquired automatically */ virtual CUdeviceptr getMappedDevicePtr(void* pinnedHostBuffer) = 0; /** * \brief Acquire the CUDA context for the current thread * * Acquisitions are allowed to be recursive within a single thread. * You can acquire the context multiple times so long as you release * it the same count. * * The context must be acquired before using most CUDA functions. */ virtual void acquireContext() = 0; /** * \brief Release the CUDA context from the current thread * * The CUDA context should be released as soon as practically * possible, to allow other CPU threads to work efficiently. */ virtual void releaseContext() = 0; /** * \brief Return the CUcontext */ virtual CUcontext getContext() = 0; /** * \brief Return the CudaContext */ virtual PxCudaContext* getCudaContext() = 0; /** * \brief Context manager has a valid CUDA context * * This method should be called after creating a PxCudaContextManager, * especially if the manager was responsible for allocating its own * CUDA context (desc.ctx == NULL). */ virtual bool contextIsValid() const = 0; /* Query CUDA context and device properties, without acquiring context */ virtual bool supportsArchSM10() const = 0; //!< G80 virtual bool supportsArchSM11() const = 0; //!< G92 virtual bool supportsArchSM12() const = 0; //!< GT200 virtual bool supportsArchSM13() const = 0; //!< GT260 virtual bool supportsArchSM20() const = 0; //!< GF100 virtual bool supportsArchSM30() const = 0; //!< GK100 virtual bool supportsArchSM35() const = 0; //!< GK110 virtual bool supportsArchSM50() const = 0; //!< GM100 virtual bool supportsArchSM52() const = 0; //!< GM200 virtual bool supportsArchSM60() const = 0; //!< GP100 virtual bool isIntegrated() const = 0; //!< true if GPU is an integrated (MCP) part virtual bool canMapHostMemory() const = 0; //!< true if GPU map host memory to GPU (0-copy) virtual int getDriverVersion() const = 0; //!< returns cached value of cuGetDriverVersion() virtual size_t getDeviceTotalMemBytes() const = 0; //!< returns cached value of device memory size virtual int getMultiprocessorCount() const = 0; //!< returns cache value of SM unit count virtual unsigned int getClockRate() const = 0; //!< returns cached value of SM clock frequency virtual int getSharedMemPerBlock() const = 0; //!< returns total amount of shared memory available per block in bytes virtual int getSharedMemPerMultiprocessor() const = 0; //!< returns total amount of shared memory available per multiprocessor in bytes virtual unsigned int getMaxThreadsPerBlock() const = 0; //!< returns the maximum number of threads per block virtual const char *getDeviceName() const = 0; //!< returns device name retrieved from driver virtual CUdevice getDevice() const = 0; //!< returns device handle retrieved from driver virtual void setUsingConcurrentStreams(bool) = 0; //!< turn on/off using concurrent streams for GPU work virtual bool getUsingConcurrentStreams() const = 0; //!< true if GPU work can run in concurrent streams /* End query methods that don't require context to be acquired */ virtual void getDeviceMemoryInfo(size_t& free, size_t& total) const = 0; //!< get currently available and total memory /** * \brief Determine if the user has configured a dedicated PhysX GPU in the NV Control Panel * \note If using CUDA Interop, this will always return false * \returns 1 if there is a dedicated GPU * 0 if there is NOT a dedicated GPU * -1 if the routine is not implemented */ virtual int usingDedicatedGPU() const = 0; /** * \brief Get the cuda modules that have been loaded into this context on construction * \return Pointer to the cuda modules */ virtual CUmodule* getCuModules() = 0; /** * \brief Release the PxCudaContextManager * * If the PxCudaContextManager created the CUDA context it was * responsible for, it also frees that context. * * Do not release the PxCudaContextManager if there are any scenes * using it. Those scenes must be released first. * */ virtual void release() = 0; protected: /** * \brief protected destructor, use release() method */ virtual ~PxCudaContextManager() {} virtual void* allocDeviceBufferInternal(PxU64 numBytes, const char* filename = NULL, PxI32 line = -1) = 0; virtual void* allocPinnedHostBufferInternal(PxU64 numBytes, const char* filename = NULL, PxI32 line = -1) = 0; virtual void freeDeviceBufferInternal(void* deviceBuffer) = 0; virtual void freePinnedHostBufferInternal(void* pinnedHostBuffer) = 0; virtual void clearDeviceBufferAsyncInternal(void* deviceBuffer, PxU32 numBytes, CUstream stream, PxI32 value) = 0; virtual void copyDToHAsyncInternal(void* hostBuffer, const void* deviceBuffer, PxU32 numBytes, CUstream stream) = 0; virtual void copyHToDAsyncInternal(void* deviceBuffer, const void* hostBuffer, PxU32 numBytes, CUstream stream) = 0; virtual void copyDToDAsyncInternal(void* dstDeviceBuffer, const void* srcDeviceBuffer, PxU32 numBytes, CUstream stream) = 0; virtual void copyDToHInternal(void* hostBuffer, const void* deviceBuffer, PxU32 numBytes) = 0; virtual void copyHToDInternal(void* deviceBuffer, const void* hostBuffer, PxU32 numBytes) = 0; virtual void memsetD8AsyncInternal(void* dstDeviceBuffer, const PxU8& value, PxU32 numBytes, CUstream stream) = 0; virtual void memsetD32AsyncInternal(void* dstDeviceBuffer, const PxU32& value, PxU32 numIntegers, CUstream stream) = 0; }; #define PX_DEVICE_ALLOC(cudaContextManager, deviceBuffer, numElements) cudaContextManager->allocDeviceBuffer(deviceBuffer, numElements, PX_FL) #define PX_DEVICE_ALLOC_T(T, cudaContextManager, numElements) cudaContextManager->allocDeviceBuffer<T>(numElements, PX_FL) #define PX_DEVICE_FREE(cudaContextManager, deviceBuffer) cudaContextManager->freeDeviceBuffer(deviceBuffer); #define PX_PINNED_HOST_ALLOC(cudaContextManager, pinnedHostBuffer, numElements) cudaContextManager->allocPinnedHostBuffer(pinnedHostBuffer, numElements, PX_FL) #define PX_PINNED_HOST_ALLOC_T(T, cudaContextManager, numElements) cudaContextManager->allocPinnedHostBuffer<T>(numElements, PX_FL) #define PX_PINNED_HOST_FREE(cudaContextManager, pinnedHostBuffer) cudaContextManager->freePinnedHostBuffer(pinnedHostBuffer); /** * \brief Convenience class for holding CUDA lock within a scope */ class PxScopedCudaLock { public: /** * \brief ScopedCudaLock constructor */ PxScopedCudaLock(PxCudaContextManager& ctx) : mCtx(&ctx) { mCtx->acquireContext(); } /** * \brief ScopedCudaLock destructor */ ~PxScopedCudaLock() { mCtx->releaseContext(); } protected: /** * \brief CUDA context manager pointer (initialized in the constructor) */ PxCudaContextManager* mCtx; }; #if !PX_DOXYGEN } // namespace physx #endif #endif // PX_SUPPORT_GPU_PHYSX #endif
18,190
C
35.021782
159
0.734634
NVIDIA-Omniverse/PhysX/physx/include/cudamanager/PxCudaContext.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. #ifndef PX_CUDA_CONTEX_H #define PX_CUDA_CONTEX_H #include "foundation/PxPreprocessor.h" #if PX_SUPPORT_GPU_PHYSX #include "PxCudaTypes.h" #if !PX_DOXYGEN namespace physx { #endif struct PxCudaKernelParam { void* data; size_t size; }; // workaround for not being able to forward declare enums in PxCudaTypes.h. // provides different automatic casting depending on whether cuda.h was included beforehand or not. template<typename CUenum> struct PxCUenum { PxU32 value; PxCUenum(CUenum e) { value = PxU32(e); } operator CUenum() const { return CUenum(value); } }; #ifdef CUDA_VERSION typedef PxCUenum<CUjit_option> PxCUjit_option; typedef PxCUenum<CUresult> PxCUresult; #else typedef PxCUenum<PxU32> PxCUjit_option; typedef PxCUenum<PxU32> PxCUresult; #endif #define PX_CUDA_KERNEL_PARAM(X) { (void*)&X, sizeof(X) } #define PX_CUDA_KERNEL_PARAM2(X) (void*)&X class PxDeviceAllocatorCallback; /** Cuda Context */ class PxCudaContext { protected: virtual ~PxCudaContext() {} PxDeviceAllocatorCallback* mAllocatorCallback; public: virtual void release() = 0; virtual PxCUresult memAlloc(CUdeviceptr *dptr, size_t bytesize) = 0; virtual PxCUresult memFree(CUdeviceptr dptr) = 0; virtual PxCUresult memHostAlloc(void **pp, size_t bytesize, unsigned int Flags) = 0; virtual PxCUresult memFreeHost(void *p) = 0; virtual PxCUresult memHostGetDevicePointer(CUdeviceptr *pdptr, void *p, unsigned int Flags) = 0; virtual PxCUresult moduleLoadDataEx(CUmodule *module, const void *image, unsigned int numOptions, PxCUjit_option *options, void **optionValues) = 0; virtual PxCUresult moduleGetFunction(CUfunction *hfunc, CUmodule hmod, const char *name) = 0; virtual PxCUresult moduleUnload(CUmodule hmod) = 0; virtual PxCUresult streamCreate(CUstream *phStream, unsigned int Flags) = 0; virtual PxCUresult streamCreateWithPriority(CUstream *phStream, unsigned int flags, int priority) = 0; virtual PxCUresult streamFlush(CUstream hStream) = 0; virtual PxCUresult streamWaitEvent(CUstream hStream, CUevent hEvent, unsigned int Flags) = 0; virtual PxCUresult streamDestroy(CUstream hStream) = 0; virtual PxCUresult streamSynchronize(CUstream hStream) = 0; virtual PxCUresult eventCreate(CUevent *phEvent, unsigned int Flags) = 0; virtual PxCUresult eventRecord(CUevent hEvent, CUstream hStream) = 0; virtual PxCUresult eventQuery(CUevent hEvent) = 0; virtual PxCUresult eventSynchronize(CUevent hEvent) = 0; virtual PxCUresult eventDestroy(CUevent hEvent) = 0; virtual PxCUresult launchKernel( CUfunction f, unsigned int gridDimX, unsigned int gridDimY, unsigned int gridDimZ, unsigned int blockDimX, unsigned int blockDimY, unsigned int blockDimZ, unsigned int sharedMemBytes, CUstream hStream, PxCudaKernelParam* kernelParams, size_t kernelParamsSizeInBytes, void** extra, const char* file, int line ) = 0; // PT: same as above but without copying the kernel params to a local stack before the launch // i.e. the kernelParams data is passed directly to the kernel. virtual PxCUresult launchKernel( CUfunction f, PxU32 gridDimX, PxU32 gridDimY, PxU32 gridDimZ, PxU32 blockDimX, PxU32 blockDimY, PxU32 blockDimZ, PxU32 sharedMemBytes, CUstream hStream, void** kernelParams, void** extra, const char* file, int line ) = 0; virtual PxCUresult memcpyDtoH(void *dstHost, CUdeviceptr srcDevice, size_t ByteCount) = 0; virtual PxCUresult memcpyDtoHAsync(void* dstHost, CUdeviceptr srcDevice, size_t ByteCount, CUstream hStream) = 0; virtual PxCUresult memcpyHtoD(CUdeviceptr dstDevice, const void *srcHost, size_t ByteCount) = 0; virtual PxCUresult memcpyHtoDAsync(CUdeviceptr dstDevice, const void *srcHost, size_t ByteCount, CUstream hStream) = 0; virtual PxCUresult memcpyDtoDAsync(CUdeviceptr dstDevice, CUdeviceptr srcDevice, size_t ByteCount, CUstream hStream) = 0; virtual PxCUresult memcpyDtoD(CUdeviceptr dstDevice, CUdeviceptr srcDevice, size_t ByteCount) = 0; virtual PxCUresult memcpyPeerAsync(CUdeviceptr dstDevice, CUcontext dstContext, CUdeviceptr srcDevice, CUcontext srcContext, size_t ByteCount, CUstream hStream) = 0; virtual PxCUresult memsetD32Async(CUdeviceptr dstDevice, unsigned int ui, size_t N, CUstream hStream) = 0; virtual PxCUresult memsetD8Async(CUdeviceptr dstDevice, unsigned char uc, size_t N, CUstream hStream) = 0; virtual PxCUresult memsetD32(CUdeviceptr dstDevice, unsigned int ui, size_t N) = 0; virtual PxCUresult memsetD16(CUdeviceptr dstDevice, unsigned short uh, size_t N) = 0; virtual PxCUresult memsetD8(CUdeviceptr dstDevice, unsigned char uc, size_t N) = 0; virtual PxCUresult getLastError() = 0; PxDeviceAllocatorCallback* getAllocatorCallback() { return mAllocatorCallback; } }; #if !PX_DOXYGEN } // namespace physx #endif #endif // PX_SUPPORT_GPU_PHYSX #endif
6,486
C
33.689839
167
0.760099
NVIDIA-Omniverse/PhysX/physx/include/cudamanager/PxCudaTypes.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. #ifndef PX_CUDA_TYPES_H #define PX_CUDA_TYPES_H //type definitions to avoid forced inclusion of cuda.h //if cuda.h is needed anyway, please include it before PxCudaContextManager.h, PxCudaContext.h or PxCudaTypes.h #include "foundation/PxPreprocessor.h" #if PX_SUPPORT_GPU_PHYSX #ifndef CUDA_VERSION #include "foundation/PxSimpleTypes.h" #if PX_CLANG #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wc++98-compat-pedantic" #endif #if PX_P64_FAMILY typedef unsigned long long CUdeviceptr; #else typedef unsigned int CUdeviceptr; #endif #if PX_CLANG #pragma clang diagnostic pop #endif typedef int CUdevice; typedef struct CUctx_st* CUcontext; typedef struct CUmod_st* CUmodule; typedef struct CUfunc_st* CUfunction; typedef struct CUstream_st* CUstream; typedef struct CUevent_st* CUevent; typedef struct CUgraphicsResource_st* CUgraphicsResource; #endif #else typedef struct CUstream_st* CUstream; // We declare some callbacks taking CUstream as an argument even when building with PX_SUPPORT_GPU_PHYSX = 0. typedef struct CUevent_st* CUevent; #endif // PX_SUPPORT_GPU_PHYSX #endif
2,674
C
36.152777
147
0.777487
NVIDIA-Omniverse/PhysX/physx/include/pvd/PxPvdTransport.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_PVD_TRANSPORT_H #define PX_PVD_TRANSPORT_H /** \addtogroup pvd @{ */ #include "foundation/PxErrors.h" #include "foundation/PxFlags.h" #include "pvd/PxPvd.h" #if !PX_DOXYGEN namespace physx { #endif /** \brief PxPvdTransport is an interface representing the data transport mechanism. This class defines all services associated with the transport: configuration, connection, reading, writing etc. It is owned by the application, and can be realized as a file or a socket (using one-line PxDefault<...> methods in PhysXExtensions) or in a custom implementation. This is a class that is intended for use by PVD, not by the application, the application entry points are PxPvd and PvdClient. */ class PxPvdTransport { public: // connect, isConnected, disconnect, read, write, flush /** Connects to the Visual Debugger application. return True if success */ virtual bool connect() = 0; /** Disconnects from the Visual Debugger application. If we are still connected, this will kill the entire debugger connection. */ virtual void disconnect() = 0; /** * Return if connection to PVD is created. */ virtual bool isConnected() = 0; /** * write bytes to the other endpoint of the connection. should lock before witre. If an error occurs * this connection will assume to be dead. */ virtual bool write(const uint8_t* inBytes, uint32_t inLength) = 0; /* lock this transport and return it */ virtual PxPvdTransport& lock() = 0; /* unlock this transport */ virtual void unlock() = 0; /** * send any data and block until we know it is at least on the wire. */ virtual void flush() = 0; /** * Return size of written data. */ virtual uint64_t getWrittenDataSize() = 0; virtual void release() = 0; protected: virtual ~PxPvdTransport() { } }; /** \brief Create a default socket transport. \param host host address of the pvd application. \param port ip port used for pvd, should same as the port setting in pvd application. \param timeoutInMilliseconds timeout when connect to pvd host. */ PX_C_EXPORT PxPvdTransport* PX_CALL_CONV PxDefaultPvdSocketTransportCreate(const char* host, int port, unsigned int timeoutInMilliseconds); /** \brief Create a default file transport. \param name full path filename used save captured pvd data, or NULL for a fake/test file transport. */ PX_C_EXPORT PxPvdTransport* PX_CALL_CONV PxDefaultPvdFileTransportCreate(const char* name); #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
4,203
C
31.338461
115
0.743279
NVIDIA-Omniverse/PhysX/physx/include/pvd/PxPvd.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_PVD_H #define PX_PVD_H /** \addtogroup pvd @{ */ #include "foundation/PxFlags.h" #include "foundation/PxProfiler.h" #if !PX_DOXYGEN namespace physx { #endif class PxFoundation; class PxPvdTransport; /** \brief types of instrumentation that PVD can do. */ struct PxPvdInstrumentationFlag { enum Enum { /** \brief Send debugging information to PVD. This information is the actual object data of the rigid statics, shapes, articulations, etc. Sending this information has a noticeable impact on performance and thus this flag should not be set if you want an accurate performance profile. */ eDEBUG = 1 << 0, /** \brief Send profile information to PVD. This information populates PVD's profile view. It has (at this time) negligible cost compared to Debug information and makes PVD *much* more useful so it is quite highly recommended. This flag works together with a PxCreatePhysics parameter. Using it allows the SDK to send profile events to PVD. */ ePROFILE = 1 << 1, /** \brief Send memory information to PVD. The PVD sdk side hooks into the Foundation memory controller and listens to allocation/deallocation events. This has a noticable hit on the first frame, however, this data is somewhat compressed and the PhysX SDK doesn't allocate much once it hits a steady state. This information also has a fairly negligible impact and thus is also highly recommended. This flag works together with a PxCreatePhysics parameter, trackOutstandingAllocations. Using both of them together allows users to have an accurate view of the overall memory usage of the simulation at the cost of a hashtable lookup per allocation/deallocation. Again, PhysX makes a best effort attempt not to allocate or deallocate during simulation so this hashtable lookup tends to have no effect past the first frame. Sending memory information without tracking outstanding allocations means that PVD will accurate information about the state of the memory system before the actual connection happened. */ eMEMORY = 1 << 2, eALL = (eDEBUG | ePROFILE | eMEMORY) }; }; /** \brief Bitfield that contains a set of raised flags defined in PxPvdInstrumentationFlag. @see PxPvdInstrumentationFlag */ typedef PxFlags<PxPvdInstrumentationFlag::Enum, uint8_t> PxPvdInstrumentationFlags; PX_FLAGS_OPERATORS(PxPvdInstrumentationFlag::Enum, uint8_t) /** \brief PxPvd is the top-level class for the PVD framework, and the main customer interface for PVD configuration.It is a singleton class, instantiated and owned by the application. */ class PxPvd : public physx::PxProfilerCallback { public: /** Connects the SDK to the PhysX Visual Debugger application. \param transport transport for pvd captured data. \param flags Flags to set. return True if success */ virtual bool connect(PxPvdTransport& transport, PxPvdInstrumentationFlags flags) = 0; /** Disconnects the SDK from the PhysX Visual Debugger application. If we are still connected, this will kill the entire debugger connection. */ virtual void disconnect() = 0; /** * Return if connection to PVD is created. \param useCachedStatus 1> When useCachedStaus is false, isConnected() checks the lowlevel network status. This can be slow because it needs to lock the lowlevel network stream. If isConnected() is called frequently, the expense of locking can be significant. 2> When useCachedStatus is true, isConnected() checks the highlevel cached status with atomic access. It is faster than locking, but the status may be different from the lowlevel network with latency of up to one frame. The reason for this is that the cached status is changed inside socket listener, which is not called immediately when the lowlevel connection status changes. */ virtual bool isConnected(bool useCachedStatus = true) = 0; /** returns the PVD data transport returns NULL if no transport is present. */ virtual PxPvdTransport* getTransport() = 0; /** Retrieves the PVD flags. See PxPvdInstrumentationFlags. */ virtual PxPvdInstrumentationFlags getInstrumentationFlags() = 0; /** \brief Releases the pvd instance. */ virtual void release() = 0; protected: virtual ~PxPvd() { } }; /** \brief Create a pvd instance. \param foundation is the foundation instance that stores the allocator and error callbacks. */ PX_C_EXPORT PxPvd* PX_CALL_CONV PxCreatePvd(PxFoundation& foundation); #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
6,302
C
34.21229
114
0.749921
NVIDIA-Omniverse/PhysX/physx/include/pvd/PxPvdSceneClient.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_PVD_SCENE_CLIENT_H #define PX_PVD_SCENE_CLIENT_H /** \addtogroup pvd @{ */ #include "foundation/PxFlags.h" #if !PX_DOXYGEN namespace physx { #endif namespace pvdsdk { class PvdClient; } struct PxDebugPoint; struct PxDebugLine; struct PxDebugTriangle; struct PxDebugText; #if !PX_DOXYGEN } // namespace physx #endif #if !PX_DOXYGEN namespace physx { #endif /** \brief PVD scene Flags. They are disabled by default, and only works if PxPvdInstrumentationFlag::eDEBUG is set. */ struct PxPvdSceneFlag { enum Enum { eTRANSMIT_CONTACTS = (1 << 0), //! Transmits contact stream to PVD. eTRANSMIT_SCENEQUERIES = (1 << 1), //! Transmits scene query stream to PVD. eTRANSMIT_CONSTRAINTS = (1 << 2) //! Transmits constraints visualize stream to PVD. }; }; /** \brief Bitfield that contains a set of raised flags defined in PxPvdSceneFlag. @see PxPvdSceneFlag */ typedef PxFlags<PxPvdSceneFlag::Enum, PxU8> PxPvdSceneFlags; PX_FLAGS_OPERATORS(PxPvdSceneFlag::Enum, PxU8) /** \brief Special client for PxScene. It provides access to the PxPvdSceneFlag. It also provides simple user debug services that associated scene position such as immediate rendering and camera updates. */ class PxPvdSceneClient { public: /** Sets the PVD flag. See PxPvdSceneFlag. \param flag Flag to set. \param value value the flag gets set to. */ virtual void setScenePvdFlag(PxPvdSceneFlag::Enum flag, bool value) = 0; /** Sets the PVD flags. See PxPvdSceneFlags. \param flags Flags to set. */ virtual void setScenePvdFlags(PxPvdSceneFlags flags) = 0; /** Retrieves the PVD flags. See PxPvdSceneFlags. */ virtual PxPvdSceneFlags getScenePvdFlags() const = 0; /** update camera on PVD application's render window */ virtual void updateCamera(const char* name, const PxVec3& origin, const PxVec3& up, const PxVec3& target) = 0; /** draw points on PVD application's render window */ virtual void drawPoints(const physx::PxDebugPoint* points, PxU32 count) = 0; /** draw lines on PVD application's render window */ virtual void drawLines(const physx::PxDebugLine* lines, PxU32 count) = 0; /** draw triangles on PVD application's render window */ virtual void drawTriangles(const physx::PxDebugTriangle* triangles, PxU32 count) = 0; /** draw text on PVD application's render window */ virtual void drawText(const physx::PxDebugText& text) = 0; /** get the underlying client, for advanced users */ virtual physx::pvdsdk::PvdClient* getClientInternal() = 0; protected: virtual ~PxPvdSceneClient(){} }; #if !PX_DOXYGEN } // namespace physx #endif /** @} */ #endif
4,313
C
28.547945
122
0.743102
NVIDIA-Omniverse/PhysX/physx/include/vehicle/PxVehicleTireFriction.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_VEHICLE_TIREFRICTION_H #define PX_VEHICLE_TIREFRICTION_H #include "foundation/PxSimpleTypes.h" #include "common/PxSerialFramework.h" #if !PX_DOXYGEN namespace physx { #endif class PxMaterial; class PxCollection; class PxOutputStream; /** \brief Driving surface type. Each PxMaterial is associated with a corresponding PxVehicleDrivableSurfaceType. @see PxMaterial, PxVehicleDrivableSurfaceToTireFrictionPairs */ struct PX_DEPRECATED PxVehicleDrivableSurfaceType { enum { eSURFACE_TYPE_UNKNOWN=0xffffffff }; PxU32 mType; }; /** \brief Friction for each combination of driving surface type and tire type. @see PxVehicleDrivableSurfaceType, PxVehicleTireData::mType */ class PX_DEPRECATED PxVehicleDrivableSurfaceToTireFrictionPairs { public: friend class VehicleSurfaceTypeHashTable; enum { eMAX_NB_SURFACE_TYPES=256 }; /** \brief Allocate the memory for a PxVehicleDrivableSurfaceToTireFrictionPairs instance that can hold data for combinations of tire type and surface type with up to maxNbTireTypes types of tire and maxNbSurfaceTypes types of surface. \param[in] maxNbTireTypes is the maximum number of allowed tire types. \param[in] maxNbSurfaceTypes is the maximum number of allowed surface types. Must be less than or equal to eMAX_NB_SURFACE_TYPES \return a PxVehicleDrivableSurfaceToTireFrictionPairs instance that can be reused later with new type and friction data. @see setup */ static PxVehicleDrivableSurfaceToTireFrictionPairs* allocate (const PxU32 maxNbTireTypes, const PxU32 maxNbSurfaceTypes); /** \brief Set up a PxVehicleDrivableSurfaceToTireFrictionPairs instance for combinations of nbTireTypes tire types and nbSurfaceTypes surface types. \param[in] nbTireTypes is the number of different types of tire. This value must be less than or equal to maxNbTireTypes specified in allocate(). \param[in] nbSurfaceTypes is the number of different types of surface. This value must be less than or equal to maxNbSurfaceTypes specified in allocate(). \param[in] drivableSurfaceMaterials is an array of PxMaterial pointers of length nbSurfaceTypes. \param[in] drivableSurfaceTypes is an array of PxVehicleDrivableSurfaceType instances of length nbSurfaceTypes. \note If the pointer to the PxMaterial that touches the tire is found in drivableSurfaceMaterials[x] then the surface type is drivableSurfaceTypes[x].mType and the friction is the value that is set with setTypePairFriction(drivableSurfaceTypes[x].mType, PxVehicleTireData::mType, frictionValue). \note A friction value of 1.0 will be assigned as default to each combination of tire and surface type. To override this use setTypePairFriction. @see release, setTypePairFriction, getTypePairFriction, PxVehicleTireData.mType */ void setup (const PxU32 nbTireTypes, const PxU32 nbSurfaceTypes, const PxMaterial** drivableSurfaceMaterials, const PxVehicleDrivableSurfaceType* drivableSurfaceTypes); /** \brief Deallocate a PxVehicleDrivableSurfaceToTireFrictionPairs instance */ void release(); /** \brief Set the friction for a specified pair of tire type and drivable surface type. \param[in] surfaceType describes the surface type \param[in] tireType describes the tire type. \param[in] value describes the friction coefficient for the combination of surface type and tire type. */ void setTypePairFriction(const PxU32 surfaceType, const PxU32 tireType, const PxReal value); /** \brief Compute the surface type associated with a specified PxMaterial instance. \param[in] surfaceMaterial is the material to be queried for its associated surface type. \note The surface type may be used to query the friction of a surface type/tire type pair using getTypePairFriction() \return The surface type associated with a specified PxMaterial instance. If surfaceMaterial is not referenced by the PxVehicleDrivableSurfaceToTireFrictionPairs a value of 0 will be returned. @see setup @see getTypePairFriction */ PxU32 getSurfaceType(const PxMaterial& surfaceMaterial) const; /** \brief Return the friction for a specified combination of surface type and tire type. \return The friction for a specified combination of surface type and tire type. \note The final friction value used by the tire model is the value returned by getTypePairFriction multiplied by the value computed from PxVehicleTireData::mFrictionVsSlipGraph \note The surface type is associated with a PxMaterial. The mapping between the two may be queried using getSurfaceType(). @see PxVehicleTireData::mFrictionVsSlipGraph @see getSurfaceType */ PxReal getTypePairFriction(const PxU32 surfaceType, const PxU32 tireType) const; /** \brief Return the friction for a specified combination of PxMaterial and tire type. \return The friction for a specified combination of PxMaterial and tire type. \note The final friction value used by the tire model is the value returned by getTypePairFriction multiplied by the value computed from PxVehicleTireData::mFrictionVsSlipGraph \note If surfaceMaterial is not referenced by the PxVehicleDrivableSurfaceToTireFrictionPairs a surfaceType of value 0 will be assumed and the corresponding friction value will be returned. @see PxVehicleTireData::mFrictionVsSlipGraph */ PxReal getTypePairFriction(const PxMaterial& surfaceMaterial, const PxU32 tireType) const; /** \brief Return the maximum number of surface types \return The maximum number of surface types @see allocate */ PX_FORCE_INLINE PxU32 getMaxNbSurfaceTypes() const {return mMaxNbSurfaceTypes;} /** \brief Return the maximum number of tire types \return The maximum number of tire types @see allocate */ PX_FORCE_INLINE PxU32 getMaxNbTireTypes() const {return mMaxNbTireTypes;} /** \brief Binary serialization of a PxVehicleDrivableSurfaceToTireFrictionPairs instance. The PxVehicleDrivableSurfaceToTireFrictionPairs instance is serialized to a PxOutputStream. The materials referenced by the PxVehicleDrivableSurfaceToTireFrictionPairs instance are serialized to a PxCollection. \param[in] frictionTable is the PxVehicleDrivableSurfaceToTireFrictionPairs instance to be serialized. \param[in] materialIds are unique ids that will be used to add the materials to the collection. \param[in] nbMaterialIds is the length of the materialIds array. It must be sufficient to cover all materials. \param[out] collection is the PxCollection instance that is to be used to serialize the PxMaterial instances referenced by the PxVehicleDrivableSurfaceToTireFrictionPairs instance. \param[out] stream contains the memory block for the binary serialized friction table. \note If a material has already been added to the collection with a PxSerialObjectId, it will not be added again. \note If all materials have already been added to the collection with a PxSerialObjectId, it is legal to pass a NULL ptr for the materialIds array. \note frictionTable references PxMaterial instances, which are serialized using PxCollection. The PxCollection instance may be used to serialize an entire scene that also references some or none of those material instances or particular objects in a scene or nothing at all. The complementary deserialize() function requires the same collection instance or more typically a deserialized copy of the collection to be passed as a function argument. @see deserializeFromBinary */ static void serializeToBinary(const PxVehicleDrivableSurfaceToTireFrictionPairs& frictionTable, const PxSerialObjectId* materialIds, const PxU32 nbMaterialIds, PxCollection* collection, PxOutputStream& stream); /** \brief Deserialize from a memory block to create a PxVehicleDrivableSurfaceToTireFrictionPairs instance. \param[in] collection contains the PxMaterial instances that will be referenced by the friction table. \param[in] memBlock is a binary array that may be retrieved or copied from the stream in the complementary serializeToBinary function. \return A PxVehicleDrivableSurfaceToTireFrictionPairs instance whose base address is equal to the memBlock ptr. @see serializeToBinary */ static PxVehicleDrivableSurfaceToTireFrictionPairs* deserializeFromBinary(const PxCollection& collection, void* memBlock); private: /** \brief Ptr to base address of a 2d PxReal array with dimensions [mNbSurfaceTypes][mNbTireTypes] \note Each element of the array describes the maximum friction provided by a surface type-tire type combination. eg the friction corresponding to a combination of surface type x and tire type y is mPairs[x][y] */ PxReal* mPairs; /** \brief Ptr to 1d array of material ptrs that is of length mNbSurfaceTypes. \note If the PxMaterial that touches the tire corresponds to mDrivableSurfaceMaterials[x] then the drivable surface type is mDrivableSurfaceTypes[x].mType and the friction for that contact is mPairs[mDrivableSurfaceTypes[x].mType][y], assuming a tire type y. \note If the PxMaterial that touches the tire is not found in mDrivableSurfaceMaterials then the friction is mPairs[0][y], assuming a tire type y. */ const PxMaterial** mDrivableSurfaceMaterials; /** \brief Ptr to 1d array of PxVehicleDrivableSurfaceType that is of length mNbSurfaceTypes. \note If the PxMaterial that touches the tire is found in mDrivableSurfaceMaterials[x] then the drivable surface type is mDrivableSurfaceTypes[x].mType and the friction for that contact is mPairs[mDrivableSurfaceTypes[x].mType][y], assuming a tire type y. \note If the PxMaterial that touches the tire is not found in mDrivableSurfaceMaterials then the friction is mPairs[0][y], assuming a tire type y. */ PxVehicleDrivableSurfaceType* mDrivableSurfaceTypes; /** \brief A PxSerialObjectId per surface type used internally for serialization. */ PxSerialObjectId* mMaterialSerialIds; /** \brief Number of different driving surface types. \note mDrivableSurfaceMaterials and mDrivableSurfaceTypes are both 1d arrays of length mMaxNbSurfaceTypes. \note mNbSurfaceTypes must be less than or equal to mMaxNbSurfaceTypes. */ PxU32 mNbSurfaceTypes; /** \brief Maximum number of different driving surface types. \note mMaxNbSurfaceTypes must be less than or equal to eMAX_NB_SURFACE_TYPES. */ PxU32 mMaxNbSurfaceTypes; /** \brief Number of different tire types. \note Tire types stored in PxVehicleTireData.mType */ PxU32 mNbTireTypes; /** \brief Maximum number of different tire types. \note Tire types stored in PxVehicleTireData.mType */ PxU32 mMaxNbTireTypes; PxVehicleDrivableSurfaceToTireFrictionPairs(){} ~PxVehicleDrivableSurfaceToTireFrictionPairs(){} }; PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleDrivableSurfaceToTireFrictionPairs) & 15)); #if !PX_DOXYGEN } // namespace physx #endif #endif
12,491
C
44.425454
211
0.798175
NVIDIA-Omniverse/PhysX/physx/include/vehicle/PxVehicleDriveTank.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_VEHICLE_DRIVE_TANK_H #define PX_VEHICLE_DRIVE_TANK_H #include "vehicle/PxVehicleDrive.h" #include "vehicle/PxVehicleWheels.h" #include "vehicle/PxVehicleComponents.h" #if !PX_DOXYGEN namespace physx { #endif struct PxFilterData; class PxGeometry; class PxPhysics; class PxVehicleDrivableSurfaceToTireFrictionPairs; class PxShape; class PxMaterial; class PxRigidDynamic; /** \brief The ordering of the wheels of a PxVehicleDriveTank. @see PxVehicleWheelsSimData, PxVehicleWheelsDynData */ struct PX_DEPRECATED PxVehicleDriveTankWheelOrder { enum Enum { eFRONT_LEFT=0, eFRONT_RIGHT, e1ST_FROM_FRONT_LEFT, e1ST_FROM_FRONT_RIGHT, e2ND_FROM_FRONT_LEFT, e2ND_FROM_FRONT_RIGHT, e3RD_FROM_FRONT_LEFT, e3RD_FROM_FRONT_RIGHT, e4TH_FROM_FRONT_LEFT, e4TH_FROM_FRONT_RIGHT, e5TH_FROM_FRONT_LEFT, e5TH_FROM_FRONT_RIGHT, e6TH_FROM_FRONT_LEFT, e6TH_FROM_FRONT_RIGHT, e7TH_FROM_FRONT_LEFT, e7TH_FROM_FRONT_RIGHT, e8TH_FROM_FRONT_LEFT, e8TH_FROM_FRONT_RIGHT, e9TH_FROM_FRONT_LEFT, e9TH_FROM_FRONT_RIGHT }; }; /** \brief The control inputs for a PxVehicleDriveTank. \note The values of eANALOG_INPUT_THRUST_LEFT and eANALOG_INPUT_THRUST_RIGHT determine how much of the total available drive torque is diverted to the left and right wheels. These entries in the enumerated list represent the state of the left and right control sticks of a tank. The total available drive torque available is controlled by eANALOG_INPUT_ACCEL, which represents the state of the acceleration pedal and controls how much torque will be applied to the engine. \note To accelerate forwards eANALOG_INPUT_ACCEL must be greater than zero so that torque is applied to drive the engine, while eANALOG_INPUT_THRUST_LEFT and eANALOG_INPUT_THRUST_RIGHT must also be greater than zero to divert the available drive torque to the left and wheels. If eANALOG_INPUT_THRUST_LEFT > eANALOG_INPUT_THRUST_RIGHT the tank will turn to the right. If eANALOG_INPUT_THRUST_RIGHT > eANALOG_INPUT_THRUST_LEFT the tank will turn to the left. @see PxVehicleDriveDynData::setAnalogInput, PxVehicleDriveDynData::getAnalogInput */ struct PX_DEPRECATED PxVehicleDriveTankControl { enum Enum { eANALOG_INPUT_ACCEL=0, eANALOG_INPUT_BRAKE_LEFT, eANALOG_INPUT_BRAKE_RIGHT, eANALOG_INPUT_THRUST_LEFT, eANALOG_INPUT_THRUST_RIGHT, eMAX_NB_DRIVETANK_ANALOG_INPUTS }; }; /** \brief Two driving models are supported. \note If eSTANDARD is chosen the left and right wheels are always driven in the same direction. If the tank is in a forward gear the left and right wheels will all be driven forwards, while in reverse gear the left and right wheels will all be driven backwards. With eSTANDARD the legal range of left and right thrust is (0,1). \note If eSPECIAL is chosen it is possible to drive the left and right wheels in different directions. With eSPECIAL the legal range of left and right thrust is (-1,1). In forward(reverse) gear negative thrust values drive the wheels backwards(forwards), while positive thrust values drives the wheels forwards(backwards). \note A sharp left turn can be achieved in eSTANDARD mode by braking with the left wheels and thrusting forward with the right wheels. A smaller turning circle can theoretically be achieved in eSPECIAL mode by applying negative thrust to the left wheels and positive thrust to the right wheels. \note In both modes the legal ranges of acceleration and left/right brake are all (0,1). @see PxVehicleDriveTank::setDriveModel */ struct PX_DEPRECATED PxVehicleDriveTankControlModel { enum Enum { eSTANDARD=0, eSPECIAL }; }; /** \brief Data structure with instanced dynamics data and configuration data of a tank. */ class PX_DEPRECATED PxVehicleDriveTank : public PxVehicleDrive { public: friend class PxVehicleUpdate; /** \brief Allocate a PxVehicleTankDrive instance for a tank with nbWheels \param[in] nbWheels is the number of wheels on the vehicle. \note It is assumed that all wheels are driven wheels. \return The instantiated vehicle. @see free, setup */ static PxVehicleDriveTank* allocate(const PxU32 nbWheels); /** \brief Deallocate a PxVehicleDriveTank instance. @see allocate */ void free(); /** \brief Set up a tank using simulation data for the wheels and drive model. \param[in] physics is a PxPhysics instance that is needed to create special vehicle constraints that are maintained by the vehicle. \param[in] vehActor is a PxRigidDynamic instance that is used to represent the tank in the PhysX SDK. \param[in] wheelsData describes the configuration of all suspension/tires/wheels of the tank. The tank instance takes a copy of this data. \param[in] driveData describes the properties of the tank's drive model (gears/engine/clutch/autobox). The tank instance takes a copy of this data. \param[in] nbDrivenWheels is the number of wheels on the tank. \note It is assumed that the first shapes of the actor are the wheel shapes, followed by the chassis shapes. To break this assumption use PxVehicleWheelsSimData::setWheelShapeMapping. @see allocate, free, setToRestState, PxVehicleWheelsSimData::setWheelShapeMapping \note nbDrivenWheels must be an even number \note The wheels must be arranged according to PxVehicleDriveTankWheelOrder; that is, the even wheels are on the left side of the tank and the odd wheels are on the right side of the tank. */ void setup (PxPhysics* physics, PxRigidDynamic* vehActor, const PxVehicleWheelsSimData& wheelsData, const PxVehicleDriveSimData& driveData, const PxU32 nbDrivenWheels); /** \brief Allocate and set up a tank using simulation data for the wheels and drive model. \param[in] physics is a PxPhysics instance that is needed to create special vehicle constraints that are maintained by the tank. \param[in] vehActor is a PxRigidDynamic instance that is used to represent the tank in the PhysX SDK. \param[in] wheelsData describes the configuration of all suspension/tires/wheels of the tank. The tank instance takes a copy of this data. \param[in] driveData describes the properties of the tank's drive model (gears/engine/clutch/differential/autobox). The tank instance takes a copy of this data. \param[in] nbDrivenWheels is the number of wheels on the tank. \note It is assumed that the first shapes of the actor are the wheel shapes, followed by the chassis shapes. To break this assumption use PxVehicleWheelsSimData::setWheelShapeMapping. \return The instantiated vehicle. @see allocate, free, setToRestState, PxVehicleWheelsSimData::setWheelShapeMapping */ static PxVehicleDriveTank* create (PxPhysics* physics, PxRigidDynamic* vehActor, const PxVehicleWheelsSimData& wheelsData, const PxVehicleDriveSimData& driveData, const PxU32 nbDrivenWheels); /** \brief Set the control model used by the tank. \note eDRIVE_MODEL_STANDARD: turning achieved by braking on one side, accelerating on the other side. \note eDRIVE_MODEL_SPECIAL: turning achieved by accelerating forwards on one side, accelerating backwards on the other side. \note The default value is eDRIVE_MODEL_STANDARD */ void setDriveModel(const PxVehicleDriveTankControlModel::Enum driveModel) { mDriveModel=driveModel; } /** \brief Return the control model used by the tank. */ PxVehicleDriveTankControlModel::Enum getDriveModel() const {return mDriveModel;} /** \brief Set a vehicle to its rest state. Aside from the rigid body transform, this will set the vehicle and rigid body to the state they were in immediately after setup or create. \note Calling setToRestState invalidates the cached raycast hit planes under each wheel meaning that suspension line raycasts need to be performed at least once with PxVehicleSuspensionRaycasts before calling PxVehicleUpdates. @see setup, create, PxVehicleSuspensionRaycasts, PxVehicleUpdates */ void setToRestState(); /** \brief Simulation data that models vehicle components @see setup, create */ PxVehicleDriveSimData mDriveSimData; private: /** \brief Test if the instanced dynamics and configuration data has legal values. */ bool isValid() const; /** \brief Drive model @see setDriveModel, getDriveModel, PxVehicleDriveTankControlModel */ PxVehicleDriveTankControlModel::Enum mDriveModel; PxU32 mPad[3]; //serialization public: PxVehicleDriveTank(PxBaseFlags baseFlags) : PxVehicleDrive(baseFlags) {} static PxVehicleDriveTank* createObject(PxU8*& address, PxDeserializationContext& context); static void getBinaryMetaData(PxOutputStream& stream); virtual const char* getConcreteTypeName() const { return "PxVehicleDriveTank"; } virtual bool isKindOf(const char* name) const { PX_IS_KIND_OF(name, "PxVehicleDriveTank", PxVehicleDrive); } protected: PxVehicleDriveTank(); ~PxVehicleDriveTank(){} //~serialization }; PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleDriveTank) & 15)); #if !PX_DOXYGEN } // namespace physx #endif #endif
10,691
C
38.6
185
0.77598
NVIDIA-Omniverse/PhysX/physx/include/vehicle/PxVehicleComponents.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_VEHICLE_COMPONENTS_H #define PX_VEHICLE_COMPONENTS_H #include "foundation/PxMemory.h" #include "foundation/PxVec3.h" #include "common/PxCoreUtilityTypes.h" #include "vehicle/PxVehicleSDK.h" #include "common/PxTypeInfo.h" #if !PX_DOXYGEN namespace physx { #endif class PX_DEPRECATED PxVehicleChassisData { public: friend class PxVehicleDriveSimData4W; PxVehicleChassisData() : mMOI(PxVec3(0,0,0)), mMass(1500), mCMOffset(PxVec3(0,0,0)) { } /** \brief Moment of inertia of vehicle rigid body actor. \note Specified in kilograms metres-squared (kg m^2). */ PxVec3 mMOI; /** \brief Mass of vehicle rigid body actor. \note Specified in kilograms (kg). */ PxReal mMass; /** \brief Center of mass offset of vehicle rigid body actor. \note Specified in metres (m). */ PxVec3 mCMOffset; private: PxReal pad; bool isValid() const; }; PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleChassisData)& 0x0f)); class PX_DEPRECATED PxVehicleEngineData { public: friend class PxVehicleDriveSimData; enum { eMAX_NB_ENGINE_TORQUE_CURVE_ENTRIES = 8 }; PxVehicleEngineData() : mMOI(1.0f), mPeakTorque(500.0f), mMaxOmega(600.0f), mDampingRateFullThrottle(0.15f), mDampingRateZeroThrottleClutchEngaged(2.0f), mDampingRateZeroThrottleClutchDisengaged(0.35f) { mTorqueCurve.addPair(0.0f, 0.8f); mTorqueCurve.addPair(0.33f, 1.0f); mTorqueCurve.addPair(1.0f, 0.8f); mRecipMOI=1.0f/mMOI; mRecipMaxOmega=1.0f/mMaxOmega; } /** \brief Graph of normalized torque (torque/mPeakTorque) against normalized engine speed ( engineRotationSpeed / mMaxOmega ). \note The normalized engine speed is the x-axis of the graph, while the normalized torque is the y-axis of the graph. */ PxFixedSizeLookupTable<eMAX_NB_ENGINE_TORQUE_CURVE_ENTRIES> mTorqueCurve; /** \brief Moment of inertia of the engine around the axis of rotation. \note Specified in kilograms metres-squared (kg m^2) */ PxReal mMOI; /** \brief Maximum torque available to apply to the engine when the accelerator pedal is at maximum. \note The torque available is the value of the accelerator pedal (in range [0, 1]) multiplied by the normalized torque as computed from mTorqueCurve multiplied by mPeakTorque. \note Specified in kilograms metres-squared per second-squared (kg m^2 s^-2). <b>Range:</b> [0, PX_MAX_F32)<br> */ PxReal mPeakTorque; /** \brief Maximum rotation speed of the engine. \note Specified in radians per second (s^-1). <b>Range:</b> [0, PX_MAX_F32)<br> */ PxReal mMaxOmega; /** \brief Damping rate of engine when full throttle is applied. \note If the clutch is engaged (any gear except neutral) then the damping rate applied at run-time is an interpolation between mDampingRateZeroThrottleClutchEngaged and mDampingRateFullThrottle: mDampingRateZeroThrottleClutchEngaged + (mDampingRateFullThrottle-mDampingRateZeroThrottleClutchEngaged)*acceleratorPedal; \note If the clutch is disengaged (in neutral gear) the damping rate applied at run-time is an interpolation between mDampingRateZeroThrottleClutchDisengaged and mDampingRateFullThrottle: mDampingRateZeroThrottleClutchDisengaged + (mDampingRateFullThrottle-mDampingRateZeroThrottleClutchDisengaged)*acceleratorPedal; \note Specified in kilograms metres-squared per second (kg m^2 s^-1). <b>Range:</b> [0, PX_MAX_F32)<br> */ PxReal mDampingRateFullThrottle; /** \brief Damping rate of engine when full throttle is applied. \note If the clutch is engaged (any gear except neutral) then the damping rate applied at run-time is an interpolation between mDampingRateZeroThrottleClutchEngaged and mDampingRateFullThrottle: mDampingRateZeroThrottleClutchEngaged + (mDampingRateFullThrottle-mDampingRateZeroThrottleClutchEngaged)*acceleratorPedal; \note If the clutch is disengaged (in neutral gear) the damping rate applied at run-time is an interpolation between mDampingRateZeroThrottleClutchDisengaged and mDampingRateFullThrottle: mDampingRateZeroThrottleClutchDisengaged + (mDampingRateFullThrottle-mDampingRateZeroThrottleClutchDisengaged)*acceleratorPedal; \note Specified in kilograms metres-squared per second (kg m^2 s^-1). <b>Range:</b> [0, PX_MAX_F32)<br> */ PxReal mDampingRateZeroThrottleClutchEngaged; /** \brief Damping rate of engine when full throttle is applied. \note If the clutch is engaged (any gear except neutral) then the damping rate applied at run-time is an interpolation between mDampingRateZeroThrottleClutchEngaged and mDampingRateFullThrottle: mDampingRateZeroThrottleClutchEngaged + (mDampingRateFullThrottle-mDampingRateZeroThrottleClutchEngaged)*acceleratorPedal; \note If the clutch is disengaged (in neutral gear) the damping rate applied at run-time is an interpolation between mDampingRateZeroThrottleClutchDisengaged and mDampingRateFullThrottle: mDampingRateZeroThrottleClutchDisengaged + (mDampingRateFullThrottle-mDampingRateZeroThrottleClutchDisengaged)*acceleratorPedal; \note Specified in kilograms metres-squared per second (kg m^2 s^-1). <b>Range:</b> [0, PX_MAX_F32)<br> */ PxReal mDampingRateZeroThrottleClutchDisengaged; /** \brief Return value of mRecipMOI(=1.0f/mMOI) that is automatically set by PxVehicleDriveSimData::setEngineData */ PX_FORCE_INLINE PxReal getRecipMOI() const {return mRecipMOI;} /** \brief Return value of mRecipMaxOmega( = 1.0f / mMaxOmega ) that is automatically set by PxVehicleDriveSimData::setEngineData */ PX_FORCE_INLINE PxReal getRecipMaxOmega() const {return mRecipMaxOmega;} private: /** \brief Reciprocal of the engine moment of inertia. \note Not necessary to set this value because it is set by PxVehicleDriveSimData::setEngineData <b>Range:</b> [0, PX_MAX_F32)<br> */ PxReal mRecipMOI; /** \brief Reciprocal of the maximum rotation speed of the engine. \note Not necessary to set this value because it is set by PxVehicleDriveSimData::setEngineData <b>Range:</b> [0, PX_MAX_F32)<br> */ PxReal mRecipMaxOmega; bool isValid() const; //serialization public: PxVehicleEngineData(const PxEMPTY) : mTorqueCurve(PxEmpty) {} //~serialization }; PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleEngineData)& 0x0f)); class PX_DEPRECATED PxVehicleGearsData { public: friend class PxVehicleDriveSimData; enum Enum { eREVERSE=0, eNEUTRAL, eFIRST, eSECOND, eTHIRD, eFOURTH, eFIFTH, eSIXTH, eSEVENTH, eEIGHTH, eNINTH, eTENTH, eELEVENTH, eTWELFTH, eTHIRTEENTH, eFOURTEENTH, eFIFTEENTH, eSIXTEENTH, eSEVENTEENTH, eEIGHTEENTH, eNINETEENTH, eTWENTIETH, eTWENTYFIRST, eTWENTYSECOND, eTWENTYTHIRD, eTWENTYFOURTH, eTWENTYFIFTH, eTWENTYSIXTH, eTWENTYSEVENTH, eTWENTYEIGHTH, eTWENTYNINTH, eTHIRTIETH, eGEARSRATIO_COUNT }; PxVehicleGearsData() : mFinalRatio(4.0f), mNbRatios(7), mSwitchTime(0.5f) { mRatios[PxVehicleGearsData::eREVERSE]=-4.0f; mRatios[PxVehicleGearsData::eNEUTRAL]=0.0f; mRatios[PxVehicleGearsData::eFIRST]=4.0f; mRatios[PxVehicleGearsData::eSECOND]=2.0f; mRatios[PxVehicleGearsData::eTHIRD]=1.5f; mRatios[PxVehicleGearsData::eFOURTH]=1.1f; mRatios[PxVehicleGearsData::eFIFTH]=1.0f; for(PxU32 i = PxVehicleGearsData::eSIXTH; i < PxVehicleGearsData::eGEARSRATIO_COUNT; ++i) mRatios[i]=0.f; } /** \brief Gear ratios <b>Range:</b> [0, PX_MAX_F32)<br> */ PxReal mRatios[PxVehicleGearsData::eGEARSRATIO_COUNT]; /** \brief Gear ratio applied is mRatios[currentGear]*finalRatio <b>Range:</b> [0, PX_MAX_F32)<br> */ PxReal mFinalRatio; /** \brief Number of gears (including reverse and neutral). <b>Range:</b> (0, MAX_NB_GEAR_RATIOS)<br> */ PxU32 mNbRatios; /** \brief Time it takes to switch gear. \note Specified in seconds (s). <b>Range:</b> [0, PX_MAX_F32)<br> */ PxReal mSwitchTime; private: PxReal mPad; bool isValid() const; //serialization public: PxVehicleGearsData(const PxEMPTY) {} PxReal getGearRatio(PxVehicleGearsData::Enum a) const {return mRatios[a];} void setGearRatio(PxVehicleGearsData::Enum a, PxReal ratio) { mRatios[a] = ratio;} //~serialization }; PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleGearsData)& 0x0f)); class PX_DEPRECATED PxVehicleAutoBoxData { public: friend class PxVehicleDriveSimData; PxVehicleAutoBoxData() { for(PxU32 i=0;i<PxVehicleGearsData::eGEARSRATIO_COUNT;i++) { mUpRatios[i]=0.65f; mDownRatios[i]=0.50f; } //Not sure how important this is but we want to kick out of neutral very quickly. mUpRatios[PxVehicleGearsData::eNEUTRAL]=0.15f; //Set the latency time in an unused element of one of the arrays. mDownRatios[PxVehicleGearsData::eREVERSE]=2.0f; } /** \brief Value of ( engineRotationSpeed / PxVehicleEngineData::mMaxOmega ) that is high enough to increment gear. \note When ( engineRotationSpeed / PxVehicleEngineData::mMaxOmega ) > mUpRatios[currentGear] the autobox will begin a transition to currentGear+1 unless currentGear is the highest possible gear or neutral or reverse. <b>Range:</b> [0, 1]<br> */ PxReal mUpRatios[PxVehicleGearsData::eGEARSRATIO_COUNT]; /** \brief Value of engineRevs/maxEngineRevs that is low enough to decrement gear. \note When ( engineRotationSpeed / PxVehicleEngineData::mMaxOmega ) < mDownRatios[currentGear] the autobox will begin a transition to currentGear-1 unless currentGear is first gear or neutral or reverse. <b>Range:</b> [0, 1]<br> */ PxReal mDownRatios[PxVehicleGearsData::eGEARSRATIO_COUNT]; /** \brief Set the latency time of the autobox. \note Latency time is the minimum time that must pass between each gear change that is initiated by the autobox. The auto-box will only attempt to initiate another gear change up or down if the simulation time that has passed since the most recent automated gear change is greater than the specified latency. \note Specified in seconds (s). @see getLatency */ void setLatency(const PxReal latency) { mDownRatios[PxVehicleGearsData::eREVERSE]=latency; } /** \brief Get the latency time of the autobox. \note Specified in seconds (s). @see setLatency */ PxReal getLatency() const { return mDownRatios[PxVehicleGearsData::eREVERSE]; } private: bool isValid() const; //serialization public: PxVehicleAutoBoxData(const PxEMPTY) {} PxReal getUpRatios(PxVehicleGearsData::Enum a) const {return mUpRatios[a];} void setUpRatios(PxVehicleGearsData::Enum a, PxReal ratio) { mUpRatios[a] = ratio;} PxReal getDownRatios(PxVehicleGearsData::Enum a) const {return mDownRatios[a];} void setDownRatios(PxVehicleGearsData::Enum a, PxReal ratio) { mDownRatios[a] = ratio;} //~serialization }; PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleAutoBoxData)& 0x0f)); class PX_DEPRECATED PxVehicleDifferential4WData { public: friend class PxVehicleDriveSimData4W; enum Enum { eDIFF_TYPE_LS_4WD, //limited slip differential for car with 4 driven wheels eDIFF_TYPE_LS_FRONTWD, //limited slip differential for car with front-wheel drive eDIFF_TYPE_LS_REARWD, //limited slip differential for car with rear-wheel drive eDIFF_TYPE_OPEN_4WD, //open differential for car with 4 driven wheels eDIFF_TYPE_OPEN_FRONTWD, //open differential for car with front-wheel drive eDIFF_TYPE_OPEN_REARWD, //open differential for car with rear-wheel drive eMAX_NB_DIFF_TYPES }; PxVehicleDifferential4WData() : mFrontRearSplit(0.45f), mFrontLeftRightSplit(0.5f), mRearLeftRightSplit(0.5f), mCentreBias(1.3f), mFrontBias(1.3f), mRearBias(1.3f), mType(PxVehicleDifferential4WData::eDIFF_TYPE_LS_4WD) { } /** \brief Ratio of torque split between front and rear (>0.5 means more to front, <0.5 means more to rear). \note Only applied to DIFF_TYPE_LS_4WD and eDIFF_TYPE_OPEN_4WD <b>Range:</b> [0, 1]<br> */ PxReal mFrontRearSplit; /** \brief Ratio of torque split between front-left and front-right (>0.5 means more to front-left, <0.5 means more to front-right). \note Only applied to DIFF_TYPE_LS_4WD and eDIFF_TYPE_OPEN_4WD and eDIFF_TYPE_LS_FRONTWD <b>Range:</b> [0, 1]<br> */ PxReal mFrontLeftRightSplit; /** \brief Ratio of torque split between rear-left and rear-right (>0.5 means more to rear-left, <0.5 means more to rear-right). \note Only applied to DIFF_TYPE_LS_4WD and eDIFF_TYPE_OPEN_4WD and eDIFF_TYPE_LS_REARWD <b>Range:</b> [0, 1]<br> */ PxReal mRearLeftRightSplit; /** \brief Maximum allowed ratio of average front wheel rotation speed and rear wheel rotation speeds The differential will divert more torque to the slower wheels when the bias is exceeded. \note Only applied to DIFF_TYPE_LS_4WD <b>Range:</b> [1, PX_MAX_F32)<br> */ PxReal mCentreBias; /** \brief Maximum allowed ratio of front-left and front-right wheel rotation speeds. The differential will divert more torque to the slower wheel when the bias is exceeded. \note Only applied to DIFF_TYPE_LS_4WD and DIFF_TYPE_LS_FRONTWD <b>Range:</b> [1, PX_MAX_F32)<br> */ PxReal mFrontBias; /** \brief Maximum allowed ratio of rear-left and rear-right wheel rotation speeds. The differential will divert more torque to the slower wheel when the bias is exceeded. \note Only applied to DIFF_TYPE_LS_4WD and DIFF_TYPE_LS_REARWD <b>Range:</b> [1, PX_MAX_F32)<br> */ PxReal mRearBias; /** \brief Type of differential. <b>Range:</b> [DIFF_TYPE_LS_4WD, DIFF_TYPE_OPEN_FRONTWD]<br> */ PxVehicleDifferential4WData::Enum mType; private: PxReal mPad[1]; bool isValid() const; //serialization public: PxVehicleDifferential4WData(const PxEMPTY) {} //~serialization }; PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleDifferential4WData)& 0x0f)); class PX_DEPRECATED PxVehicleDifferentialNWData { public: friend class PxVehicleDriveSimDataNW; friend class PxVehicleUpdate; PxVehicleDifferentialNWData() { PxMemSet(mBitmapBuffer, 0, sizeof(PxU32) * (((PX_MAX_NB_WHEELS + 31) & ~31) >> 5)); mNbDrivenWheels=0; mInvNbDrivenWheels=0.0f; } /** \brief Set a specific wheel to be driven or non-driven by the differential. \note The available drive torque will be split equally between all driven wheels. Zero torque will be applied to non-driven wheels. The default state of each wheel is to be uncoupled to the differential. */ void setDrivenWheel(const PxU32 wheelId, const bool drivenState); /** \brief Test if a specific wheel has been configured as a driven or non-driven wheel. */ bool getIsDrivenWheel(const PxU32 wheelId) const; private: PxU32 mBitmapBuffer[((PX_MAX_NB_WHEELS + 31) & ~31) >> 5]; PxU32 mNbDrivenWheels; PxReal mInvNbDrivenWheels; PxU32 mPad; bool isValid() const; //serialization public: PxVehicleDifferentialNWData(const PxEMPTY) {} PxU32 getDrivenWheelStatus() const; void setDrivenWheelStatus(PxU32 status); //~serialization }; PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleDifferentialNWData)& 0x0f)); class PX_DEPRECATED PxVehicleAckermannGeometryData { public: friend class PxVehicleDriveSimData4W; PxVehicleAckermannGeometryData() : mAccuracy(1.0f), mFrontWidth(0.0f), //Must be filled out mRearWidth(0.0f), //Must be filled out mAxleSeparation(0.0f) //Must be filled out { } /** \brief Accuracy of Ackermann steer calculation. \note Accuracy with value 0.0 results in no Ackermann steer-correction, while accuracy with value 1.0 results in perfect Ackermann steer-correction. \note Perfect Ackermann steer correction modifies the steer angles applied to the front-left and front-right wheels so that the perpendiculars to the wheels' longitudinal directions cross the extended vector of the rear axle at the same point. It is also applied to any steer angle applied to the rear wheels but instead using the extended vector of the front axle. \note In general, more steer correction produces better cornering behavior. <b>Range:</b> [0, 1]<br> */ PxReal mAccuracy; /** \brief Distance between center-point of the two front wheels. \note Specified in metres (m). <b>Range:</b> [0, PX_MAX_F32)<br> */ PxReal mFrontWidth; /** \brief Distance between center-point of the two rear wheels. \note Specified in metres (m). <b>Range:</b> [0, PX_MAX_F32)<br> */ PxReal mRearWidth; /** \brief Distance between center of front axle and center of rear axle. \note Specified in metres (m). <b>Range:</b> [0, PX_MAX_F32)<br> */ PxReal mAxleSeparation; private: bool isValid() const; //serialization public: PxVehicleAckermannGeometryData(const PxEMPTY) {} //~serialization }; PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleAckermannGeometryData)& 0x0f)); /** \brief Choose between a potentially more expensive but more accurate solution to the clutch model or a potentially cheaper but less accurate solution. @see PxVehicleClutchData */ struct PX_DEPRECATED PxVehicleClutchAccuracyMode { enum Enum { eESTIMATE = 0, eBEST_POSSIBLE }; }; class PX_DEPRECATED PxVehicleClutchData { public: friend class PxVehicleDriveSimData; PxVehicleClutchData() : mStrength(10.0f), mAccuracyMode(PxVehicleClutchAccuracyMode::eBEST_POSSIBLE), mEstimateIterations(5) { } /** \brief Strength of clutch. \note The clutch is the mechanism that couples the engine to the wheels. A stronger clutch more strongly couples the engine to the wheels, while a clutch of strength zero completely decouples the engine from the wheels. Stronger clutches more quickly bring the wheels and engine into equilibrium, while weaker clutches take longer, resulting in periods of clutch slip and delays in power transmission from the engine to the wheels. The torque generated by the clutch is proportional to the clutch strength and the velocity difference between the engine's rotational speed and the rotational speed of the driven wheels after accounting for the gear ratio. The torque at the clutch is applied negatively to the engine and positively to the driven wheels. \note Specified in kilograms metres-squared per second (kg m^2 s^-1) <b>Range:</b> [0,PX_MAX_F32)<br> */ PxReal mStrength; /** \brief The engine and wheel rotation speeds that are coupled through the clutch can be updated by choosing one of two modes: eESTIMATE and eBEST_POSSIBLE. \note If eESTIMATE is chosen the vehicle sdk will update the wheel and engine rotation speeds with estimated values to the implemented clutch model. \note If eBEST_POSSIBLE is chosen the vehicle sdk will compute the best possible solution (within floating point tolerance) to the implemented clutch model. This is the recommended mode. \note The clutch model remains the same if either eESTIMATE or eBEST_POSSIBLE is chosen but the accuracy and computational cost of the solution to the model can be tuned as required. */ PxVehicleClutchAccuracyMode::Enum mAccuracyMode; /** \brief Tune the mathematical accuracy and computational cost of the computed estimate to the wheel and engine rotation speeds if eESTIMATE is chosen. \note As mEstimateIterations increases the computational cost of the clutch also increases and the solution approaches the solution that would be computed if eBEST_POSSIBLE was chosen instead. \note This has no effect if eBEST_POSSIBLE is chosen as the accuracy mode. \note A value of zero is not allowed if eESTIMATE is chosen as the accuracy mode. */ PxU32 mEstimateIterations; private: PxU8 mPad[4]; bool isValid() const; //serialization public: PxVehicleClutchData(const PxEMPTY) {} //~serialization }; PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleClutchData)& 0x0f)); /** \brief Tire load variation can be strongly dependent on the time-step so it is a good idea to filter it to give less jerky handling behavior. \note The x-axis of the graph is normalized tire load, while the y-axis is the filtered normalized tire load. \note The normalized load is the force acting downwards on the tire divided by the force experienced by the tire when the car is at rest on the ground. \note The rest load is approximately the product of the value of gravitational acceleration and PxVehicleSuspensionData::mSprungMass. \note The minimum possible normalized load is zero. \note There are two points on the graph: (mMinNormalisedLoad, mMinNormalisedFilteredLoad) and (mMaxNormalisedLoad, mMaxFilteredNormalisedLoad). \note Normalized loads less than mMinNormalisedLoad have filtered normalized load = mMinNormalisedFilteredLoad. \note Normalized loads greater than mMaxNormalisedLoad have filtered normalized load = mMaxFilteredNormalisedLoad. \note Normalized loads in-between are linearly interpolated between mMinNormalisedFilteredLoad and mMaxFilteredNormalisedLoad. \note The tire load applied as input to the tire force computation is the filtered normalized load multiplied by the rest load. */ class PX_DEPRECATED PxVehicleTireLoadFilterData { public: friend class PxVehicleWheelsSimData; PxVehicleTireLoadFilterData() : mMinNormalisedLoad(0), mMinFilteredNormalisedLoad(0.2308f), mMaxNormalisedLoad(3.0f), mMaxFilteredNormalisedLoad(3.0f) { mDenominator=1.0f/(mMaxNormalisedLoad - mMinNormalisedLoad); } /** \brief Graph point (mMinNormalisedLoad,mMinFilteredNormalisedLoad) */ PxReal mMinNormalisedLoad; /** \brief Graph point (mMinNormalisedLoad,mMinFilteredNormalisedLoad) */ PxReal mMinFilteredNormalisedLoad; /** \brief Graph point (mMaxNormalisedLoad,mMaxFilteredNormalisedLoad) */ PxReal mMaxNormalisedLoad; /** \brief Graph point (mMaxNormalisedLoad,mMaxFilteredNormalisedLoad) */ PxReal mMaxFilteredNormalisedLoad; PX_FORCE_INLINE PxReal getDenominator() const {return mDenominator;} private: /** \brief Not necessary to set this value. */ //1.0f/(mMaxNormalisedLoad-mMinNormalisedLoad) for quick calculations PxReal mDenominator; PxU32 mPad[3]; bool isValid() const; //serialization public: PxVehicleTireLoadFilterData(const PxEMPTY) {} //~serialization }; PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleTireLoadFilterData)& 0x0f)); class PX_DEPRECATED PxVehicleWheelData { public: friend class PxVehicleWheels4SimData; PxVehicleWheelData() : mRadius(0.0f), //Must be filled out mWidth(0.0f), mMass(20.0f), mMOI(0.0f), //Must be filled out mDampingRate(0.25f), mMaxBrakeTorque(1500.0f), mMaxHandBrakeTorque(0.0f), mMaxSteer(0.0f), mToeAngle(0.0f), mRecipRadius(0.0f), //Must be filled out mRecipMOI(0.0f) //Must be filled out { } /** \brief Radius of unit that includes metal wheel plus rubber tire. \note Specified in metres (m). <b>Range:</b> [0, PX_MAX_F32)<br> */ PxReal mRadius; /** \brief Maximum width of unit that includes wheel plus tire. \note Specified in metres (m). <b>Range:</b> [0, PX_MAX_F32)<br> */ PxReal mWidth; /** \brief Mass of unit that includes wheel plus tire. \note Specified in kilograms (kg). <b>Range:</b> [0, PX_MAX_F32)<br> */ PxReal mMass; /** \brief Moment of inertia of unit that includes wheel plus tire about the rolling axis. \note Specified in kilograms metres-squared (kg m^2). <b>Range:</b> [0, PX_MAX_F32)<br> */ PxReal mMOI; /** \brief Damping rate applied to wheel. \note Specified in kilograms metres-squared per second (kg m^2 s^-1). <b>Range:</b> [0, PX_MAX_F32)<br> */ PxReal mDampingRate; /** \brief Max brake torque that can be applied to wheel. \note Specified in kilograms metres-squared per second-squared (kg m^2 s^-2) <b>Range:</b> [0, PX_MAX_F32)<br> */ PxReal mMaxBrakeTorque; /** \brief Max handbrake torque that can be applied to wheel. \note Specified in kilograms metres-squared per second-squared (kg m^2 s^-2) <b>Range:</b> [0, PX_MAX_F32)<br> */ PxReal mMaxHandBrakeTorque; /** \brief Max steer angle that can be achieved by the wheel. \note Specified in radians. <b>Range:</b> [0, PX_MAX_F32)<br> */ PxReal mMaxSteer; /** \brief Wheel toe angle. This value is ignored by PxVehicleDriveTank and PxVehicleNoDrive. \note Specified in radians. <b>Range:</b> [0, Pi/2]<br> */ PxReal mToeAngle;//in radians /** \brief Return value equal to 1.0f/mRadius @see PxVehicleWheelsSimData::setWheelData */ PX_FORCE_INLINE PxReal getRecipRadius() const {return mRecipRadius;} /** \brief Return value equal to 1.0f/mRecipMOI @see PxVehicleWheelsSimData::setWheelData */ PX_FORCE_INLINE PxReal getRecipMOI() const {return mRecipMOI;} private: /** \brief Reciprocal of radius of unit that includes metal wheel plus rubber tire. \note Not necessary to set this value because it is set by PxVehicleWheelsSimData::setWheelData <b>Range:</b> [0, PX_MAX_F32)<br> */ PxReal mRecipRadius; /** \brief Reciprocal of moment of inertia of unit that includes wheel plus tire about single allowed axis of rotation. \note Not necessary to set this value because it is set by PxVehicleWheelsSimData::setWheelData <b>Range:</b> [0, PX_MAX_F32)<br> */ PxReal mRecipMOI; PxReal mPad[1]; bool isValid() const; }; PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleWheelData)& 0x0f)); class PX_DEPRECATED PxVehicleSuspensionData { public: friend class PxVehicleWheels4SimData; PxVehicleSuspensionData() : mSpringStrength(0.0f), mSpringDamperRate(0.0f), mMaxCompression(0.3f), mMaxDroop(0.1f), mSprungMass(0.0f), mCamberAtRest(0.0f), mCamberAtMaxCompression(0.0f), mCamberAtMaxDroop(0.0f), mRecipMaxCompression(1.0f), mRecipMaxDroop(1.0f) { } /** \brief Spring strength of suspension unit. \note Specified in kilograms per second-squared (kg s^-2). <b>Range:</b> [0, PX_MAX_F32)<br> */ PxReal mSpringStrength; /** \brief Spring damper rate of suspension unit. \note Specified in kilograms per second (kg s^-1). <b>Range:</b> [0, PX_MAX_F32)<br> */ PxReal mSpringDamperRate; /** \brief Maximum compression allowed by suspension spring. \note Specified in metres (m). <b>Range:</b> [0, PX_MAX_F32)<br> */ PxReal mMaxCompression; /** \brief Maximum elongation allowed by suspension spring. \note Specified in metres (m). <b>Range:</b> [0, PX_MAX_F32)<br> */ PxReal mMaxDroop; /** \brief Mass of vehicle that is supported by suspension spring. \note Specified in kilograms (kg). \note Each suspension is guaranteed to generate an upwards force of |gravity|*mSprungMass along the suspension direction when the wheel is perfectly at rest and sitting at the rest pose defined by the wheel centre offset. \note The sum of the sprung masses of all suspensions of a vehicle should match the mass of the PxRigidDynamic associated with the vehicle. When this condition is satisfied for a vehicle on a horizontal plane the wheels of the vehicle are guaranteed to sit at the rest pose defined by the wheel centre offset. For special cases, where this condition can not be met easily, the flag #PxVehicleWheelsSimFlag::eDISABLE_SPRUNG_MASS_SUM_CHECK allows to provide sprung mass values that do not sum up to the mass of the PxRigidDynamic. \note As the wheel compresses or elongates along the suspension direction the force generated by the spring is F = |gravity|*mSprungMass + deltaX*mSpringStrength + deltaXDot*mSpringDamperRate where deltaX is the deviation from the defined rest pose and deltaXDot is the velocity of the sprung mass along the suspension direction. In practice, deltaXDot is computed by comparing the current and previous deviation from the rest pose and dividing the difference by the simulation timestep. \note If a single suspension spring is hanging in the air and generates zero force the remaining springs of the vehicle will necessarily sit in a compressed configuration. In summary, the sum of the remaining suspension forces cannot balance the downwards gravitational force acting on the vehicle without extra force arising from the deltaX*mSpringStrength force term. \note Theoretically, a suspension spring should generate zero force at maximum elongation and increase linearly as the suspension approaches the rest pose. PxVehicleSuspensionData will only enforce this physical law if the spring is configured so that |gravity|*mSprungMass == mMaxDroop*mSpringStrength. To help decouple vehicle handling from visual wheel positioning this condition is not enforced. In practice, the value of |gravity|*mSprungMass + deltaX*mSpringStrength is clamped at zero to ensure it never falls negative. @see PxVehicleComputeSprungMasses, PxVehicleWheelsSimData::setWheelCentreOffset, PxVehicleSuspensionData::mSpringStrength, PxVehicleSuspensionData::mSpringDamperRate, PxVehicleSuspensionData::mMaxDroop <b>Range:</b> [0, PX_MAX_F32)<br> */ PxReal mSprungMass; /** \brief Camber angle (in radians) of wheel when the suspension is at its rest position. \note Specified in radians. <b>Range:</b> [-pi/2, pi/2]<br> */ PxReal mCamberAtRest; /** \brief Camber angle (in radians) of wheel when the suspension is at maximum compression. \note For compressed suspensions the camber angle is a linear interpolation of mCamberAngleAtRest and mCamberAtMaxCompression \note Specified in radians. <b>Range:</b> [-pi/2, pi/2]<br> */ PxReal mCamberAtMaxCompression; /** \brief Camber angle (in radians) of wheel when the suspension is at maximum droop. \note For extended suspensions the camber angle is linearly interpolation of mCamberAngleAtRest and mCamberAtMaxDroop \note Specified in radians. <b>Range:</b> [-pi/2, pi/2]<br> */ PxReal mCamberAtMaxDroop; /** \brief Reciprocal of maximum compression. \note Not necessary to set this value because it is set by PxVehicleWheelsSimData::setSuspensionData <b>Range:</b> [0, PX_MAX_F32)<br> */ PX_FORCE_INLINE PxReal getRecipMaxCompression() const {return mRecipMaxCompression;} /** \brief Reciprocal of maximum droop. \note Not necessary to set this value because it is set by PxVehicleWheelsSimData::setSuspensionData <b>Range:</b> [0, PX_MAX_F32)<br> */ PX_FORCE_INLINE PxReal getRecipMaxDroop() const {return mRecipMaxDroop;} /** \brief Set a new sprung mass for the suspension and modify the spring strength so that the natural frequency of the spring is preserved. \param[in] newSprungMass is the new mass that the suspension spring will support. */ void setMassAndPreserveNaturalFrequency(const PxReal newSprungMass) { const PxF32 oldStrength = mSpringStrength; const PxF32 oldSprungMass = mSprungMass; const PxF32 newStrength = oldStrength * (newSprungMass / oldSprungMass); mSpringStrength = newStrength; mSprungMass = newSprungMass; } private: /** \brief Cached value of 1.0f/mMaxCompression \note Not necessary to set this value because it is set by PxVehicleWheelsSimData::setSuspensionData */ PxReal mRecipMaxCompression; /** \brief Cached value of 1.0f/mMaxDroop \note Not necessary to set this value because it is set by PxVehicleWheelsSimData::setSuspensionData */ PxReal mRecipMaxDroop; //padding PxReal mPad[2]; bool isValid() const; }; PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleSuspensionData)& 0x0f)); class PX_DEPRECATED PxVehicleAntiRollBarData { public: friend class PxVehicleWheelsSimData; PxVehicleAntiRollBarData() : mWheel0(0xffffffff), mWheel1(0xffffffff), mStiffness(0.0f) { } /* \brief The anti-roll bar connects two wheels with indices mWheel0 and mWheel1 */ PxU32 mWheel0; /* \brief The anti-roll bar connects two wheels with indices mWheel0 and mWheel1 */ PxU32 mWheel1; /* \brief The stiffness of the anti-roll bar. \note Specified in kilograms per second-squared (kg s^-2). <b>Range:</b> [0, PX_MAX_F32)<br> */ PxF32 mStiffness; private: PxF32 mPad[1]; bool isValid() const; }; PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleAntiRollBarData)& 0x0f)); class PX_DEPRECATED PxVehicleTireData { public: friend class PxVehicleWheels4SimData; PxVehicleTireData() : mLatStiffX(2.0f), mLatStiffY(0.3125f*(180.0f / PxPi)), mLongitudinalStiffnessPerUnitGravity(1000.0f), mCamberStiffnessPerUnitGravity(0.1f*(180.0f / PxPi)), mType(0) { mFrictionVsSlipGraph[0][0]=0.0f; mFrictionVsSlipGraph[0][1]=1.0f; mFrictionVsSlipGraph[1][0]=0.1f; mFrictionVsSlipGraph[1][1]=1.0f; mFrictionVsSlipGraph[2][0]=1.0f; mFrictionVsSlipGraph[2][1]=1.0f; mRecipLongitudinalStiffnessPerUnitGravity=1.0f/mLongitudinalStiffnessPerUnitGravity; mFrictionVsSlipGraphRecipx1Minusx0=1.0f/(mFrictionVsSlipGraph[1][0]-mFrictionVsSlipGraph[0][0]); mFrictionVsSlipGraphRecipx2Minusx1=1.0f/(mFrictionVsSlipGraph[2][0]-mFrictionVsSlipGraph[1][0]); } /** \brief Tire lateral stiffness is a graph of tire load that has linear behavior near zero load and flattens at large loads. mLatStiffX describes the minimum normalized load (load/restLoad) that gives a flat lateral stiffness response to load. <b>Range:</b> [0, PX_MAX_F32)<br> */ PxReal mLatStiffX; /** \brief Tire lateral stiffness is a graph of tire load that has linear behavior near zero load and flattens at large loads. mLatStiffY describes the maximum possible value of lateralStiffness/restLoad that occurs when (load/restLoad)>= mLatStiffX. \note If load/restLoad is greater than mLatStiffX then the lateral stiffness is mLatStiffY*restLoad. \note If load/restLoad is less than mLatStiffX then the lateral stiffness is mLastStiffY*(load/mLatStiffX) \note Lateral force can be approximated as lateralStiffness * lateralSlip. \note Specified in per radian. <b>Range:</b> [0, PX_MAX_F32)<br> */ PxReal mLatStiffY; /** \brief Tire Longitudinal stiffness per unit gravitational acceleration. \note Longitudinal stiffness of the tire is calculated as gravitationalAcceleration*mLongitudinalStiffnessPerUnitGravity. \note Longitudinal force can be approximated as gravitationalAcceleration*mLongitudinalStiffnessPerUnitGravity*longitudinalSlip. \note Specified in kilograms per radian. <b>Range:</b> [0, PX_MAX_F32)<br> */ PxReal mLongitudinalStiffnessPerUnitGravity; /** \brief tire Tire camber stiffness per unity gravitational acceleration. \note Camber stiffness of the tire is calculated as gravitationalAcceleration*mCamberStiffnessPerUnitGravity \note Camber force can be approximated as gravitationalAcceleration*mCamberStiffnessPerUnitGravity*camberAngle. \note Specified in kilograms per radian. <b>Range:</b> [0, PX_MAX_F32)<br> */ PxReal mCamberStiffnessPerUnitGravity; /** \brief Graph of friction vs longitudinal slip with 3 points. \note mFrictionVsSlipGraph[0][0] is always zero. \note mFrictionVsSlipGraph[0][1] is the friction available at zero longitudinal slip. \note mFrictionVsSlipGraph[1][0] is the value of longitudinal slip with maximum friction. \note mFrictionVsSlipGraph[1][1] is the maximum friction. \note mFrictionVsSlipGraph[2][0] is the end point of the graph. \note mFrictionVsSlipGraph[2][1] is the value of friction for slips greater than mFrictionVsSlipGraph[2][0]. \note The friction value computed from the friction vs longitudinal slip graph is used to scale the friction value for the combination of material and tire type (PxVehicleDrivableSurfaceToTireFrictionPairs). \note mFrictionVsSlipGraph[2][0] > mFrictionVsSlipGraph[1][0] > mFrictionVsSlipGraph[0][0] \note mFrictionVsSlipGraph[1][1] is typically greater than mFrictionVsSlipGraph[0][1] \note mFrictionVsSlipGraph[2][1] is typically smaller than mFrictionVsSlipGraph[1][1] \note longitudinal slips > mFrictionVsSlipGraph[2][0] use friction multiplier mFrictionVsSlipGraph[2][1] \note The final friction value used by the tire model is the value returned by PxVehicleDrivableSurfaceToTireFrictionPairs multiplied by the value computed from mFrictionVsSlipGraph. @see PxVehicleDrivableSurfaceToTireFrictionPairs, PxVehicleComputeTireForce <b>Range:</b> [0, PX_MAX_F32)<br> */ PxReal mFrictionVsSlipGraph[3][2]; /** \brief Tire type denoting slicks, wets, snow, winter, summer, all-terrain, mud etc. @see PxVehicleDrivableSurfaceToTireFrictionPairs <b>Range:</b> [0, PX_MAX_F32)<br> */ PxU32 mType; /** \brief Return Cached value of 1.0/mLongitudinalStiffnessPerUnitGravity @see PxVehicleWheelsSimData::setTireData */ PX_FORCE_INLINE PxReal getRecipLongitudinalStiffnessPerUnitGravity() const {return mRecipLongitudinalStiffnessPerUnitGravity;} /** \brief Return Cached value of 1.0f/(mFrictionVsSlipGraph[1][0]-mFrictionVsSlipGraph[0][0]) @see PxVehicleWheelsSimData::setTireData */ PX_FORCE_INLINE PxReal getFrictionVsSlipGraphRecipx1Minusx0() const {return mFrictionVsSlipGraphRecipx1Minusx0;} /** \brief Return Cached value of 1.0f/(mFrictionVsSlipGraph[2][0]-mFrictionVsSlipGraph[1][0]) @see PxVehicleWheelsSimData::setTireData */ PX_FORCE_INLINE PxReal getFrictionVsSlipGraphRecipx2Minusx1() const {return mFrictionVsSlipGraphRecipx2Minusx1;} private: /** \brief Cached value of 1.0/mLongitudinalStiffnessPerUnitGravity. \note Not necessary to set this value because it is set by PxVehicleWheelsSimData::setTireData @see PxVehicleWheelsSimData::setTireData */ PxReal mRecipLongitudinalStiffnessPerUnitGravity; /** \brief Cached value of 1.0f/(mFrictionVsSlipGraph[1][0]-mFrictionVsSlipGraph[0][0]) \note Not necessary to set this value because it is set by PxVehicleWheelsSimData::setTireData @see PxVehicleWheelsSimData::setTireData */ PxReal mFrictionVsSlipGraphRecipx1Minusx0; /** \brief Cached value of 1.0f/(mFrictionVsSlipGraph[2][0]-mFrictionVsSlipGraph[1][0]) \note Not necessary to set this value because it is set by PxVehicleWheelsSimData::setTireData @see PxVehicleWheelsSimData::setTireData */ PxReal mFrictionVsSlipGraphRecipx2Minusx1; PxReal mPad[2]; bool isValid() const; }; PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleTireData)& 0x0f)); #if !PX_DOXYGEN } // namespace physx #endif #endif
39,557
C
28.172566
202
0.755618