Cleanup some code
This commit is contained in:
@@ -248,7 +248,7 @@ public:
|
||||
/// <returns>True if the current BoundingFrustum intersects a BoundingBox, otherwise false.</returns>
|
||||
FORCE_INLINE bool Intersects(const BoundingBox& box) const
|
||||
{
|
||||
return CollisionsHelper::FrustumIntersectsBox(*this, box);
|
||||
return CollisionsHelper::FrustumContainsBox(*this, box) != ContainmentType::Disjoint;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -1301,43 +1301,33 @@ bool CollisionsHelper::FrustumIntersectsBox(const BoundingFrustum& frustum, cons
|
||||
|
||||
ContainmentType CollisionsHelper::FrustumContainsBox(const BoundingFrustum& frustum, const BoundingBox& box)
|
||||
{
|
||||
Vector3 p, n;
|
||||
Plane plane;
|
||||
auto result = ContainmentType::Contains;
|
||||
|
||||
for (int32 i = 0; i < 6; i++)
|
||||
{
|
||||
plane = frustum.GetPlane(i);
|
||||
GetBoxToPlanePVertexNVertex(box, plane.Normal, p, n);
|
||||
|
||||
Plane plane = frustum.GetPlane(i);
|
||||
Vector3 p = box.Minimum;
|
||||
if (plane.Normal.X >= 0)
|
||||
p.X = box.Maximum.X;
|
||||
if (plane.Normal.Y >= 0)
|
||||
p.Y = box.Maximum.Y;
|
||||
if (plane.Normal.Z >= 0)
|
||||
p.Z = box.Maximum.Z;
|
||||
if (PlaneIntersectsPoint(plane, p) == PlaneIntersectionType::Back)
|
||||
return ContainmentType::Disjoint;
|
||||
|
||||
if (PlaneIntersectsPoint(plane, n) == PlaneIntersectionType::Back)
|
||||
p = box.Maximum;
|
||||
if (plane.Normal.X >= 0)
|
||||
p.X = box.Minimum.X;
|
||||
if (plane.Normal.Y >= 0)
|
||||
p.Y = box.Minimum.Y;
|
||||
if (plane.Normal.Z >= 0)
|
||||
p.Z = box.Minimum.Z;
|
||||
if (PlaneIntersectsPoint(plane, p) == PlaneIntersectionType::Back)
|
||||
result = ContainmentType::Intersects;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void CollisionsHelper::GetBoxToPlanePVertexNVertex(const BoundingBox& box, const Vector3& planeNormal, Vector3& p, Vector3& n)
|
||||
{
|
||||
p = box.Minimum;
|
||||
if (planeNormal.X >= 0)
|
||||
p.X = box.Maximum.X;
|
||||
if (planeNormal.Y >= 0)
|
||||
p.Y = box.Maximum.Y;
|
||||
if (planeNormal.Z >= 0)
|
||||
p.Z = box.Maximum.Z;
|
||||
|
||||
n = box.Maximum;
|
||||
if (planeNormal.X >= 0)
|
||||
n.X = box.Minimum.X;
|
||||
if (planeNormal.Y >= 0)
|
||||
n.Y = box.Minimum.Y;
|
||||
if (planeNormal.Z >= 0)
|
||||
n.Z = box.Minimum.Z;
|
||||
}
|
||||
|
||||
bool CollisionsHelper::LineIntersectsLine(const Vector2& l1p1, const Vector2& l1p2, const Vector2& l2p1, const Vector2& l2p2)
|
||||
{
|
||||
float q = (l1p1.Y - l2p1.Y) * (l2p2.X - l2p1.X) - (l1p1.X - l2p1.X) * (l2p2.Y - l2p1.Y);
|
||||
|
||||
@@ -550,8 +550,6 @@ public:
|
||||
|
||||
static ContainmentType FrustumContainsBox(const BoundingFrustum& frustum, const BoundingBox& box);
|
||||
|
||||
static void GetBoxToPlanePVertexNVertex(const BoundingBox& box, const Vector3& planeNormal, Vector3& p, Vector3& n);
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether a line intersects with the other line.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user