32#include "common/PxMetaData.h"
35#include "ScShapeCore.h"
37#include "CmPtrTable.h"
54 void preExportDataReset();
64 const PxU16* materialIndices,
67 PxShapeCoreFlag::Enum flag = PxShapeCoreFlag::Enum(0));
128 PX_FORCE_INLINE PxU32 getActorCount()
const {
return mFreeSlot & ACTOR_COUNT_MASK; }
129 PX_FORCE_INLINE bool isExclusiveFast()
const {
return mCore.getCore().mShapeCoreFlags.isSet(PxShapeCoreFlag::eIS_EXCLUSIVE); }
137 template <
typename PxMaterialType,
typename NpMaterialType>
138 PX_INLINE PxMaterialType* getMaterial(PxU32 index)
const {
return scGetMaterial<NpMaterialType>(index); }
142 if(isExclusiveFast())
146 void releaseInternal();
147 template <
typename PxMaterialType>
148 static PX_INLINE bool checkMaterialSetup(
const PxGeometry& geom,
const char* errorMsgPrefix, PxMaterialType*
const* materials, PxU16 materialCount);
150 void onActorAttach(
PxActor& actor);
151 void onActorDetach();
153 void incActorCount();
154 void decActorCount();
159 if(isExclusiveFast())
161 PX_ASSERT(isExclusiveFast() || NP_UNUSED_BASE_INDEX == getBaseIndex());
162 PX_ASSERT(!isExclusiveFast() || NP_UNUSED_BASE_INDEX != getBaseIndex());
163 const PxU32 index = getBaseIndex();
164 return index!=NP_UNUSED_BASE_INDEX ? index : 0xffffffff;
167 return shapes.find(
this);
172 ((!isExclusiveFast() && NP_UNUSED_BASE_INDEX==getBaseIndex()) ||
173 ((getBaseIndex() < shapes.getCount()) && (shapes.getPtrs()[getBaseIndex()] ==
this)));
177 setBaseIndex(isExclusiveFast() ?
id : NP_UNUSED_BASE_INDEX);
181 setBaseIndex(NP_UNUSED_BASE_INDEX);
190 static const PxI32 EXCLUSIVE_MASK = 0x80000000;
191 static const PxI32 ACTOR_COUNT_MASK = 0x7fffffff;
194 void notifyActorAndUpdatePVD(
const PxShapeFlags oldShapeFlags);
195 void incMeshRefCount();
196 void decMeshRefCount();
199 void updateSQ(
const char* errorMessage);
200 template <
typename PxMaterialType,
typename NpMaterialType>
201 bool setMaterialsHelper(PxMaterialType*
const* materials, PxU16 materialCount);
211 return mCore.getNbMaterialIndices();
214 template <
typename Material>
215 PX_INLINE Material* scGetMaterial(PxU32 index)
const
217 PX_ASSERT(index < scGetNbMaterials());
221 const PxU16 matTableIndex = mCore.getMaterialIndices()[index];
222 return matManager.getMaterial(matTableIndex);
226 template <
typename PxMaterialType,
typename NpMaterialType>
227 PX_INLINE PxU32 scGetMaterials(PxMaterialType** buffer, PxU32 bufferSize, PxU32 startIndex=0)
const
229 const PxU16* materialIndices;
232 materialIndices = mCore.getMaterialIndices();
233 matCount = mCore.getNbMaterialIndices();
237 PxU32 size = matCount;
238 const PxU32 remainder = PxU32(PxMax<PxI32>(PxI32(size - startIndex), 0));
239 const PxU32 writeCount =
PxMin(remainder, bufferSize);
240 materialIndices += startIndex;
241 for(PxU32 i=0;i<writeCount;i++)
242 buffer[i] = matManager.getMaterial(materialIndices[i]);
247 template<
typename PxMaterialType,
typename NpMaterialType>
void setMaterialsInternal(PxMaterialType*
const * materials, PxU16 materialCount);
250template <
typename PxMaterialType>
251PX_INLINE bool NpShape::checkMaterialSetup(
const PxGeometry& geom,
const char* errorMsgPrefix, PxMaterialType*
const* materials, PxU16 materialCount)
253 for (PxU32 i = 0; i < materialCount; ++i)
258 "material pointer %d is NULL!", i);
264 if (materialCount > 1 && (geom.
getType() != PxGeometryType::eHEIGHTFIELD) && (geom.
getType() != PxGeometryType::eTRIANGLEMESH) && (geom.
getType() != PxGeometryType::eTETRAHEDRONMESH))
267 "%s: multiple materials defined for single material geometry!", errorMsgPrefix);
272 if (materialCount > 1 && (geom.
getType() == PxGeometryType::eTRIANGLEMESH))
274 const PxTriangleMeshGeometry& meshGeom =
static_cast<const PxTriangleMeshGeometry&
>(geom);
275 const PxTriangleMesh& mesh = *meshGeom.triangleMesh;
281 "%s: multiple materials defined for an SDF triangle-mesh geometry!", errorMsgPrefix);
285 if (mesh.getTriangleMaterialIndex(0) != 0xffff)
287 for (PxU32 i = 0; i < mesh.getNbTriangles(); i++)
289 const PxMaterialTableIndex meshMaterialIndex = mesh.getTriangleMaterialIndex(i);
290 if (meshMaterialIndex >= materialCount)
293 "%s: PxTriangleMesh material indices reference more materials than provided!", errorMsgPrefix);
300 if (materialCount > 1 && (geom.
getType() == PxGeometryType::eTETRAHEDRONMESH))
302 const PxTetrahedronMeshGeometry& meshGeom =
static_cast<const PxTetrahedronMeshGeometry&
>(geom);
303 const PxTetrahedronMesh& mesh = *meshGeom.tetrahedronMesh;
321 if (materialCount > 1 && (geom.
getType() == PxGeometryType::eHEIGHTFIELD))
323 const PxHeightFieldGeometry& meshGeom =
static_cast<const PxHeightFieldGeometry&
>(geom);
324 const PxHeightField& mesh = *meshGeom.heightField;
325 if (mesh.getTriangleMaterialIndex(0) != 0xffff)
327 const PxU32 nbTris = mesh.getNbColumns()*mesh.getNbRows() * 2;
328 for (PxU32 i = 0; i < nbTris; i++)
330 const PxMaterialTableIndex meshMaterialIndex = mesh.getTriangleMaterialIndex(i);
334 "%s: PxHeightField material indices reference more materials than provided!", errorMsgPrefix);
Definition NpPhysics.h:90
Definition NpMaterialManager.h:40
virtual void setSimulationFilterData(const PxFilterData &data) PX_OVERRIDE
Sets the user definable collision filter data.
Definition NpShape.cpp:358
virtual PxFilterData getQueryFilterData() const PX_OVERRIDE
Retrieves the shape's Query filter data.
Definition NpShape.cpp:393
virtual void setLocalPose(const PxTransform &pose) PX_OVERRIDE
Sets the pose of the shape in actor space, i.e. relative to the actors to which they are attached.
Definition NpShape.cpp:331
virtual PxU32 getReferenceCount() const PX_OVERRIDE
Returns the reference count of the object.
Definition NpShape.cpp:205
virtual void setDensityForFluid(PxReal) PX_OVERRIDE
Sets the density used to interact with fluids.
Definition NpShape.cpp:600
virtual PxReal getMinTorsionalPatchRadius() const PX_OVERRIDE
Gets minimum torsional patch radius.
Definition NpShape.cpp:671
virtual void setRestOffset(PxReal) PX_OVERRIDE
Sets the rest offset.
Definition NpShape.cpp:577
virtual void setTorsionalPatchRadius(PxReal) PX_OVERRIDE
Sets torsional patch radius.
Definition NpShape.cpp:622
virtual void setContactOffset(PxReal) PX_OVERRIDE
Sets the contact offset.
Definition NpShape.cpp:554
virtual void setFlag(PxShapeFlag::Enum flag, bool value) PX_OVERRIDE
Sets shape flags.
Definition NpShape.cpp:755
virtual PxU32 getMaterials(PxMaterial **userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const PX_OVERRIDE
Retrieve all the material pointers associated with the shape.
Definition NpShape.cpp:482
virtual PxU16 getNbMaterials() const PX_OVERRIDE
Returns the number of materials assigned to the shape.
Definition NpShape.cpp:476
virtual PxReal getTorsionalPatchRadius() const PX_OVERRIDE
Gets torsional patch radius.
Definition NpShape.cpp:644
virtual void setMaterials(PxMaterial *const *materials, PxU16 materialCount) PX_OVERRIDE
Assigns material(s) to the shape. Will remove existing materials from the shape.
Definition NpShape.cpp:441
virtual void setSoftBodyMaterials(PxFEMSoftBodyMaterial *const *materials, PxU16 materialCount) PX_OVERRIDE
Assigns FEM soft body material(s) to the shape. Will remove existing materials from the shape.
Definition NpShape.cpp:447
virtual void setQueryFilterData(const PxFilterData &data) PX_OVERRIDE
Sets the user definable query filter data.
Definition NpShape.cpp:379
virtual PxReal getDensityForFluid() const PX_OVERRIDE
Retrieves the density used to interact with fluids.
Definition NpShape.cpp:616
virtual void setGeometry(const PxGeometry &) PX_OVERRIDE
Adjust the geometry of the shape.
Definition NpShape.cpp:263
virtual PxRigidActor * getActor() const PX_OVERRIDE
Retrieves the actor which this shape is associated with.
Definition NpShape.cpp:325
virtual void setFlags(PxShapeFlags inFlags) PX_OVERRIDE
Sets shape flags.
Definition NpShape.cpp:773
virtual PxReal getContactOffset() const PX_OVERRIDE
Retrieves the contact offset.
Definition NpShape.cpp:571
virtual PxShapeFlags getFlags() const PX_OVERRIDE
Retrieves shape flags.
Definition NpShape.cpp:788
virtual const PxGeometry & getGeometry() const PX_OVERRIDE
Retrieve a reference to the shape's geometry.
Definition NpShape.cpp:319
virtual bool isExclusive() const PX_OVERRIDE
Returns true if the shape is exclusive to an actor.
Definition NpShape.cpp:794
virtual void release() PX_OVERRIDE
call to release from actor
Definition NpShape.cpp:215
virtual PxTransform getLocalPose() const PX_OVERRIDE
Retrieves the pose of the shape in actor space, i.e. relative to the actor they are owned by.
Definition NpShape.cpp:350
virtual PxBaseMaterial * getMaterialFromInternalFaceIndex(PxU32 faceIndex) const PX_OVERRIDE
Retrieve material from given triangle index.
Definition NpShape.cpp:507
virtual void setClothMaterials(PxFEMClothMaterial *const *materials, PxU16 materialCount) PX_OVERRIDE
Assigns FEM cloth material(s) to the shape. Will remove existing materials from the shape.
Definition NpShape.cpp:463
virtual PxU32 getSoftBodyMaterials(PxFEMSoftBodyMaterial **userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const PX_OVERRIDE
Retrieve all the FEM soft body material pointers associated with the shape.
Definition NpShape.cpp:488
virtual PxFilterData getSimulationFilterData() const PX_OVERRIDE
Retrieves the shape's collision filter data.
Definition NpShape.cpp:373
virtual PxReal getRestOffset() const PX_OVERRIDE
Retrieves the rest offset.
Definition NpShape.cpp:594
virtual PxU32 getClothMaterials(PxFEMClothMaterial **userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const PX_OVERRIDE
Retrieve all the FEM cloth material pointers associated with the shape.
Definition NpShape.cpp:501
virtual void setName(const char *debugName) PX_OVERRIDE
Sets a name string for the object that can be retrieved with getName().
Definition NpShape.cpp:830
virtual void setMinTorsionalPatchRadius(PxReal) PX_OVERRIDE
Sets minimum torsional patch radius.
Definition NpShape.cpp:650
virtual void acquireReference() PX_OVERRIDE
Acquires a counted reference to this object.
Definition NpShape.cpp:210
virtual const char * getName() const PX_OVERRIDE
retrieves the name string set with setName().
Definition NpShape.cpp:840
PxActor is the base class for the main simulation objects in the physics SDK.
Definition PxActor.h:201
Base material class.
Definition PxBaseMaterial.h:49
Binary deserialization context class.
Definition PxSerialFramework.h:174
Material class to represent a set of FEM material properties.
Definition PxFEMClothMaterial.h:48
Material class to represent a set of softbody FEM material properties.
Definition PxFEMSoftBodyMaterial.h:49
A geometry object.
Definition PxGeometry.h:79
PX_CUDA_CALLABLE PX_FORCE_INLINE PxGeometryType::Enum getType() const
Returns the type of the geometry.
Definition PxGeometry.h:85
Material class to represent a set of surface properties.
Definition PxMaterial.h:149
Output stream class for I/O.
Definition PxIO.h:114
Callback class used to process PxBase objects.
Definition PxSerialFramework.h:81
Base class for ref-counted objects.
Definition PxBase.h:200
PxRigidActor represents a base class shared between dynamic and static rigid bodies in the physics SD...
Definition PxRigidActor.h:53
Binary serialization context class.
Definition PxSerialFramework.h:99
Abstract class for collision shapes.
Definition PxShape.h:146
Definition ScRigidCore.h:61
Definition ScShapeCore.h:46
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
#define PX_OVERRIDE
Definition PxPreprocessor.h:375
PX_C_EXPORT PX_FOUNDATION_API physx::PxFoundation &PX_CALL_CONV PxGetFoundation()
Retrieves the Foundation SDK after it has been created.
Definition FdFoundation.cpp:279
#define PX_INLINE
Definition PxPreprocessor.h:320
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PX_CUDA_CALLABLE PX_FORCE_INLINE T PxMin(T a, T b)
The return value is the lesser of the two specified values.
Definition PxMath.h:88
Definition CmPtrTable.h:72
@ eINVALID_PARAMETER
method called with invalid parameter(s)
Definition PxErrors.h:62
@ eDEBUG_WARNING
a warning message for the user to help with debugging
Definition PxErrors.h:59
PxFilterData is user-definable data which gets passed into the collision filtering shader and/or call...
Definition PxFiltering.h:365
Enum
Definition PxGeometry.h:52
@ eHOLE
A material indicating that the triangle should be treated as a hole in the mesh.
Definition PxHeightFieldSample.h:51
Enum
Definition PxShape.h:70