5#include <glm/gtc/quaternion.hpp>
6#include <entt/entt.hpp>
13class btCollisionShape;
42 std::shared_ptr<SceneNode> sceneNode);
122 void teleport(
const glm::vec3& position);
129 void teleport(
const glm::vec3& position,
const glm::quat& rotation);
Base class for collision shape components.
LogicComponent(Scene *owningScene)
void unregisterCollision(CollisionComponent *collision)
Unregisters a collision component from this body. Called by CollisionComponent::endPlay().
void registerCollision(CollisionComponent *collision)
Registers a collision component with this body. Called by CollisionComponent::beginPlay().
void beginPlay() override
Called when the component is added to the scene or the game starts.
void endPlay() override
Called when the component is removed or the game ends.
void setRestitution(float restitution)
Sets the restitution (bounciness).
float getRestitution() const
Gets the restitution.
bool isKinematic() const
Checks if the body is kinematic.
void setFriction(float friction)
Sets the friction coefficient.
void rebuildCollisionShape()
void setStatic(bool isStatic)
Sets whether the body is static (immovable).
glm::vec3 getAngularVelocity() const
Gets the angular velocity.
void markShapeDirty()
Marks the collision shape as needing rebuild. Called when a collision component's shape changes.
PhysicsEngine * getPhysicsEngine() const
std::weak_ptr< SceneNode > sceneNode_
std::set< CollisionComponent * > previousCollisions_
bool isStatic() const
Checks if the body is static.
float getFriction() const
Gets the friction coefficient.
~PhysicsBodyComponent() override
void setKinematic(bool kinematic)
Sets whether the body is kinematic. Kinematic bodies are moved by code, not physics.
void setAngularVelocity(const glm::vec3 &velocity)
Sets the angular velocity.
glm::vec3 getLinearVelocity() const
Gets the linear velocity.
void updateEcsComponent()
btCompoundShape * compoundShape_
void setMass(float mass)
Sets the mass of the rigid body.
void processCollisions()
Processes collision events and dispatches callbacks. Called after physics step.
btRigidBody * getRigidBody() const
Gets the Bullet rigid body.
void setLinearVelocity(const glm::vec3 &velocity)
Sets the linear velocity.
void rebuildIfDirty()
Rebuilds the collision shape if dirty.
void teleport(const glm::vec3 &position)
Teleports the body to a new position.
std::vector< CollisionComponent * > collisions_
static constexpr bool IsUnique
PhysicsBodyComponent(Scene *scene, entt::entity entity, std::shared_ptr< SceneNode > sceneNode)
Constructs a PhysicsBodyComponent.
float getMass() const
Gets the mass of the rigid body.
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 actors.
Log category system implementation.