Physics Simulation & Visualization Tool 0.1
A C++ physics simulation engine with real-time 3D visualization
Loading...
Searching...
No Matches
ICollider.h
Go to the documentation of this file.
1
7#pragma once
8#define GLM_ENABLE_EXPERIMENTAL
9#include <glm/glm.hpp>
10#include <memory>
11#include <optional>
12#include "math/Ray.h"
13
28namespace Physics::Bounding {
35 struct ContactInfo {
36 glm::vec3 point;
37 glm::vec3 normal;
39 };
40
64 class ICollider {
65 public:
69 virtual ~ICollider() = default;
70
81 virtual bool contains(const glm::vec3& p) const = 0;
82
99 virtual ContactInfo closestPoint(const glm::vec3& p) const = 0;
100
121 virtual std::unique_ptr<ICollider> getTransformed(const glm::mat4& modelMatrix) const = 0;
122
133 virtual std::optional<float> intersectRay(const Math::Ray& ray) const = 0;
134
135
144 virtual glm::vec3 getAABBMin() const { return glm::vec3(0.0f); }
145 virtual glm::vec3 getAABBMax() const { return glm::vec3(0.0f); }
146 };
147}
Abstract base class for collision volumes in the physics engine.
Definition ICollider.h:64
virtual ~ICollider()=default
Virtual destructor for proper cleanup of derived classes.
virtual std::unique_ptr< ICollider > getTransformed(const glm::mat4 &modelMatrix) const =0
Creates a transformed copy of this collider in world space.
virtual std::optional< float > intersectRay(const Math::Ray &ray) const =0
Tests ray-collider intersection.
virtual glm::vec3 getAABBMin() const
Gets the minimum, maximum corner of the axis-aligned bounding box (AABB) that contains this collider.
Definition ICollider.h:144
virtual bool contains(const glm::vec3 &p) const =0
Tests if a point is inside the collider volume.
virtual ContactInfo closestPoint(const glm::vec3 &p) const =0
Finds the closest point on the collider surface to a given point.
virtual glm::vec3 getAABBMax() const
Definition ICollider.h:145
Represents a ray in 3D space.
Definition Ray.h:11
Bounding volume and collision shape definitions.
Definition AABB.h:5
float penetration
Penetration depth (positive = overlapping, negative = separated)
Definition ICollider.h:38
glm::vec3 normal
Surface normal at contact point (points outward from surface)
Definition ICollider.h:37
glm::vec3 point
Contact point in world space (closest point on surface)
Definition ICollider.h:36
Contact point information from collision queries.
Definition ICollider.h:35