namespace
geomGeometry module.
Classes
- struct AABB
- Represents an axis-aligned bounding box.
- struct Box
- Represents a box shape.
- struct Capsule
- Represents a capsule or sphere shape.
- struct Intersection
- Contains info regarding an intersection between shapes.
- struct Plane
- Represents a plane. Assumes equation: normal.x + normal.y + normal.z + d = 0.
Functions
-
auto intersects(const Box& box1,
const glm::mat4& localToWorld1,
const Box& box2,
const glm::mat4& localToWorld2,
Intersection& intersect) -> CUBOS_
CORE_ API bool - Computes the intersection between two box shapes.
-
auto sutherlandHodgmanClipping(const std::vector<glm::vec3>& inputPolygon,
int numClipPlanes,
const cubos::
core:: geom:: Plane* clipPlanes, bool removeNotClipToPlane) -> CUBOS_ CORE_ API std::vector<glm::vec3> - Performs the Sutherland-Hodgman Clipping algorithm.
-
auto planeEdgeIntersection(const cubos::
core:: geom:: Plane& plane, const glm::vec3& start, const glm::vec3& end, glm::vec3& outPoint) -> CUBOS_ CORE_ API bool - Compute the intersection between a plane and an edge.
-
auto pointInPlane(const glm::vec3& point,
const cubos::
core:: geom:: Plane& plane) -> CUBOS_ CORE_ API bool - Computes if a point is in the area limited by the plane.
-
auto getMaxVertexInAxis(int numVertices,
const glm::vec3 vertices[],
const glm::vec3& localAxis) -> CUBOS_
CORE_ API int - Computes the vertex furthest along the axis.
-
auto getIncidentReferencePolygon(const cubos::
core:: geom:: Box& shape, const glm::vec3& normal, std::vector<glm::vec3>& outPoints, glm::vec3& outNormal, std::vector<cubos:: core:: geom:: Plane>& outAdjacentPlanes, const glm::mat4& localToWorld, float scale) -> CUBOS_ CORE_ API void - Computes the candidate face of the polygon to be reference, as well as it's normal and adjacent planes.
-
auto getClosestPointEdge(const glm::vec3& point,
glm::vec3 start,
glm::vec3 end) -> CUBOS_
CORE_ API glm::vec3 - Computes the closest point on the line (edge) to point.
-
auto getClosestPointPolygon(const glm::vec3& point,
const std::vector<glm::vec3>& polygon) -> CUBOS_
CORE_ API glm::vec3 - Iterates through all edges in polygon and computes closest position on the edges of the polygon to point.
Function documentation
CUBOS_ CORE_ API bool cubos:: core:: geom:: intersects(const Box& box1,
const glm::mat4& localToWorld1,
const Box& box2,
const glm::mat4& localToWorld2,
Intersection& intersect)
#include <core/geom/intersections.hpp>
Computes the intersection between two box shapes.
Parameters | |
---|---|
box1 | Box shape of the first entity. |
localToWorld1 | Local to world matrix of the first entity. |
box2 | Box shape of the second entity. |
localToWorld2 | Local to world matrix of the second entity. |
intersect |
CUBOS_ CORE_ API std::vector<glm::vec3> cubos:: core:: geom:: sutherlandHodgmanClipping(const std::vector<glm::vec3>& inputPolygon,
int numClipPlanes,
const cubos:: core:: geom:: Plane* clipPlanes,
bool removeNotClipToPlane)
#include <core/geom/intersections.hpp>
Performs the Sutherland-Hodgman Clipping algorithm.
Parameters | |
---|---|
inputPolygon | The polygon to perform the clipping on. |
numClipPlanes | Number of cliping planes. |
clipPlanes | Clipping planes |
removeNotClipToPlane | Whether to remove the points if they're outside the plane. |
Returns | The polygon resulting from the clipping. |
CUBOS_ CORE_ API bool cubos:: core:: geom:: planeEdgeIntersection(const cubos:: core:: geom:: Plane& plane,
const glm::vec3& start,
const glm::vec3& end,
glm::vec3& outPoint)
#include <core/geom/intersections.hpp>
Compute the intersection between a plane and an edge.
Parameters | |
---|---|
plane | The plane. |
start | The start point of the edge. |
end | The end point of the edge. |
outPoint | The position of the intersection. |
Returns | True if there's intersection, false otherwise. |
CUBOS_ CORE_ API bool cubos:: core:: geom:: pointInPlane(const glm::vec3& point,
const cubos:: core:: geom:: Plane& plane)
#include <core/geom/utils.hpp>
Computes if a point is in the area limited by the plane.
Parameters | |
---|---|
point | The position of the point in world coordinates. |
plane | The plane to use. |
Returns | True is the point is on the plane or closer, false otherwise. |
CUBOS_ CORE_ API int cubos:: core:: geom:: getMaxVertexInAxis(int numVertices,
const glm::vec3 vertices[],
const glm::vec3& localAxis)
#include <core/geom/utils.hpp>
Computes the vertex furthest along the axis.
Parameters | |
---|---|
numVertices | |
vertices | Array of vertices. |
localAxis | The direction of the axis in local coordinates. |
Returns | The index of the vertex. |
CUBOS_ CORE_ API void cubos:: core:: geom:: getIncidentReferencePolygon(const cubos:: core:: geom:: Box& shape,
const glm::vec3& normal,
std::vector<glm::vec3>& outPoints,
glm::vec3& outNormal,
std::vector<cubos:: core:: geom:: Plane>& outAdjacentPlanes,
const glm::mat4& localToWorld,
float scale)
#include <core/geom/utils.hpp>
Computes the candidate face of the polygon to be reference, as well as it's normal and adjacent planes.
Parameters | |
---|---|
shape | Collider shape. |
normal | The reference normal in world coordinates. |
outPoints | The points of the resulting face. |
outNormal | The resulting normal. |
outAdjacentPlanes | The resulting adjacent planes (4). |
localToWorld | The localToWorld matrix of the body. |
scale | The scale of the body. |
TODO: since this is a box shape, we know how many points and adjacent planes exist beforehand
CUBOS_ CORE_ API glm::vec3 cubos:: core:: geom:: getClosestPointEdge(const glm::vec3& point,
glm::vec3 start,
glm::vec3 end)
#include <core/geom/utils.hpp>
Computes the closest point on the line (edge) to point.
Parameters | |
---|---|
point | Position of the point. |
start | Starting position of the edge. |
end | End position of the edge. |
Returns | Closest position on edge to the point. |
CUBOS_ CORE_ API glm::vec3 cubos:: core:: geom:: getClosestPointPolygon(const glm::vec3& point,
const std::vector<glm::vec3>& polygon)
#include <core/geom/utils.hpp>
Iterates through all edges in polygon and computes closest position on the edges of the polygon to point.
Parameters | |
---|---|
point | Position of the point. |
polygon | List of points that compose the shape (edges are defined as a line-loop list of vertices). |
Returns | Closest point that resides on any of the given edges of the polygon. |