ReactPhysics3D: reactphysics3d::PhysicsCommon Class Reference

| ReactPhysics3D v0.10.2 C++ Physics engine library

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
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.
| ~PhysicsCommon ()
| Destructor.
PhysicsWorld * | createPhysicsWorld (const PhysicsWorld::WorldSettings &worldSettings=PhysicsWorld::WorldSettings())
| Create and return an instance of PhysicsWorld.
void | destroyPhysicsWorld (PhysicsWorld *world)
| Destroy an instance of PhysicsWorld.
SphereShape * | createSphereShape (const decimal radius)
| Create and return a sphere collision shape.
void | destroySphereShape (SphereShape *sphereShape)
| Destroy a sphere collision shape.
BoxShape * | createBoxShape (const Vector3 &extent)
| Create and return a box collision shape.
void | destroyBoxShape (BoxShape *boxShape)
| Destroy a box collision shape.
CapsuleShape * | createCapsuleShape (decimal radius, decimal height)
| Create and return a capsule shape.
void | destroyCapsuleShape (CapsuleShape *capsuleShape)
| Destroy a capsule collision shape.
ConvexMeshShape * | createConvexMeshShape (ConvexMesh *convexMesh, const Vector3 &scaling=Vector3(1, 1, 1))
| Create and return a convex mesh shape.
void | destroyConvexMeshShape (ConvexMeshShape *convexMeshShape)
| Destroy a convex mesh shape.
HeightField * | 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.
HeightFieldShape * | createHeightFieldShape (HeightField *heightField, const Vector3 &scaling=Vector3(1, 1, 1))
| Create and return a height-field shape.
void | destroyHeightFieldShape (HeightFieldShape *heightFieldShape)
| Destroy a height-field shape.
ConcaveMeshShape * | createConcaveMeshShape (TriangleMesh *triangleMesh, const Vector3 &scaling=Vector3(1, 1, 1))
| Create and return a concave mesh shape.
void | destroyConcaveMeshShape (ConcaveMeshShape *concaveMeshShape)
| Destroy a concave mesh shape.
ConvexMesh * | createConvexMesh (const PolygonVertexArray &polygonVertexArray, std::vector< Message > &messages)
| Create a convex mesh from a PolygonVertexArray describing vertices and faces.
ConvexMesh * | createConvexMesh (const VertexArray &vertexArray, std::vector< Message > &messages)
| Create a convex mesh from an array of vertices (automatically computing the convex hull using QuickHull)
void | destroyConvexMesh (ConvexMesh *convexMesh)
| Destroy a convex mesh.
TriangleMesh * | createTriangleMesh (const TriangleVertexArray &triangleVertexArray, std::vector< Message > &messages)
| Create a triangle mesh.
void | destroyTriangleMesh (TriangleMesh *triangleMesh)
| Destroy a triangle mesh.
void | destroyHeightField (HeightField *heightField)
| Destroy a height-field.
DefaultLogger * | createDefaultLogger ()
| Create and return a new default logger.
void | destroyDefaultLogger (DefaultLogger *logger)
| Destroy a default logger.

## Static Public Member Functions
static Logger * | getLogger ()
| Return the current logger.
static void | setLogger (Logger *logger)
| Set the logger.

## 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

  baseMemoryAllocator | Pointer to a user custom memory allocator

## Member Function Documentation

## ◆ createBoxShape()

BoxShape * PhysicsCommon::createBoxShape | ( | const Vector3 & | halfExtents | ) |

Create and return a box collision shape.

Parameters

  halfExtents | A 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

  radius | The radius of the sphere of the capsule shape
  height | The 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

  triangleMesh | A pointer to the triangle mesh to use to create the concave mesh shape
  scaling | An 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

  polygonVertexArray | A pointer to the polygon vertex array to use to create the convex mesh
  messages | A 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

  vertexArray | A reference to the vertex object describing the vertices used to compute the convex hull
  messages | A 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

  convexMesh | A pointer to the convex mesh for this shape
  scaling | Scaling 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

  | nbGridColumns | Number of columns in the grid of the height field (along the local x axis)
  | nbGridRows | Number of rows in the grid of the height field (along the local z axis)
  | heightFieldData | Pointer to the first height value data (note that values are copied into the heigh-field)
  | dataType | Data type for the height values (int, float, double)
  [out] | messages | A reference to the array where the messages (warnings, errors, ...) will be stored
  | integerHeightScale | Scaling 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

  heightField | A pointer to a HeightField object
  scaling | Scaling 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

  worldSettings | The 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

  radius | The 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

  triangleVertexArray | A reference to the input TriangleVertexArray
  messages | A 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

  boxShape | A pointer to the box shape to destroy

## ◆ destroyCapsuleShape()

void PhysicsCommon::destroyCapsuleShape | ( | CapsuleShape * | capsuleShape | ) |

Destroy a capsule collision shape.

Parameters

  capsuleShape | A pointer to the capsule shape to destroy

## ◆ destroyConcaveMeshShape()

void PhysicsCommon::destroyConcaveMeshShape | ( | ConcaveMeshShape * | concaveMeshShape | ) |

Destroy a concave mesh shape.

Parameters

  concaveMeshShape | A pointer to the concave mesh shape to destroy

## ◆ destroyConvexMesh()

void PhysicsCommon::destroyConvexMesh | ( | ConvexMesh * | convexMesh | ) |

Destroy a convex mesh.

Parameters

  convexMesh | A pointer to the convex mesh to destroy

## ◆ destroyConvexMeshShape()

void PhysicsCommon::destroyConvexMeshShape | ( | ConvexMeshShape * | convexMeshShape | ) |

Destroy a convex mesh shape.

Parameters

  convexMeshShape | A pointer to the convex mesh shape to destroy

## ◆ destroyDefaultLogger()

void PhysicsCommon::destroyDefaultLogger | ( | DefaultLogger * | logger | ) |

Destroy a default logger.

Parameters

  logger | A pointer to the default logger to destroy

## ◆ destroyHeightField()

void PhysicsCommon::destroyHeightField | ( | HeightField * | heightField | ) |

Destroy a height-field.

Parameters

  heightField | A pointer to the height field to destroy

## ◆ destroyHeightFieldShape()

void PhysicsCommon::destroyHeightFieldShape | ( | HeightFieldShape * | heightFieldShape | ) |

Destroy a height-field shape.

Parameters

  heightFieldShape | A pointer to the height field shape to destroy

## ◆ destroyPhysicsWorld()

void PhysicsCommon::destroyPhysicsWorld | ( | PhysicsWorld * | world | ) |

Destroy an instance of PhysicsWorld.

Parameters

  world | A pointer to the physics world to destroy

## ◆ destroySphereShape()

void PhysicsCommon::destroySphereShape | ( | SphereShape * | sphereShape | ) |

Destroy a sphere collision shape.

Parameters

  sphereShape | A pointer to the sphere collision shape to destroy

## ◆ destroyTriangleMesh()

void PhysicsCommon::destroyTriangleMesh | ( | TriangleMesh * | triangleMesh | ) |

Destroy a triangle mesh.

Parameters

  triangleMesh | A 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

  logger | A pointer to the logger to use

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

- include/reactphysics3d/engine/PhysicsCommon.h
- src/engine/PhysicsCommon.cpp