Compare commits
1 Commits
cc7dffbb9a
...
17b4ec2cde
| Author | SHA1 | Date | |
|---|---|---|---|
| 17b4ec2cde |
@@ -53,6 +53,7 @@ public:
|
|||||||
void init();
|
void init();
|
||||||
static AABB Create(const Vector3& minPoint, const Vector3& maxPoint);
|
static AABB Create(const Vector3& minPoint, const Vector3& maxPoint);
|
||||||
static AABB Create(const Vector3& corner1, const Vector3& corner2, const Matrix4& modelMatrix);
|
static AABB Create(const Vector3& corner1, const Vector3& corner2, const Matrix4& modelMatrix);
|
||||||
|
static AABB Create(const AABB& modelSpaceExtents, const Matrix4& modelMatrix);
|
||||||
static AABB Create();
|
static AABB Create();
|
||||||
|
|
||||||
void scale(const Vector3& s);
|
void scale(const Vector3& s);
|
||||||
@@ -69,6 +70,7 @@ public:
|
|||||||
bool intersectsRay(const Vector3& v1, const Vector3& dir) const;
|
bool intersectsRay(const Vector3& v1, const Vector3& dir) const;
|
||||||
bool intersectsSphere(const Vector3& center, float radius) const;
|
bool intersectsSphere(const Vector3& center, float radius) const;
|
||||||
void encapsulate(const AABB& b);
|
void encapsulate(const AABB& b);
|
||||||
|
void encapsulate(const Vector3& v);
|
||||||
|
|
||||||
bool operator ==(const AABB& b) const;
|
bool operator ==(const AABB& b) const;
|
||||||
bool operator !=(const AABB& b) const;
|
bool operator !=(const AABB& b) const;
|
||||||
|
|||||||
18
src/aabb.cpp
18
src/aabb.cpp
@@ -91,6 +91,13 @@ AABB AABB::Create(const Vector3& corner1, const Vector3& corner2, const Matrix4&
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AABB AABB::Create(const AABB& modelSpaceExtents, const Matrix4& modelMatrix)
|
||||||
|
{
|
||||||
|
AABB r;
|
||||||
|
r.init(modelSpaceExtents.min, modelSpaceExtents.max, modelMatrix);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
bool AABB::operator ==(const AABB& b) const
|
bool AABB::operator ==(const AABB& b) const
|
||||||
{
|
{
|
||||||
return min == b.min && max == b.max;
|
return min == b.min && max == b.max;
|
||||||
@@ -366,6 +373,17 @@ void AABB::encapsulate(const AABB& b)
|
|||||||
if (b.max.z > max.z) max.z = b.max.z;
|
if (b.max.z > max.z) max.z = b.max.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AABB::encapsulate(const Vector3& v)
|
||||||
|
{
|
||||||
|
if (v.x < min.x) min.x = v.x;
|
||||||
|
if (v.y < min.y) min.y = v.y;
|
||||||
|
if (v.z < min.z) min.z = v.z;
|
||||||
|
|
||||||
|
if (v.x > max.x) max.x = v.x;
|
||||||
|
if (v.y > max.y) max.y = v.y;
|
||||||
|
if (v.z > max.z) max.z = v.z;
|
||||||
|
}
|
||||||
|
|
||||||
Vector3 AABB::nearestPoint(const Vector3& v) const
|
Vector3 AABB::nearestPoint(const Vector3& v) const
|
||||||
{
|
{
|
||||||
return Vector3::Create(KRCLAMP(v.x, min.x, max.x), KRCLAMP(v.y, min.y, max.y), KRCLAMP(v.z, min.z, max.z));
|
return Vector3::Create(KRCLAMP(v.x, min.x, max.x), KRCLAMP(v.y, min.y, max.y), KRCLAMP(v.z, min.z, max.z));
|
||||||
|
|||||||
Reference in New Issue
Block a user