6#include <glm/gtc/quaternion.hpp>
7#include <entt/entt.hpp>
14class btCollisionShape;
168 virtual void debugDraw(
const glm::mat4& worldTransform)
const;
Base class for collision shape components.
btCollisionShape * getShape() const
Gets the current collision shape.
virtual void onCollisionStay(Components::Collision *other)
Called every frame while colliding with another object.
void setIsTrigger(bool trigger)
Sets whether this collision is a trigger (overlap only, no physics response).
static void setDebugDrawEnabled(bool enabled)
Enable or disable debug drawing for all collision components.
static constexpr const char * ComponentName
static bool debugDrawEnabled_
virtual void debugDraw(const glm::mat4 &worldTransform) const
Draws debug visualization of the collision shape.
void markDirty()
Marks the shape as needing rebuild. Call after changing shape properties (halfExtents,...
void setLocalRotation(const glm::quat &rotation)
Sets the local rotation relative to the body.
void endPlay() override
Called when the component is removed or the game ends.
glm::vec3 getLocalOffset() const
Gets the local position offset.
btCollisionShape * shape_
Components::PhysicsBody * bodyComponent_
void setLocalOffset(const glm::vec3 &offset)
Sets the local position offset relative to the body.
const std::string & getDebugName() const
std::uint64_t debugColorSeed_
virtual void destroyShape()
Destroys the current shape.
void setDebugColorSeed(std::uint64_t seed)
void beginPlay() override
Called when the component is added to the scene or the game starts.
glm::mat4 getLocalTransform() const
Gets the local transform matrix.
Components::PhysicsBody * getBodyComponent() const
Gets the physics body component this collision is registered with.
void setDebugName(std::string name)
virtual void onCollisionBegin(Components::Collision *other)
Called when a collision with another object begins.
bool isTrigger() const
Checks if this collision is a trigger.
static bool isDebugDrawEnabled()
Check if debug drawing is enabled globally.
void rebuild()
Rebuilds the shape and notifies PhysicsBodyComponent.
Collision(Engine::Entities::Scene *scene, entt::entity entity)
Constructs a CollisionComponent.
glm::quat getLocalRotation() const
Gets the local rotation.
virtual btCollisionShape * createShape()=0
Creates the Bullet collision shape. Must be implemented by derived classes.
void unregisterFromBody()
static constexpr bool IsUnique
virtual void onCollisionEnd(Components::Collision *other)
Called when a collision with another object ends.
glm::vec4 getDebugDrawColor(const glm::vec4 &fallbackColor) const
Logic(Entities::Scene *owningScene)
Component that manages a physics rigid body for an entity.
A scene is the overarching structure which can spawn, contain and destroy actors or entities.