Add AABBvAABB interesection & add AABB scale

This commit is contained in:
Mishura
2024-05-07 14:55:09 -04:00
parent 35e1309d6f
commit 82cb3d7ee3
2 changed files with 68 additions and 2 deletions

View File

@@ -1,5 +1,7 @@
#pragma once
#include <optional>
#include <J3ML/LinearAlgebra.h>
#include <J3ML/Geometry/Common.h>
#include <J3ML/Geometry/Shape.h>
@@ -179,6 +181,8 @@ namespace J3ML::Geometry
void Translate(const Vector3& offset);
AABB Translated(const Vector3& offset) const;
void Scale(const Vector3& scale);
AABB Scaled(const Vector3& scale) const;
AABB TransformAABB(const Matrix3x3& transform);
AABB TransformAABB(const Matrix4x4& transform);
AABB TransformAABB(const Quaternion& transform);
@@ -230,6 +234,7 @@ namespace J3ML::Geometry
bool Intersects(const Polygon& polygon) const;
bool Intersects(const Frustum& frustum) const;
bool Intersects(const Polyhedron& polyhedron) const;
bool Intersects(const AABB& aabb) const;
/** For reference documentation on the Sphere-AABB intersection test, see Christer Ericson's Real-Time Collision Detection, p. 165. [groupSyntax]
@param sphere The first parameter of this function specifies the other object to test against.
@@ -270,9 +275,9 @@ namespace J3ML::Geometry
}
/// Finds the set intersection of this and the given AABB.
/** @return This function returns the AABB that is contained in both this and the given AABB.
/** @return This function returns an intersection that is contained in both this and the given AABB if there is one.
@todo Add Intersection(OBB/Polyhedron). */
AABB Intersection(const AABB& rhs) const;
std::optional<AABB> Intersection(const AABB& rhs) const;
/// Sets this AABB to enclose the given set of points.