35 template<
typename T>
struct TAABox;
36 template<
typename T>
struct TLineSegment;
37 template<
typename T>
struct TCapsule;
38 template<
typename T>
struct TPlane;
39 template<
typename T>
struct TRect;
40 template<
typename T>
struct TSphere;
41 template<
typename T>
struct TConvexVolume;
42 template<
typename T>
struct TRayIntersection;
43 template<
typename T>
struct TRay;
86 explicit
TAABox(const
TSphere<T>& sphere) : minimum(sphere.center - sphere.radius), maximum(sphere.center + sphere.radius) {}
107 [[nodiscard]] Array<
TVector3<T>, 8> getCorners() const noexcept;
140 bool intersects(const
TPlane<T>& p) const;
150 bool intersects(const
TRay<T>& ray, T& d1, T& d2) const;
159 bool contains(const
TVector3<T>& v, T extra) const;
164 bool contains(const
TAABox& other) const;
191 friend
bool operator==(const
TAABox& lhs, const
TAABox& rhs) {
return lhs.minimum == rhs.minimum && lhs.maximum == rhs.maximum; }
270 template<typename I = UInt32>
271 static inline constexpr I CUBE_INDICES[] = {
273 NearLeftBottom, NearLeftTop, NearRightTop, NearLeftBottom, NearRightTop, NearRightBottom,
276 FarRightBottom, FarRightTop, FarLeftTop, FarRightBottom, FarLeftTop, FarLeftBottom,
279 FarLeftBottom, FarLeftTop, NearLeftTop, FarLeftBottom, NearLeftTop, NearLeftBottom,
282 NearRightBottom, NearRightTop, FarRightTop, NearRightBottom, FarRightTop, FarRightBottom,
285 FarLeftTop, FarRightTop, NearRightTop, FarLeftTop, NearRightTop, NearLeftTop,
288 NearLeftBottom, NearRightBottom, FarRightBottom, NearLeftBottom, FarRightBottom, FarLeftBottom};
332 T getLength()
const {
return distance(start, end); }
336 TVector3<
T> getCenter()
const {
return start + (end - start) *
T(0.5); }
368 T getHeight()
const {
return segment.getLength(); }
372 TVector3<
T> getCenter()
const {
return segment.getCenter(); }
392 Positive = (1U << 0
U),
393 Negative = (1U << 1U),
394 Both = Positive | Negative
486 T mExtentHorz =
T(0.0);
487 T mExtentVert =
T(0.0);
493 : mCenter(center), mAxisHorz(axes[0]), mAxisVert(axes[1]), mExtentHorz(extents[0]), mExtentVert(extents[1]) {}
527 friend struct std::hash<
TRect>;
768 template<
typename T>
struct TRay {
924template<
typename T>
struct std::hash<CeresEngine::TAABox<T>> {
929template<
typename T>
struct std::hash<
CeresEngine::TLineSegment<T>> {
931 size_t operator()(
const Type& obj)
const {
return CeresEngine::hash(obj.start, obj.end); }
934template<
typename T>
struct std::hash<
CeresEngine::TCapsule<T>> {
936 size_t operator()(
const Type& obj)
const {
return CeresEngine::hash(obj.segment, obj.radius); }
939template<
typename T>
struct std::hash<
CeresEngine::TConvexVolume<T>> {
941 size_t operator()(
const Type& obj)
const {
return CeresEngine::hash(obj.planes); }
944template<
typename T>
struct std::hash<
CeresEngine::TPlane<T>> {
946 size_t operator()(
const Type& obj)
const {
return CeresEngine::hash(obj.normal, obj.distance); }
949template<
typename T>
struct std::hash<
CeresEngine::TRect<T>> {
951 size_t operator()(
const Type& obj)
const {
return CeresEngine::hash(obj.mCenter, obj.mAxisHorz, obj.mAxisVert, obj.mExtentHorz, obj.mExtentVert); }
954template<
typename T>
struct std::hash<
CeresEngine::TSphere<T>> {
956 size_t operator()(
const Type& obj)
const {
return CeresEngine::hash(obj.center, obj.radius); }
960 using Type = CeresEngine::FrustumPlane;
964template<
typename T>
struct std::hash<
CeresEngine::TRayIntersection<T>> {
966 size_t operator()(
const Type& obj)
const {
return CeresEngine::hash(obj.distance, obj.intersects); }
969template<
typename T>
struct std::hash<
CeresEngine::TRay<T>> {
971 size_t operator()(
const Type& obj)
const {
return CeresEngine::hash(obj.origin, obj.direction); }
#define CE_SCRIPT_EXPORT(...)
The CE_SCRIPT_EXPORT macro marks a class or method as exportable and available in scripting environme...
Definition Macros.hpp:247
Definition Application.hpp:19
Box box(T &value)
Creates a new Box object by wraping the value as a reference type.
Definition Box.hpp:672
constexpr Byte operator<<(const Byte arg, const _IntType shift) noexcept
Definition DataTypes.hpp:44
auto move(Vector3 position)
Moves a entity to the given position.
Definition Helpers.hpp:22
sfl::small_vector< T, N, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > SmallVector
SmallVector is a sequence container similar to Vector.
Definition SmallVector.hpp:31
std::array< T, N > Array
Array is a container that encapsulates fixed size arrays.
Definition Array.hpp:17
std::uint32_t UInt32
Definition DataTypes.hpp:23
auto transform(Container &container, Transform &&transform)
Returns an iterable object that iterates over the values of the container and applies transform to ev...
Definition Iterator.hpp:436
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
TVector3< double > Vector3
A three dimensional vector with (x, y, z) coordinates.
Definition Vector.hpp:84
TMatrix< 4, 4, T > TMatrix4
A 4x4 type that uses a internal representation of type T
Definition Matrix.hpp:54
TVector< 4, T > TVector4
A four dimensional vector type that uses a internal representation of type T
Definition Vector.hpp:115
TVector3< T > normal(const TVector3< T > &p1, const TVector3< T > &p2, const TVector3< T > &p3)
Definition Math.hpp:704
TVector< 3, T > TVector3
A three dimensional vector type that uses a internal representation of type T
Definition Vector.hpp:80
FrustumPlane
Clip planes that form the camera frustum (visible area).
Definition Geometry.hpp:661
Axis aligned box represented by minimum and maximum point.
Definition Geometry.hpp:46
friend bool operator!=(const TAABox &lhs, const TAABox &rhs)
Definition Geometry.hpp:193
friend TAABox & operator+=(TAABox &lhs, const TAABox &rhs)
Merges the two boxes, creating a new bounding box that encapsulates them both.
Definition Geometry.hpp:211
friend TAABox operator+(const TAABox &lhs, const TVector3< T > &rhs)
Expands the bounding box so it includes the provided point.
Definition Geometry.hpp:220
Corner
Different corners of a box.
Definition Geometry.hpp:68
TAABox merge(const TAABox &rhs)
Merges the two boxes, creating a new bounding box that encapsulates them both.
friend TAABox & operator+=(TAABox &lhs, const TVector3< T > &rhs)
Expands the bounding box so it includes the provided point.
Definition Geometry.hpp:230
void transform(const TMatrix4< T > &matrix)
Transforms the bounding box by the given matrix.
friend TAABox operator*(const TMatrix4< T > &lhs, TAABox rhs)
Transforms the bounding box by the given matrix.
Definition Geometry.hpp:241
friend TAABox operator+(const TAABox &lhs, const TAABox &rhs)
Merges the two boxes, creating a new bounding box that encapsulates them both.
Definition Geometry.hpp:200
friend TAABox operator*(const TTransform< T > &lhs, TAABox rhs)
Transforms the bounding box by the given transform.
Definition Geometry.hpp:252
void transform(const TTransform< T > &aTransform)
Transforms the bounding box by the given matrix.
Definition Geometry.hpp:128
Represents a capsule with a line segment and a radius.
Definition Geometry.hpp:343
Represents a convex volume defined by planes representing the volume border.
Definition Geometry.hpp:672
friend TConvexVolume operator*(const TTransform< T > &lhs, TConvexVolume rhs)
Transforms the convex volume by the given transform.
Definition Geometry.hpp:732
void transform(const TTransform< T > &aTransform)
Transforms the convex volume by the given matrix.
Definition Geometry.hpp:693
void transform(const TMatrix4< T > &matrix)
Transforms the convex volume by the given matrix.
Represents a line segment in three dimensional space defined by a start and an end point.
Definition Geometry.hpp:307
Pair< Array< TVector3< T >, 2 >, T > getNearestPoint(const TRay< T > &ray) const
Find the nearest point on the line segment and the provided ray.
A plane represented by a normal and a distance.
Definition Geometry.hpp:379
TVector3< T > normal
Definition Geometry.hpp:381
Side getSide(const TSphere< T > &sphere) const
Returns the side where the sphere is.
bool operator!=(const TPlane &rhs) const
Definition Geometry.hpp:470
Side
The "positive side" of the plane is the half space to which the plane normal points.
Definition Geometry.hpp:390
void transform(const TTransform< T > &aTransform)
Transforms the plane by the given matrix.
Definition Geometry.hpp:426
Side getSide(const TAABox< T > &box) const
Returns the side where the alignedBox is.
T distance
Definition Geometry.hpp:384
Side getSide(const TVector3< T > &point, T epsilon=0.0) const
Returns the side of the plane where the point is located on.
A ray in 3D space represented with an origin and direction.
Definition Geometry.hpp:768
void transform(const TTransform< T > &aTransform)
Transforms the ray by the given matrix.
Definition Geometry.hpp:799
friend TRay< T > operator*(const TTransform< T > &lhs, TRay< T > rhs)
Transforms the ray by the given transform.
Definition Geometry.hpp:851
void transform(const TMatrix4< T > &matrix)
Transforms the ray by the given matrix.
friend TRay< T > operator*(const TMatrix4< T > &lhs, TRay< T > rhs)
Transforms the ray by the given matrix.
Definition Geometry.hpp:842
A structure that describes an intersection with a ray.
Definition Geometry.hpp:742
Represents a rectangle in three dimensional space.
Definition Geometry.hpp:480
const T & getExtentHorz() const
Gets the extent of the rectangle along its horizontal axis.
Definition Geometry.hpp:522
const TVector3< T > & getAxisHorz() const
Returns the rectangle's horizontal axis.
Definition Geometry.hpp:516
const T & getExtentVertical() const
Gets the extent of the rectangle along its vertical axis.
Definition Geometry.hpp:525
const TVector3< T > & getAxisVert() const
Returns the rectangle's vertical axis.
Definition Geometry.hpp:519
Pair< TVector3< T >, T > getNearestPoint(const TVector3< T > &point) const
Find the nearest point on the rectangle to the provided point.
Pair< Array< TVector3< T >, 2 >, T > getNearestPoint(const TRay< T > &ray) const
Find the nearest points of the provided ray and the rectangle.
TRect(const TVector3< T > ¢er, const Array< TVector3< T >, 2 > &axes, const Array< T, 2 > &extents)
Definition Geometry.hpp:492
const TVector3< T > & getCenter() const
Gets the origin of the rectangle.
Definition Geometry.hpp:513
TRayIntersection< T > intersects(const TRay< T > &ray) const
Ray/rectangle intersection.
A sphere represented by a center point and a radius.
Definition Geometry.hpp:534
void merge(const TSphere &rhs)
Merges the two spheres, creating a new sphere that encapsulates them both.
friend TSphere & operator+=(TSphere &lhs, const TVector3< T > &rhs)
Expands the sphere so it includes the provided point.
Definition Geometry.hpp:629
friend TSphere operator*(const TTransform< T > &lhs, TSphere rhs)
Transforms the sphere by the given matrix.
Definition Geometry.hpp:641
friend TSphere & operator+=(TSphere &lhs, const TSphere &rhs)
Merges the two spheres, creating a new sphere that encapsulates them both.
Definition Geometry.hpp:617
void transform(const TMatrix4< T > &matrix)
Transforms the sphere by the given matrix.
void transform(const TTransform< T > &aTransform)
Transforms the sphere by the given matrix.
Definition Geometry.hpp:569
friend TSphere operator+(TSphere lhs, const TVector3< T > &rhs)
Expands the sphere so it includes the provided point.
Definition Geometry.hpp:623
friend TSphere operator*(const TMatrix4< T > &lhs, TSphere rhs)
Transforms the sphere by the given matrix.
Definition Geometry.hpp:635