14 static constexpr int AXIS_X_MASK = 1;
15 static constexpr int AXIS_Y_MASK = 2;
16 static constexpr int AXIS_Z_MASK = 4;
33 unsigned int axis : 3 = 0b000;
44 AABBCollider(std::shared_ptr<AABB> aabb,
float stepHeight = 0.0f);
47 void setWorld(std::shared_ptr<World> world);
50 void setAABB(std::shared_ptr<AABB> aabb);
62 static constexpr float s_epsGap = std::numeric_limits<float>::epsilon() * 64.0f;
64 std::shared_ptr<World> m_world =
nullptr;
65 std::shared_ptr<AABB> m_aabb;
69 std::vector<AABB> m_aabbCache;
70 glm::ivec3 m_lastPosition;
72 glm::vec3 m_cacheDirection;
74 float m_stepUpCooldown = 0.0f;
83 void updateAABBCache(
const glm::vec3& velocity,
const glm::vec3& position);
85 float swept1D(
int axis,
float velocity,
const AABB& other);
Definition AABBCollider.h:42
CollisionInfo collide(glm::vec3 &moveStep, const glm::vec3 &position, float dt)
Checks if the AABB collides with any blocks in the world.
Definition AABBCollider.cpp:42
void setWorld(std::shared_ptr< World > world)
Sets the world for this collider.
Definition AABBCollider.cpp:34
void setAABB(std::shared_ptr< AABB > aabb)
Sets the AABB that will be checked for collisions against the world.
Definition AABBCollider.cpp:38
static constexpr glm::vec3 s_checkBox
The box around the AABB that will be generated, thus checked for collisions against the world.
Definition AABBCollider.h:61
float tryStepUp(const glm::vec3 &horizontalMove, const SweptResult &bestRes)
Attempts to step up when hitting a horizontal obstacle.
Definition AABBCollider.cpp:292
Definition AABBCollider.h:77
Definition AABBCollider.h:13
std::array< std::vector< glm::vec3 >, 3 > hitPositions
The positions of the AABBs that will be hit after the move step is applied. (for each axis)
Definition AABBCollider.h:28
float stepHeight
The height that was stepped up (for stairs/slabs). 0 if no step.
Definition AABBCollider.h:39
glm::vec3 correction
The position correction that was applied during the collision resolution, so the AABB stops touching ...
Definition AABBCollider.h:19
glm::vec3 t
The time till the collision happens for all axis with the provided move step.
Definition AABBCollider.h:25
bool grounded
If the AABB is grounded, meaning it is touching the ground.
Definition AABBCollider.h:36