29#ifndef GU_CONVEX_MESH_H
30#define GU_CONVEX_MESH_H
32#include "foundation/PxBitAndData.h"
33#include "common/PxMetaData.h"
34#include "geometry/PxConvexMesh.h"
35#include "geometry/PxConvexMeshGeometry.h"
36#include "foundation/PxUserAllocated.h"
37#include "CmRefCountable.h"
38#include "common/PxRenderOutput.h"
39#include "GuConvexMeshData.h"
48 struct HullPolygonData;
50 PX_INLINE PxU32 computeBufferSize(
const Gu::ConvexHullData& data, PxU32 nb)
52 PxU32 bytesNeeded =
sizeof(Gu::HullPolygonData) * data.mNbPolygons;
53 bytesNeeded +=
sizeof(PxVec3) * data.mNbHullVertices;
54 bytesNeeded +=
sizeof(PxU8) * data.mNbEdges * 2;
55 bytesNeeded +=
sizeof(PxU8) * data.mNbHullVertices * 3;
56 bytesNeeded += data.mNbEdges.isBitSet() ? (
sizeof(PxU16) * data.mNbEdges * 2) : 0;
57 bytesNeeded +=
sizeof(PxU8) * nb;
60 const PxU32 mod = bytesNeeded %
sizeof(PxReal);
62 bytesNeeded +=
sizeof(PxReal) - mod;
91 #define PX_CONVEX_VERSION 14
108 void preExportDataReset() { Cm::RefCountable_preExportDataReset(*
this); }
112 PX_PHYSX_COMMON_API
static void getBinaryMetaData(
PxOutputStream& stream);
123 virtual void onRefCountZero();
142 virtual const PxReal*
getSDF()
const;
153 PX_FORCE_INLINE const ConvexHullData& getHull()
const {
return mHullData; }
159 PX_FORCE_INLINE void setInertia(
const PxMat33& inertia) { mInertia = inertia; }
164 PX_FORCE_INLINE PxU32 getBufferSize()
const {
return computeBufferSize(mHullData, getNb()); }
166 virtual ~ConvexMesh();
168 PX_FORCE_INLINE void setMeshFactory(MeshFactory* f) { mMeshFactory = f; }
172 ConvexHullData mHullData;
183 PX_FORCE_INLINE PxU32 ownsMemory()
const {
return PxU32(!mNb.isBitSet()); }
186 PX_FORCE_INLINE const Gu::ConvexHullData* _getHullData(
const PxConvexMeshGeometry& convexGeom)
188 return &
static_cast<const Gu::ConvexMesh*
>(convexGeom.convexMesh)->getHull();
Definition GuBigConvexData2.h:42
Definition GuConvexMesh.h:94
virtual PxBounds3 getLocalBounds() const
Returns the local-space (vertex space) AABB from the convex mesh.
Definition GuConvexMesh.cpp:438
virtual PxU32 getNbVertices() const
Returns the number of vertices.
Definition GuConvexMesh.h:133
virtual void acquireReference()
Acquires a counted reference to this object.
Definition GuConvexMesh.cpp:421
virtual const PxU8 * getIndexBuffer() const
Returns the index buffer.
Definition GuConvexMesh.h:135
BigConvexData * mBigConvexData
optional, only for large meshes! PT: redundant with ptr in chull data? Could also be end of other buf...
Definition GuConvexMesh.h:176
virtual const PxReal * getSDF() const
Returns the local-space Signed Distance Field for this mesh if it has one.
Definition GuConvexMesh.cpp:444
virtual const PxVec3 * getVertices() const
Returns the vertices.
Definition GuConvexMesh.h:134
virtual bool isGpuCompatible() const
This method decides whether a convex mesh is gpu compatible. If the total number of vertices are more...
Definition GuConvexMesh.cpp:100
virtual void getMassInformation(PxReal &mass, PxMat33 &localInertia, PxVec3 &localCenterOfMass) const
Returns the mass properties of the mesh assuming unit density.
Definition GuConvexMesh.cpp:431
virtual PxU32 getNbPolygons() const
Returns the number of polygons.
Definition GuConvexMesh.h:136
virtual PxU32 getReferenceCount() const
Returns the reference count of the object.
Definition GuConvexMesh.cpp:426
virtual bool getPolygonData(PxU32 i, PxHullPolygon &data) const
Returns the polygon data.
Definition GuConvexMesh.cpp:38
virtual void release()
Decrements the reference count of a convex mesh and releases it if the new reference count is zero.
Definition GuConvexMesh.cpp:410
Definition GuMeshFactory.h:83
Represents a signed distance field.
Definition GuSDF.h:88
Class representing 3D range or axis aligned bounding box.
Definition PxBounds3.h:58
A convex mesh.
Definition PxConvexMesh.h:83
Binary deserialization context class.
Definition PxSerialFramework.h:174
3x3 matrix class
Definition PxMat33.h:91
Output stream class for I/O.
Definition PxIO.h:114
Callback class used to process PxBase objects.
Definition PxSerialFramework.h:81
Binary serialization context class.
Definition PxSerialFramework.h:99
Definition PxUserAllocated.h:43
3 Element vector class.
Definition PxVec3.h:50
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
#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
Definition GuConvexMeshData.h:109
HullPolygonData * mPolygons
Array of mNbPolygons structures.
Definition GuConvexMeshData.h:128
CenterExtents mAABB
bounds TODO: compute this on the fly from first 6 vertices in the vertex array. We'll of course need ...
Definition GuConvexMeshData.h:118
PX_FORCE_INLINE const PxU8 * getVertexData8() const
< Vertex indices indexed by hull polygons
Definition GuConvexMeshData.h:191
PxBitAndWord mNbEdges
the highest bit indicate whether we have grb data, the other 15 bits indicate the number of edges in ...
Definition GuConvexMeshData.h:123
PX_FORCE_INLINE const PxVec3 * getHullVertices() const
< Convex hull vertices
Definition GuConvexMeshData.h:152
PxU8 mNbPolygons
Number of planar polygons composing the hull.
Definition GuConvexMeshData.h:126
PxU8 mNbHullVertices
Number of vertices in the convex hull.
Definition GuConvexMeshData.h:125
Definition GuConvexMesh.h:67
Polygon data.
Definition PxConvexMesh.h:50