ReactPhysics3D  v0.10.1
C++ Physics engine library
reactphysics3d::PhysicsCommon Class Reference

This class is a singleton that needs to be instanciated once at the beginning. More...

#include <include/reactphysics3d/engine/PhysicsCommon.h>

Public Member Functions

 PhysicsCommon (MemoryAllocator *baseMemoryAllocator=nullptr)
 Constructor. More...
 
 ~PhysicsCommon ()
 Destructor.
 
PhysicsWorldcreatePhysicsWorld (const PhysicsWorld::WorldSettings &worldSettings=PhysicsWorld::WorldSettings())
 Create and return an instance of PhysicsWorld. More...
 
void destroyPhysicsWorld (PhysicsWorld *world)
 Destroy an instance of PhysicsWorld. More...
 
SphereShapecreateSphereShape (const decimal radius)
 Create and return a sphere collision shape. More...
 
void destroySphereShape (SphereShape *sphereShape)
 Destroy a sphere collision shape. More...
 
BoxShapecreateBoxShape (const Vector3 &extent)
 Create and return a box collision shape. More...
 
void destroyBoxShape (BoxShape *boxShape)
 Destroy a box collision shape. More...
 
CapsuleShapecreateCapsuleShape (decimal radius, decimal height)
 Create and return a capsule shape. More...
 
void destroyCapsuleShape (CapsuleShape *capsuleShape)
 Destroy a capsule collision shape. More...
 
ConvexMeshShapecreateConvexMeshShape (ConvexMesh *convexMesh, const Vector3 &scaling=Vector3(1, 1, 1))
 Create and return a convex mesh shape. More...
 
void destroyConvexMeshShape (ConvexMeshShape *convexMeshShape)
 Destroy a convex mesh shape. More...
 
HeightFieldcreateHeightField (int nbGridColumns, int nbGridRows, const void *heightFieldData, HeightField::HeightDataType dataType, std::vector< Message > &messages, decimal integerHeightScale=1.0f)
 Create and return a height-field. More...
 
HeightFieldShapecreateHeightFieldShape (HeightField *heightField, const Vector3 &scaling=Vector3(1, 1, 1))
 Create and return a height-field shape. More...
 
void destroyHeightFieldShape (HeightFieldShape *heightFieldShape)
 Destroy a height-field shape. More...
 
ConcaveMeshShapecreateConcaveMeshShape (TriangleMesh *triangleMesh, const Vector3 &scaling=Vector3(1, 1, 1))
 Create and return a concave mesh shape. More...
 
void destroyConcaveMeshShape (ConcaveMeshShape *concaveMeshShape)
 Destroy a concave mesh shape. More...
 
ConvexMeshcreateConvexMesh (const PolygonVertexArray &polygonVertexArray, std::vector< Message > &messages)
 Create a convex mesh from a PolygonVertexArray describing vertices and faces. More...
 
ConvexMeshcreateConvexMesh (const VertexArray &vertexArray, std::vector< Message > &messages)
 Create a convex mesh from an array of vertices (automatically computing the convex hull using QuickHull) More...
 
void destroyConvexMesh (ConvexMesh *convexMesh)
 Destroy a convex mesh. More...
 
TriangleMeshcreateTriangleMesh (const TriangleVertexArray &triangleVertexArray, std::vector< Message > &messages)
 Create a triangle mesh. More...
 
void destroyTriangleMesh (TriangleMesh *triangleMesh)
 Destroy a triangle mesh. More...
 
void destroyHeightField (HeightField *heightField)
 Destroy a height-field. More...
 
DefaultLoggercreateDefaultLogger ()
 Create and return a new default logger. More...
 
void destroyDefaultLogger (DefaultLogger *logger)
 Destroy a default logger. More...
 

Static Public Member Functions

static LoggergetLogger ()
 Return the current logger. More...
 
static void setLogger (Logger *logger)
 Set the logger. More...
 

Detailed Description

This class is a singleton that needs to be instanciated once at the beginning.

Then this class is used by the user as a factory to create the physics world and other objects.

Constructor & Destructor Documentation

◆ PhysicsCommon()

PhysicsCommon::PhysicsCommon ( MemoryAllocator baseMemoryAllocator = nullptr)

Constructor.

Parameters
baseMemoryAllocatorPointer to a user custom memory allocator

Member Function Documentation

◆ createBoxShape()

BoxShape * PhysicsCommon::createBoxShape ( const Vector3 halfExtents)

Create and return a box collision shape.

Parameters
halfExtentsA vector with the three half-extents of the box shape
Returns
A pointer to the created box shape

◆ createCapsuleShape()

CapsuleShape * PhysicsCommon::createCapsuleShape ( decimal  radius,
decimal  height 
)

Create and return a capsule shape.

Parameters
radiusThe radius of the sphere of the capsule shape
heightThe height of the capsule shape (distance betwen the two spheres centers)
Returns
boxShape A pointer to the created capsule shape

◆ createConcaveMeshShape()

ConcaveMeshShape * PhysicsCommon::createConcaveMeshShape ( TriangleMesh triangleMesh,
const Vector3 scaling = Vector3(1, 1, 1) 
)

Create and return a concave mesh shape.

Parameters
triangleMeshA pointer to the triangle mesh to use to create the concave mesh shape
scalingAn optional scaling factor to scale the triangle mesh
Returns
A pointer to the created concave mesh shape

◆ createConvexMesh() [1/2]

ConvexMesh * PhysicsCommon::createConvexMesh ( const PolygonVertexArray polygonVertexArray,
std::vector< Message > &  messages 
)

Create a convex mesh from a PolygonVertexArray describing vertices and faces.

The data (vertices, faces indices, ...) are copied from the PolygonVertexArray into the created ConvexMesh.

Parameters
polygonVertexArrayA pointer to the polygon vertex array to use to create the convex mesh
messagesA reference to a vector of messages. This vector might contains errors that occured during the creation
Returns
A pointer to the created ConvexMesh instance or nullptr if errors occured during the creation

◆ createConvexMesh() [2/2]

ConvexMesh * PhysicsCommon::createConvexMesh ( const VertexArray vertexArray,
std::vector< Message > &  messages 
)

Create a convex mesh from an array of vertices (automatically computing the convex hull using QuickHull)

The data (vertices) are copied from the VertexArray into the created ConvexMesh.

Parameters
vertexArrayA reference to the vertex object describing the vertices used to compute the convex hull
messagesA reference to the array of messages with errors that might have happened during convex mesh creation
Returns
A pointer to the created ConvexMesh instance or nullptr if errors occured during the creation

◆ createConvexMeshShape()

ConvexMeshShape * PhysicsCommon::createConvexMeshShape ( ConvexMesh convexMesh,
const Vector3 scaling = Vector3(1,1,1) 
)

Create and return a convex mesh shape.

Parameters
convexMeshA pointer to the convex mesh for this shape
scalingScaling factor to scale the convex mesh if necessary
Returns
A pointer to the created convex mesh shape

◆ createDefaultLogger()

DefaultLogger * PhysicsCommon::createDefaultLogger ( )

Create and return a new default logger.

Returns
A pointer to the created default logger

◆ createHeightField()

HeightField * PhysicsCommon::createHeightField ( int  nbGridColumns,
int  nbGridRows,
const void *  heightFieldData,
HeightField::HeightDataType  dataType,
std::vector< Message > &  messages,
decimal  integerHeightScale = 1.0f 
)

Create and return a height-field.

Parameters
nbGridColumnsNumber of columns in the grid of the height field (along the local x axis)
nbGridRowsNumber of rows in the grid of the height field (along the local z axis)
heightFieldDataPointer to the first height value data (note that values are copied into the heigh-field)
dataTypeData type for the height values (int, float, double)
[out]messagesA reference to the array where the messages (warnings, errors, ...) will be stored
integerHeightScaleScaling factor for the height values of the height field
Returns
A pointer to the created height-field

◆ createHeightFieldShape()

HeightFieldShape * PhysicsCommon::createHeightFieldShape ( HeightField heightField,
const Vector3 scaling = Vector3(1,1,1) 
)

Create and return a height-field shape.

Parameters
heightFieldA pointer to a HeightField object
scalingScaling vector for the height field
Returns
A pointer to the created height field shape

◆ createPhysicsWorld()

PhysicsWorld * PhysicsCommon::createPhysicsWorld ( const PhysicsWorld::WorldSettings worldSettings = PhysicsWorld::WorldSettings())

Create and return an instance of PhysicsWorld.

Parameters
worldSettingsThe settings of the physics world
Returns
A pointer to the created physics world

◆ createSphereShape()

SphereShape * PhysicsCommon::createSphereShape ( const decimal  radius)

Create and return a sphere collision shape.

Parameters
radiusThe radius of the sphere collision shape
Returns
A pointer to the created sphere shape

◆ createTriangleMesh()

TriangleMesh * PhysicsCommon::createTriangleMesh ( const TriangleVertexArray triangleVertexArray,
std::vector< Message > &  messages 
)

Create a triangle mesh.

The data (vertices, faces indices) are copied from the TriangleVertexArray into the created ConvexMesh.

Parameters
triangleVertexArrayA reference to the input TriangleVertexArray
messagesA reference to the array to stored the messages (warnings, erros, ...)
Returns
A pointer to the created triangle mesh

◆ destroyBoxShape()

void PhysicsCommon::destroyBoxShape ( BoxShape boxShape)

Destroy a box collision shape.

Parameters
boxShapeA pointer to the box shape to destroy

◆ destroyCapsuleShape()

void PhysicsCommon::destroyCapsuleShape ( CapsuleShape capsuleShape)

Destroy a capsule collision shape.

Parameters
capsuleShapeA pointer to the capsule shape to destroy

◆ destroyConcaveMeshShape()

void PhysicsCommon::destroyConcaveMeshShape ( ConcaveMeshShape concaveMeshShape)

Destroy a concave mesh shape.

Parameters
concaveMeshShapeA pointer to the concave mesh shape to destroy

◆ destroyConvexMesh()

void PhysicsCommon::destroyConvexMesh ( ConvexMesh convexMesh)

Destroy a convex mesh.

Parameters
convexMeshA pointer to the convex mesh to destroy

◆ destroyConvexMeshShape()

void PhysicsCommon::destroyConvexMeshShape ( ConvexMeshShape convexMeshShape)

Destroy a convex mesh shape.

Parameters
convexMeshShapeA pointer to the convex mesh shape to destroy

◆ destroyDefaultLogger()

void PhysicsCommon::destroyDefaultLogger ( DefaultLogger logger)

Destroy a default logger.

Parameters
loggerA pointer to the default logger to destroy

◆ destroyHeightField()

void PhysicsCommon::destroyHeightField ( HeightField heightField)

Destroy a height-field.

Parameters
heightFieldA pointer to the height field to destroy

◆ destroyHeightFieldShape()

void PhysicsCommon::destroyHeightFieldShape ( HeightFieldShape heightFieldShape)

Destroy a height-field shape.

Parameters
heightFieldShapeA pointer to the height field shape to destroy

◆ destroyPhysicsWorld()

void PhysicsCommon::destroyPhysicsWorld ( PhysicsWorld world)

Destroy an instance of PhysicsWorld.

Parameters
worldA pointer to the physics world to destroy

◆ destroySphereShape()

void PhysicsCommon::destroySphereShape ( SphereShape sphereShape)

Destroy a sphere collision shape.

Parameters
sphereShapeA pointer to the sphere collision shape to destroy

◆ destroyTriangleMesh()

void PhysicsCommon::destroyTriangleMesh ( TriangleMesh triangleMesh)

Destroy a triangle mesh.

Parameters
triangleMeshA pointer to the triangle mesh to destroy

◆ getLogger()

RP3D_FORCE_INLINE Logger * reactphysics3d::PhysicsCommon::getLogger ( )
static

Return the current logger.

Returns
A pointer to the current logger

◆ setLogger()

RP3D_FORCE_INLINE void reactphysics3d::PhysicsCommon::setLogger ( Logger logger)
static

Set the logger.

Parameters
loggerA pointer to the logger to use

The documentation for this class was generated from the following files: