Commit, fix boxcollider

This commit is contained in:
2026-04-15 07:52:14 +02:00
parent dc55af5323
commit ab3baf5cbb
4 changed files with 61 additions and 23 deletions

View File

@@ -2,6 +2,7 @@
#include <object/components/component.hpp>
#include <state/gamestate.hpp>
#include <unordered_set>
namespace Game::Object::Components {
struct BoxColliderBounds {
@@ -21,10 +22,10 @@ namespace Game::Object::Components {
void update(float deltaTime, Object::Entity* thisEntity) override;
BoxColliderBounds getBounds() const { return mBounds; }
bool isColliding() const { return mIsColliding; }
bool isColliding() const { return !mCollidingWith.empty(); }
private:
BoxColliderBounds mBounds;
bool mIsColliding = false; // Whether this collider is currently colliding with another collider; used to determine whether to call onCollisionEnter vs onCollisionStay, and to call onCollisionExit when collisions end
BoxColliderBounds mBounds{0.f, 0.f, 0.f, 0.f};
std::unordered_set<Object::Entity*> mCollidingWith; // Track collisions per-entity so enter/stay/exit callbacks remain correct with multiple colliders
};
}