Physics Simulation & Visualization Tool 0.1
A C++ physics simulation engine with real-time 3D visualization
Loading...
Searching...
No Matches
AABB.h
Go to the documentation of this file.
1#pragma once
2#include <glm/glm.hpp>
3#include "ICollider.h"
4
6 class AABB : public ICollider{
7 public:
8 AABB() = default;
9
10 AABB(const glm::vec3& center, const glm::vec3& halfExtents);
11 std::unique_ptr<ICollider> getTransformed(const glm::mat4 &modelMatrix) const override;
12
13 bool intersectsAABB(const AABB& other) const;
14 std::optional<float> intersectRay(const Math::Ray& ray) const override;
15 bool contains(const glm::vec3& p) const override;
16 ContactInfo closestPoint(const glm::vec3& p) const override;
17
18 void expand(const glm::vec3& point);
19 void expand(const AABB& other);
20
21 glm::vec3 getAABBMin() const override { return minCorner; }
22 glm::vec3 getAABBMax() const override { return maxCorner; }
23 glm::vec3 getCenter() const { return center; }
24
25 private:
26 glm::vec3 minCorner;
27 glm::vec3 maxCorner;
28 glm::vec3 center;
29 glm::vec3 halfExtents;
30 };
31}
Abstract interface for collision detection shapes.
std::optional< float > intersectRay(const Math::Ray &ray) const override
Tests ray-collider intersection.
Definition AABB.cpp:34
bool contains(const glm::vec3 &p) const override
Tests if a point is inside the collider volume.
Definition AABB.cpp:50
bool intersectsAABB(const AABB &other) const
Definition AABB.cpp:27
std::unique_ptr< ICollider > getTransformed(const glm::mat4 &modelMatrix) const override
Creates a transformed copy of this collider in world space.
Definition AABB.cpp:11
void expand(const glm::vec3 &point)
Definition AABB.cpp:61
glm::vec3 getAABBMin() const override
Gets the minimum, maximum corner of the axis-aligned bounding box (AABB) that contains this collider.
Definition AABB.h:21
glm::vec3 getCenter() const
Definition AABB.h:23
ContactInfo closestPoint(const glm::vec3 &p) const override
Finds the closest point on the collider surface to a given point.
Definition AABB.cpp:56
glm::vec3 getAABBMax() const override
Definition AABB.h:22
Abstract base class for collision volumes in the physics engine.
Definition ICollider.h:64
Represents a ray in 3D space.
Definition Ray.h:11
Bounding volume and collision shape definitions.
Definition AABB.h:5
Contact point information from collision queries.
Definition ICollider.h:35