Physics Simulation & Visualization Tool 0.1
A C++ physics simulation engine with real-time 3D visualization
Loading...
Searching...
No Matches
BoxCollider.h
Go to the documentation of this file.
1#pragma once
2#include "ICollider.h"
3#include <glm/gtx/quaternion.hpp>
4
5namespace Physics::Bounding {
6 class BoxCollider : public ICollider {
7 public:
8 BoxCollider() = default;
9 BoxCollider(const glm::vec3& center, const glm::vec3& halfExtents, const glm::quat& rotation);
10
11 std::unique_ptr<ICollider> getTransformed(const glm::mat4 &modelMatrix) const override;
12
13 bool contains(const glm::vec3 &p) const override;
14
15 ContactInfo closestPoint(const glm::vec3 &p) const override;
16
17 std::optional<float> intersectRay(const Math::Ray& ray) const override;
18
19 glm::vec3 getAABBMin() const override;
20 glm::vec3 getAABBMax() const override;
21 private:
22 glm::vec3 center{};
23 glm::vec3 halfExtents{};
24 glm::quat rotation{1, 0, 0, 0};
25 };
26}
Abstract interface for collision detection shapes.
std::optional< float > intersectRay(const Math::Ray &ray) const override
Tests ray-collider intersection.
std::unique_ptr< ICollider > getTransformed(const glm::mat4 &modelMatrix) const override
Creates a transformed copy of this collider in world space.
glm::vec3 getAABBMax() const override
bool contains(const glm::vec3 &p) const override
Tests if a point is inside the collider volume.
ContactInfo closestPoint(const glm::vec3 &p) const override
Finds the closest point on the collider surface to a given point.
glm::vec3 getAABBMin() const override
Gets the minimum, maximum corner of the axis-aligned bounding box (AABB) that contains this collider.
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