12#ifndef FOOLSENGINE_SPATIALQUERYGEOMETRY_H
13#define FOOLSENGINE_SPATIALQUERYGEOMETRY_H
48 return std::isfinite(number);
58 inline bool isFinite(
const glm::vec3& vector) {
110 template <
typename TDerived>
131 std::array<glm::vec3, 8> cornerSigns {};
132 for(
BoxCorner corner {0}; corner < 8; ++corner) {
133 cornerSigns[corner].x = corner&BoxCornerSpecifier::RIGHT? 1.f: -1.f;
134 cornerSigns[corner].y = corner&BoxCornerSpecifier::TOP? 1.f: -1.f;
135 cornerSigns[corner].z = corner&BoxCornerSpecifier::FRONT? 1.f: -1.f;
148 glm::vec3 absoluteCornerOffset { .5f * boxDimensions };
149 std::array<glm::vec3, 8> cornerArray { .5f * boxDimensions };
150 for(uint8_t corner{0}; corner < 8; ++corner) {
151 cornerArray[corner] = cornerSignsArray[corner] * absoluteCornerOffset;
164 template <
typename TDerived>
171 template <
typename TDerived>
180 return TDerived::getVolumeRelativeBoxCorners();
391 float mLength { std::numeric_limits<float>::infinity() };
uint8_t BoxCorner
Type used to represent the name of the corner of a box.
Definition spatial_query_basic_types.hpp:25
bool isPositive(float number)
Tests whether a number is positive.
Definition spatial_query_basic_types.hpp:70
BoxCornerSpecifier
Enum values correspond to bits on a BoxCorner which help specify which side of the box on each axis i...
Definition spatial_query_basic_types.hpp:32
bool isNonNegative(float number)
Tests whether a number is non-negative.
Definition spatial_query_basic_types.hpp:94
bool isFinite(float number)
Tests whether a given number is finite.
Definition spatial_query_basic_types.hpp:47
Namespace containing all class definitions and functions related to the ToyMaker engine.
Definition camera_system.hpp:20
A set of numbers representing a single circle situated somewhere in the world.
Definition spatial_query_basic_types.hpp:330
glm::vec3 mCenter
The real-world coordinates of the center of the circle.
Definition spatial_query_basic_types.hpp:341
glm::vec3 mNormal
A vector normal to the surface of the circle, in whose direction it may be assumed the circle is faci...
Definition spatial_query_basic_types.hpp:347
bool isSensible() const
Tests whether the circle described by these parameters is valid (as opposed to invalid,...
Definition spatial_query_basic_types.hpp:355
float mRadius
The radius of the circle.
Definition spatial_query_basic_types.hpp:335
A set of 3 points located in the world forming a (hopefully sensible) triangle.
Definition spatial_query_basic_types.hpp:297
std::array< glm::vec3, 3 > mPoints
The points of the triangle, where each point has 3 components.
Definition spatial_query_basic_types.hpp:302
bool isSensible() const
Tests whether the points describing the triangle are sensible (as opposed to invalid,...
Definition spatial_query_basic_types.hpp:310
A set of numbers describing a plane situated somewhere in the world.
Definition spatial_query_basic_types.hpp:417
glm::vec3 mNormal
A vector normal to the plane.
Definition spatial_query_basic_types.hpp:428
glm::vec3 mPointOnPlane
A known point on the plane.
Definition spatial_query_basic_types.hpp:422
bool isSensible() const
Tests whether the plane described is sensible (as opposed to invalid, infinite, or degenerate).
Definition spatial_query_basic_types.hpp:436
A set of numbers describing a ray with its source at some finite point in the world,...
Definition spatial_query_basic_types.hpp:374
float mLength
The length of the ray, infinite by default.
Definition spatial_query_basic_types.hpp:391
glm::vec3 mStart
A point representing the starting point of the ray.
Definition spatial_query_basic_types.hpp:379
glm::vec3 mDirection
The direction the ray is pointing in.
Definition spatial_query_basic_types.hpp:385
bool isSensible() const
Tests whether the ray is sensible (as opposed to invalid or degenerate).
Definition spatial_query_basic_types.hpp:399
The base class of all spatial query volumes.
Definition spatial_query_basic_types.hpp:121
static std::array< glm::vec3, 8 > ComputeBoxCorners(const glm::vec3 &boxDimensions)
Computes the model relative corners of a box, given the dimensions of the box.
Definition spatial_query_basic_types.hpp:146
static constexpr std::array< glm::vec3, 8 > GetCornerSignsArray()
Returns an array populated with axis-wise sign multipliers, where the positions on the array correspo...
Definition spatial_query_basic_types.hpp:130
std::array< glm::vec3, 8 > getVolumeRelativeBoxCorners() const
Poor man's vtable which doesn't break Volume's ability to be aggregate initialized.
Definition spatial_query_basic_types.hpp:165
Holds the parameters describing the spatial query volume of a simple three-dimensionsal box.
Definition spatial_query_basic_types.hpp:189
bool isSensible() const
Tests whether the values representing the box are valid (as opposed to invalid, infinite,...
Definition spatial_query_basic_types.hpp:211
glm::vec3 mDimensions
The dimensions of the box, its width, height, and depth.
Definition spatial_query_basic_types.hpp:194
std::array< glm::vec3, 8 > getVolumeRelativeBoxCorners() const
Returns an array of coordinates corresponding to the corners of the box.
Definition spatial_query_basic_types.hpp:201
Holds the parameters describing the spatial query volume of a simple three-dimensionsal capsule (or p...
Definition spatial_query_basic_types.hpp:221
float mRadius
The radius of the hemispheres on either end of the capsule.
Definition spatial_query_basic_types.hpp:232
std::array< glm::vec3, 8 > getVolumeRelativeBoxCorners() const
Gets an array containing the coordinates of the corners of the volume aligned box just containing the...
Definition spatial_query_basic_types.hpp:239
float mHeight
The height of the cylindrical section of the capsule.
Definition spatial_query_basic_types.hpp:226
bool isSensible() const
Tests whether the values representing the capsule make sense (as opposed to being invalid,...
Definition spatial_query_basic_types.hpp:252
Holds parameters describing a spherical spatial query volume.
Definition spatial_query_basic_types.hpp:265
float mRadius
The radius of the sphere.
Definition spatial_query_basic_types.hpp:270
std::array< glm::vec3, 8 > getVolumeRelativeBoxCorners() const
Gets an array of coordinates of corners of a box just encapsulating the sphere.
Definition spatial_query_basic_types.hpp:277
bool isSensible() const
Tests whether this volumes parameters are sensible (as opposed to invalid, infinite,...
Definition spatial_query_basic_types.hpp:287
Definition spatial_query_basic_types.hpp:172
std::array< glm::vec3, 8 > getVolumeRelativeBoxCorners() const
Poor man's vtable cont'd.
Definition spatial_query_basic_types.hpp:179