Claire's Game Engine
Full C++ Engine using OpenGL
Loading...
Searching...
No Matches
RectangleColliderComponent Class Reference

RectangleColliderComponent represents a 2D axis-aligned bounding box (AABB) collider. It provides collision detection and debug rendering for rectangular shapes in 2D space. More...

#include <RectangleColliderComponent.h>

Inheritance diagram for RectangleColliderComponent:
ColliderComponent Component DebugRenderInterface

Public Member Functions

 RectangleColliderComponent (Actor *pOwner)
 Constructor for RectangleColliderComponent.
 
void DebugRender (IRenderer *pRenderer) override
 Renders the rectangle as a line in the world for debugging purposes.
 
Rectangle GetWorldRectangle () const
 Gets the world-space rectangle based on the owner's position. Transforms the local-space rectangle to its global position.
 
bool Collision (const Rectangle &otherRectangle)
 Checks for collision with another rectangle in world space.
 
bool Collision (const ColliderComponent *pComponent) override
 Checks for collision with another collider component. Only supports collision with other RectangleColliderComponent instances.
 
- Public Member Functions inherited from ColliderComponent
 ColliderComponent (Actor *pOwner)
 Constructor for ColliderComponent.
 
void OnStart () override
 Called when the component starts. Registers the component for debug rendering and adds it to the physics system.
 
void OnEnd () override
 Called when the component ends. Unregisters the component from debug rendering and removes it from the physics system.
 
- Public Member Functions inherited from Component
 Component (Actor *pOwner, int pUpdateOrder=100)
 Constructor for Component.
 
virtual ~Component ()
 
virtual void Update ()
 Called every frame to update the component. This can be used to perform actions that need to be updated periodically.
 
virtual void OnUpdateWorldTrandform ()
 Called when the world transform of the actor is updated. This allows the component to react to changes in the actor's world transform.
 
void SetActive (bool isActive)
 Sets the active status of the component.
 
void SetOwner (Actor *pOwner)
 Sets the actor that owns this component.
 
int GetUpdateOrder () const
 Returns the update order of the component. Components with lower update orders are updated first.
 
ActorGetOwner () const
 Returns the actor that owns this component.
 

Public Attributes

Rectangle mRectangle { Vector2(-16,-16),Vector2(32,32) }
 Checks Local-space rectangle defining the collider shape.
 
- Public Attributes inherited from ColliderComponent
Color mColor { 255,0,0,255 }
 Debug rendering color for the collider (default: red).
 

Additional Inherited Members

- Protected Attributes inherited from Component
ActormOwner = nullptr
 The actor that owns this component.
 

Detailed Description

RectangleColliderComponent represents a 2D axis-aligned bounding box (AABB) collider. It provides collision detection and debug rendering for rectangular shapes in 2D space.

Constructor & Destructor Documentation

◆ RectangleColliderComponent()

RectangleColliderComponent::RectangleColliderComponent ( Actor * pOwner)

Constructor for RectangleColliderComponent.

Parameters
pOwnerThe actor that owns this collider component.

Member Function Documentation

◆ Collision() [1/2]

bool RectangleColliderComponent::Collision ( const ColliderComponent * pComponent)
overridevirtual

Checks for collision with another collider component. Only supports collision with other RectangleColliderComponent instances.

Parameters
pComponentPointer to the other collider component.
Returns
True if a collision is detected, false otherwise.

Implements ColliderComponent.

◆ Collision() [2/2]

bool RectangleColliderComponent::Collision ( const Rectangle & otherRectangle)

Checks for collision with another rectangle in world space.

Parameters
otherRectangleThe other rectangle to check against.
Returns
True if a collision is detected, false otherwise.

◆ DebugRender()

void RectangleColliderComponent::DebugRender ( IRenderer * pRenderer)
overridevirtual

Renders the rectangle as a line in the world for debugging purposes.

Parameters
pRendererThe renderer used to draw the debug rectangle.

Implements DebugRenderInterface.

◆ GetWorldRectangle()

Rectangle RectangleColliderComponent::GetWorldRectangle ( ) const

Gets the world-space rectangle based on the owner's position. Transforms the local-space rectangle to its global position.

Returns
A Rectangle in world-space coordinates.

Member Data Documentation

◆ mRectangle

Rectangle RectangleColliderComponent::mRectangle { Vector2(-16,-16),Vector2(32,32) }

Checks Local-space rectangle defining the collider shape.


The documentation for this class was generated from the following files: