3#include <btBulletDynamicsCommon.h>
4#include <glm/mat4x4.hpp>
64 btCollisionShape*
shape =
nullptr;
112 const glm::vec3& origin,
113 const glm::vec3& direction,
128 const glm::vec3& from,
132 const btCollisionObject* ignoredObject =
nullptr
144 const glm::vec3& position,
147 const btCollisionObject* ignoredObject =
nullptr
175 static btCollisionShape *
createPlaneShape(
const glm::vec3& surfaceNormal,
float distanceFromOrigin);
194 const std::vector<glm::vec3>& vertices,
195 const std::vector<uint32_t>& indices,
196 btTriangleMesh*& triangleMeshOut);
Component that manages a physics rigid body for an entity.
bool raycastClosest(const glm::vec3 &origin, const glm::vec3 &direction, float maxDistance, Physics::RaycastHit &outHit) const
Casts a ray through the physics world and returns the closest hit, if any.
btCollisionDispatcher * dispatcher
void debugDrawAll() const
Draws debug visualization of all collision shapes in the world.
btConstraintSolver * solver
btRigidBody * createRigidBody(const Physics::RigidBodyCreateInfo &info) const
Creates a rigid body for the physics simulation.
static btCollisionShape * createConvexHullShape(const std::vector< glm::vec3 > &vertices)
Creates a convex hull collision shape from a set of vertices.
btDiscreteDynamicsWorld * getDynamicsWorld() const
Gets the world where the physics simulation is performed inside.
bool sphereClosest(const glm::vec3 &position, float radius, Physics::RaycastHit &outHit, const btCollisionObject *ignoredObject=nullptr) const
Tests a sphere at one position and returns the closest overlapping collision object,...
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.
btCollisionConfiguration * collisionConfiguration
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 ...
btBroadphaseInterface * broadphase
void removeRigidBody(btRigidBody *body) const
Removes a rigid body from the physics simulation.
static btCollisionShape * createBoxShape(const glm::vec3 &halfExtents)
Creates a collision box.
void onPhysicsComponentDestroyed(entt::registry ®istry, entt::entity entity)
Cleans up the hit box pointers and motion state if applicable.
static btCompoundShape * createCompoundShape()
Creates an empty compound shape for combining multiple collision shapes.
bool sphereSweepClosest(const glm::vec3 &from, const glm::vec3 &to, float radius, Physics::RaycastHit &outHit, const btCollisionObject *ignoredObject=nullptr) const
Sweeps a sphere through the physics world and returns the closest overlap hit, if any.
static btCollisionShape * createSphereShape(float radius)
Creates a collision sphere.
static btCollisionShape * createTriangleMeshShape(const std::vector< glm::vec3 > &vertices, const std::vector< uint32_t > &indices, btTriangleMesh *&triangleMeshOut)
Creates a triangle mesh collision shape from vertices and indices.
btDiscreteDynamicsWorld * dynamicsWorld
Manages IBL (Image-Based Lighting) resources for specular reflections.
Result data for physics raycasts and sweep tests.
glm::vec3 normal
World-space surface normal at the impact point.
float distance
Distance from query origin to impact point in meters.
Components::PhysicsBody * getPhysicsBody() const
Gets the engine physics body attached to collisionObject.
const btCollisionObject * collisionObject
Bullet collision object hit by the query.
float fraction
Normalized hit fraction along the query segment.
glm::vec3 point
World-space impact point.
Rigid body create info is used to create a rigid body. It delivers all informations like the initial ...
btCollisionShape * shape
pointer to the collision shape
float friction
friction 0.0f - 1.0f. 0 is ice 0.3f - 0.5f wood or plastic. 0.7f - 1.0f High friction
float restitution
energy absorption 0.0f means full absorption on impact, 0.5f half of the energy is maintained after i...
glm::mat4 transform
initial location for the rigid body
float mass
mass in Kilograms. Mass of 0 is a static object --> immovable