geom namespace
Geometry 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 Frustum
- Represents a camera frustum.
- struct Intersection
- Contains info regarding an intersection between shapes.
- struct Plane
- Represents a plane. Assumes equation: normal.x + normal.y + normal.z + d = 0.
- struct PolygonalFeature
- Represents a polygonal feature. Used internally for manifold computation.
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 intersects(const Frustum& frustum,
const AABB& aabb) -> CUBOS_
CORE_ API bool - Computes the intersection between a frustum and an AABB.
-
auto intersects(const Frustum& frustum,
const Box& box,
const glm::mat4& localToWorld) -> CUBOS_
CORE_ API bool - Computes the intersection between a frustum and a box.
-
auto intersects(const Frustum& frustum,
const Capsule& capsule,
const glm::mat4& localToWorld) -> CUBOS_
CORE_ API bool - Computes the intersection between a frustum and a capsule.
-
auto sutherlandHodgmanClipping(PolygonalFeature& polygon,
int numClipPlanes,
const cubos::
core:: geom:: Plane* clipPlanes, bool removeNotClipToPlane) -> CUBOS_ CORE_ API void - 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 pointDistanceToPlane(const glm::vec3& point,
const cubos::
core:: geom:: Plane& plane) -> CUBOS_ CORE_ API float - Computes the signed distance from thene plane to a point.
-
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, PolygonalFeature& outPolygon, std::vector<cubos:: core:: geom:: Plane>& outAdjacentPlanes, std::vector<uint32_t> outAdjacentPlanesIds, 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.
-
auto getCameraFrustumCorners(const glm::mat4& view,
const glm::mat4& proj,
float zNear,
float zFar,
std::vector<glm::vec4>& corners) -> CUBOS_
CORE_ API void - Gets a camera's frustum corners in world space.
-
auto getCubeViewMatrices(const glm::mat4& inverseView,
std::vector<glm::mat4>& cubeViewMatrices) -> CUBOS_
CORE_ API void - Gets view matrices for rendering a cubemap.
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 bool cubos:: core:: geom:: intersects(const Frustum& frustum,
const AABB& aabb)
#include <core/geom/intersections.hpp>
Computes the intersection between a frustum and an AABB.
| Parameters | |
|---|---|
| frustum | Frustum. |
| aabb | AABB of the entity. |
| Returns | True if there's intersection, false otherwise. |
CUBOS_ CORE_ API bool cubos:: core:: geom:: intersects(const Frustum& frustum,
const Box& box,
const glm::mat4& localToWorld)
#include <core/geom/intersections.hpp>
Computes the intersection between a frustum and a box.
| Parameters | |
|---|---|
| frustum | Frustum. |
| box | Box shape of the entity. |
| localToWorld | Local to world matrix of the entity. |
| Returns | True if there's intersection, false otherwise. |
CUBOS_ CORE_ API bool cubos:: core:: geom:: intersects(const Frustum& frustum,
const Capsule& capsule,
const glm::mat4& localToWorld)
#include <core/geom/intersections.hpp>
Computes the intersection between a frustum and a capsule.
| Parameters | |
|---|---|
| frustum | Frustum. |
| capsule | Capsule shape of the entity. |
| localToWorld | Local to world matrix of the entity. |
| Returns | True if there's intersection, false otherwise. |
CUBOS_ CORE_ API void cubos:: core:: geom:: sutherlandHodgmanClipping(PolygonalFeature& polygon,
int numClipPlanes,
const cubos:: core:: geom:: Plane* clipPlanes,
bool removeNotClipToPlane)
#include <core/geom/intersections.hpp>
Performs the Sutherland-Hodgman Clipping algorithm.
| Parameters | |
|---|---|
| polygon | 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. |
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 float cubos:: core:: geom:: pointDistanceToPlane(const glm::vec3& point,
const cubos:: core:: geom:: Plane& plane)
#include <core/geom/utils.hpp>
Computes the signed distance from thene plane to a point.
| Parameters | |
|---|---|
| point | The position of the point in world coordinates. |
| plane | The plane to use. |
| Returns | The signed distance. |
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,
PolygonalFeature& outPolygon,
std::vector<cubos:: core:: geom:: Plane>& outAdjacentPlanes,
std::vector<uint32_t> outAdjacentPlanesIds,
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. |
| outPolygon | The polygon of the resulting face. |
| outAdjacentPlanes | The resulting adjacent planes (4). |
| outAdjacentPlanesIds | The resulting adjacent planes ids (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. |
CUBOS_ CORE_ API void cubos:: core:: geom:: getCameraFrustumCorners(const glm::mat4& view,
const glm::mat4& proj,
float zNear,
float zFar,
std::vector<glm::vec4>& corners)
#include <core/geom/utils.hpp>
Gets a camera's frustum corners in world space.
| Parameters | |
|---|---|
| view | Matrix that transforms world space to the camera's view space. |
| proj | Matrix that transforms the camera's view space to its clip space. |
| zNear | Near clipping plane. |
| zFar | Far clipping plane. |
| corners | Output vector where the corners will be stored. |
CUBOS_ CORE_ API void cubos:: core:: geom:: getCubeViewMatrices(const glm::mat4& inverseView,
std::vector<glm::mat4>& cubeViewMatrices)
#include <core/geom/utils.hpp>
Gets view matrices for rendering a cubemap.
| Parameters | |
|---|---|
| inverseView | Matrix that transforms the camera's view space to world space. |
| cubeViewMatrices | Output vector where the view matrices will be stored. |