|
Vulkan Schnee 0.0.1
High-performance rendering engine
|
The physics engine manages creating and destroying physics objects for the physics simulation. More...
#include <PhysicsEngine.h>
Public Member Functions | |
| PhysicsEngine () | |
| ~PhysicsEngine () | |
| void | onPhysicsComponentDestroyed (entt::registry ®istry, entt::entity entity) |
| Cleans up the hit box pointers and motion state if applicable. | |
| void | update (float deltaTimeSeconds) |
| Steps the physics simulation by 1/120th of a second. The idea of the engine is that it should run on 120hz so the update rate of the physics engine should be quite close to it. | |
| btDiscreteDynamicsWorld * | getDynamicsWorld () const |
| Gets the world where the physics simulation is performed inside. | |
| btRigidBody * | createRigidBody (const RigidBodyCreateInfo &info) const |
| Creates a rigid body for the physics simulation. | |
| void | removeRigidBody (btRigidBody *body) const |
| Removes a rigid body from the physics simulation. | |
Static Public Member Functions | |
| static btCollisionShape * | createBoxShape (const glm::vec3 &halfExtents) |
| Creates a collision box. | |
| static btCollisionShape * | createSphereShape (float radius) |
| Creates a collision sphere. | |
| static btCollisionShape * | createCapsuleShape (float radius, float height) |
| creates a capsule with a height and a radius. | |
| static btCollisionShape * | createPlaneShape (const glm::vec3 &surfaceNormal, float distanceFromOrigin) |
| Creates a plane from. | |
Private Attributes | |
| btBroadphaseInterface * | broadphase |
| btCollisionConfiguration * | collisionConfiguration |
| btCollisionDispatcher * | dispatcher |
| btConstraintSolver * | solver |
| btDiscreteDynamicsWorld * | dynamicsWorld |
The physics engine manages creating and destroying physics objects for the physics simulation.
Definition at line 32 of file PhysicsEngine.h.
| EngineCore::PhysicsEngine::PhysicsEngine | ( | ) |
Definition at line 11 of file PhysicsEngine.cpp.
References broadphase, collisionConfiguration, dispatcher, dynamicsWorld, Ecs::RegistryManager::get(), and solver.
| EngineCore::PhysicsEngine::~PhysicsEngine | ( | ) |
Definition at line 24 of file PhysicsEngine.cpp.
References broadphase, collisionConfiguration, dispatcher, dynamicsWorld, and solver.
|
static |
Creates a collision box.
| halfExtents | xyz half extents |
Definition at line 75 of file PhysicsEngine.cpp.
References bt::getVec3().
|
static |
creates a capsule with a height and a radius.
| radius | in meters |
| height | in meters |
Definition at line 85 of file PhysicsEngine.cpp.
|
static |
Creates a plane from.
| surfaceNormal | surface normal of the plane |
| distanceFromOrigin | how much to move the plane along the surface |
Definition at line 90 of file PhysicsEngine.cpp.
References bt::getVec3().
|
nodiscard |
Creates a rigid body for the physics simulation.
| info | create info which defines how the rigid body should behave in the simulation |
Definition at line 95 of file PhysicsEngine.cpp.
References dynamicsWorld, EngineCore::RigidBodyCreateInfo::friction, EngineCore::RigidBodyCreateInfo::mass, EngineCore::RigidBodyCreateInfo::restitution, EngineCore::RigidBodyCreateInfo::shape, and EngineCore::RigidBodyCreateInfo::transform.
Referenced by EngineCore::PhysicsBodyComponent::createRigidBody().
|
static |
Creates a collision sphere.
| radius | in meters |
Definition at line 80 of file PhysicsEngine.cpp.
|
nodiscard |
Gets the world where the physics simulation is performed inside.
Definition at line 70 of file PhysicsEngine.cpp.
References dynamicsWorld.
Referenced by EngineCore::PhysicsBodyComponent::processCollisions(), EngineCore::PhysicsBodyComponent::registerCollision(), and EngineCore::PhysicsBodyComponent::unregisterCollision().
| void EngineCore::PhysicsEngine::onPhysicsComponentDestroyed | ( | entt::registry & | registry, |
| entt::entity | entity ) |
Cleans up the hit box pointers and motion state if applicable.
| registry | which registry the element was destroyed from |
| entity | which entity the component belonged to |
Definition at line 48 of file PhysicsEngine.cpp.
References dynamicsWorld.
| void EngineCore::PhysicsEngine::removeRigidBody | ( | btRigidBody * | body | ) | const |
Removes a rigid body from the physics simulation.
| body | ptr to the rigid body to remove |
Definition at line 118 of file PhysicsEngine.cpp.
References dynamicsWorld.
Referenced by EngineCore::PhysicsBodyComponent::destroyRigidBody().
| void EngineCore::PhysicsEngine::update | ( | float | deltaTimeSeconds | ) |
Steps the physics simulation by 1/120th of a second. The idea of the engine is that it should run on 120hz so the update rate of the physics engine should be quite close to it.
| deltaTimeSeconds | time between this and the last frame in seconds |
Definition at line 64 of file PhysicsEngine.cpp.
References dynamicsWorld, and TRACY_ZONE_SCOPED_NAMED.
Referenced by EngineCore::Engine::update().
|
private |
Definition at line 99 of file PhysicsEngine.h.
Referenced by PhysicsEngine(), and ~PhysicsEngine().
|
private |
Definition at line 100 of file PhysicsEngine.h.
Referenced by PhysicsEngine(), and ~PhysicsEngine().
|
private |
Definition at line 101 of file PhysicsEngine.h.
Referenced by PhysicsEngine(), and ~PhysicsEngine().
|
private |
Definition at line 103 of file PhysicsEngine.h.
Referenced by createRigidBody(), getDynamicsWorld(), onPhysicsComponentDestroyed(), PhysicsEngine(), removeRigidBody(), update(), and ~PhysicsEngine().
|
private |
Definition at line 102 of file PhysicsEngine.h.
Referenced by PhysicsEngine(), and ~PhysicsEngine().