5#include <glm/gtc/quaternion.hpp>
6#include <entt/entt.hpp>
23class btCollisionShape;
24class btDiscreteDynamicsWorld;
48 std::shared_ptr<Entities::SceneNode> sceneNode);
135 void teleport(
const glm::vec3& position,
const glm::quat& rotation);
Base class for collision shape components.
Logic(Entities::Scene *owningScene)
float getRestitution() const
Gets the restitution.
float getMass() const
Gets the mass of the rigid body.
void setRestitution(float restitution)
Sets the restitution (bounciness).
void setAngularVelocity(const glm::vec3 &velocity)
Sets the angular velocity.
std::vector< Components::Collision * > collisions_
static constexpr bool IsUnique
float getFriction() const
Gets the friction coefficient.
glm::vec3 getAngularVelocity() const
Gets the angular velocity.
void debugDraw() const
Draws debug visualization of all collision shapes.
void endPlay() override
Called when the component is removed or the game ends.
void beginPlay() override
Called when the component is added to the scene or the game starts.
std::weak_ptr< Entities::SceneNode > sceneNode_
btCompoundShape * compoundShape_
btDiscreteDynamicsWorld * getDynamicsWorld() const
Gets the Bullet dynamics world.
void setMass(float mass)
Sets the mass of the rigid body.
void rebuildCollisionShape()
void unregisterCollision(Components::Collision *collision)
Unregisters a collision component from this body. Called by CollisionComponent::endPlay().
void teleport(const glm::vec3 &position, const glm::quat &rotation)
Teleports the body to a new position and rotation.
void markShapeDirty()
Marks the collision shape as needing rebuild. Called when a collision component's shape changes.
void teleport(const glm::vec3 &position)
Teleports the body to a new position.
glm::vec3 getLinearVelocity() const
Gets the linear velocity.
void rebuildIfDirty()
Rebuilds the collision shape if dirty.
void registerCollision(Components::Collision *collision)
Registers a collision component with this body. Called by CollisionComponent::beginPlay().
bool isKinematic() const
Checks if the body is kinematic.
void setLinearVelocity(const glm::vec3 &velocity)
Sets the linear velocity.
PhysicsBody(Entities::Scene *scene, entt::entity entity, std::shared_ptr< Entities::SceneNode > sceneNode)
Constructs a PhysicsBodyComponent.
void setFriction(float friction)
Sets the friction coefficient.
Core::PhysicsEngine * getPhysicsEngine() const
void updateEcsComponent()
void processCollisions()
Processes collision events and dispatches callbacks. Called after physics step.
void setStatic(bool isStatic)
Sets whether the body is static (immovable).
static constexpr const char * ComponentName
void setKinematic(bool kinematic)
Sets whether the body is kinematic. Kinematic bodies are moved by code, not physics.
bool isStatic() const
Checks if the body is static.
btRigidBody * getRigidBody() const
Gets the Bullet rigid body.
std::set< Components::Collision * > previousCollisions_
The physics engine manages creating and destroying physics objects for the physics simulation.
Represents a node in the scene graph, containing information about its position, rotation,...
A scene is the overarching structure which can spawn, contain and destroy actors or entities.
Core audio subsystem owning the miniaudio engine and managing playback.