Jolt Physics
A multi core friendly Game Physics Engine
|
Class that constructs a MeshShape. More...
#include <MeshShape.h>
Public Member Functions | |
MeshShapeSettings ()=default | |
Default constructor for deserialization. | |
MeshShapeSettings (const TriangleList &inTriangles, PhysicsMaterialList inMaterials=PhysicsMaterialList()) | |
Create a mesh shape. | |
MeshShapeSettings (VertexList inVertices, IndexedTriangleList inTriangles, PhysicsMaterialList inMaterials=PhysicsMaterialList()) | |
void | Sanitize () |
Sanitize the mesh data. Remove duplicate and degenerate triangles. This is called automatically when constructing the MeshShapeSettings with a list of (indexed-) triangles. | |
virtual ShapeResult | Create () const override |
Create a shape according to the settings specified by this object. | |
Public Member Functions inherited from ShapeSettings | |
void | ClearCachedResult () |
Public Member Functions inherited from SerializableObject | |
virtual | ~SerializableObject ()=default |
Constructor. | |
Public Member Functions inherited from NonCopyable | |
NonCopyable ()=default | |
NonCopyable (const NonCopyable &)=delete | |
void | operator= (const NonCopyable &)=delete |
Public Member Functions inherited from RefTarget< ShapeSettings > | |
RefTarget ()=default | |
Constructor. | |
RefTarget (const RefTarget &) | |
~RefTarget () | |
assert no one is referencing us | |
void | SetEmbedded () const |
RefTarget & | operator= (const RefTarget &) |
Assignment operator. | |
uint32 | GetRefCount () const |
Get current refcount of this object. | |
void | AddRef () const |
Add or release a reference to this object. | |
void | Release () const |
Public Attributes | |
VertexList | mTriangleVertices |
Vertices belonging to mIndexedTriangles. | |
IndexedTriangleList | mIndexedTriangles |
PhysicsMaterialList | mMaterials |
Materials assigned to the triangles. Each triangle specifies which material it uses through its mMaterialIndex. | |
uint | mMaxTrianglesPerLeaf = 8 |
float | mActiveEdgeCosThresholdAngle = 0.996195f |
bool | mPerTriangleUserData = false |
Public Attributes inherited from ShapeSettings | |
uint64 | mUserData = 0 |
User data (to be used freely by the application) | |
Additional Inherited Members | |
Public Types inherited from ShapeSettings | |
using | ShapeResult = Result< Ref< Shape > > |
Static Public Member Functions inherited from RefTarget< ShapeSettings > | |
static int | sInternalGetRefCountOffset () |
INTERNAL HELPER FUNCTION USED BY SERIALIZATION. | |
Protected Attributes inherited from ShapeSettings | |
ShapeResult | mCachedResult |
Protected Attributes inherited from RefTarget< ShapeSettings > | |
atomic< uint32 > | mRefCount |
Current reference count. | |
Static Protected Attributes inherited from RefTarget< ShapeSettings > | |
static constexpr uint32 | cEmbedded |
A large value that gets added to the refcount to mark the object as embedded. | |
Class that constructs a MeshShape.
|
default |
Default constructor for deserialization.
MeshShapeSettings::MeshShapeSettings | ( | const TriangleList & | inTriangles, |
PhysicsMaterialList | inMaterials = PhysicsMaterialList() |
||
) |
Create a mesh shape.
MeshShapeSettings::MeshShapeSettings | ( | VertexList | inVertices, |
IndexedTriangleList | inTriangles, | ||
PhysicsMaterialList | inMaterials = PhysicsMaterialList() |
||
) |
|
overridevirtual |
Create a shape according to the settings specified by this object.
Implements ShapeSettings.
void MeshShapeSettings::Sanitize | ( | ) |
Sanitize the mesh data. Remove duplicate and degenerate triangles. This is called automatically when constructing the MeshShapeSettings with a list of (indexed-) triangles.
float MeshShapeSettings::mActiveEdgeCosThresholdAngle = 0.996195f |
Cosine of the threshold angle (if the angle between the two triangles is bigger than this, the edge is active, note that a concave edge is always inactive). Setting this value too small can cause ghost collisions with edges, setting it too big can cause depenetration artifacts (objects not depenetrating quickly). Valid ranges are between cos(0 degrees) and cos(90 degrees). The default value is cos(5 degrees).
IndexedTriangleList MeshShapeSettings::mIndexedTriangles |
Original list of indexed triangles (triangles will be reordered internally in the mesh shape). Triangles must be provided in counter clockwise order. Degenerate triangles will automatically be removed during mesh creation but no other mesh simplifications are performed, use an external library if this is desired. For simulation, the triangles are considered to be single sided. For ray casts you can choose to make triangles double sided by setting RayCastSettings::mBackFaceMode to EBackFaceMode::CollideWithBackFaces. For collide shape tests you can use CollideShapeSettings::mBackFaceMode and for shape casts you can use ShapeCastSettings::mBackFaceModeTriangles.
PhysicsMaterialList MeshShapeSettings::mMaterials |
Materials assigned to the triangles. Each triangle specifies which material it uses through its mMaterialIndex.
uint MeshShapeSettings::mMaxTrianglesPerLeaf = 8 |
Maximum number of triangles in each leaf of the axis aligned box tree. This is a balance between memory and performance. Can be in the range [1, MeshShape::MaxTrianglesPerLeaf]. Sensible values are between 4 (for better performance) and 8 (for less memory usage).
bool MeshShapeSettings::mPerTriangleUserData = false |
When true, we store the user data coming from Triangle::mUserData or IndexedTriangle::mUserData in the mesh shape. This can be used to store additional data like the original index of the triangle in the mesh. Can be retrieved using MeshShape::GetTriangleUserData. Turning this on increases the memory used by the MeshShape by roughly 25%.
VertexList MeshShapeSettings::mTriangleVertices |
Vertices belonging to mIndexedTriangles.