|
@@ -79,9 +79,9 @@ public:
|
|
|
/// Test if a point is inside or outside.
|
|
/// Test if a point is inside or outside.
|
|
|
Intersection IsInside(const Vector3& point) const
|
|
Intersection IsInside(const Vector3& point) const
|
|
|
{
|
|
{
|
|
|
- for (unsigned i = 0; i < NUM_FRUSTUM_PLANES; ++i)
|
|
|
|
|
|
|
+ for (const auto& plane : planes_)
|
|
|
{
|
|
{
|
|
|
- if (planes_[i].Distance(point) < 0.0f)
|
|
|
|
|
|
|
+ if (plane.Distance(point) < 0.0f)
|
|
|
return OUTSIDE;
|
|
return OUTSIDE;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -92,9 +92,9 @@ public:
|
|
|
Intersection IsInside(const Sphere& sphere) const
|
|
Intersection IsInside(const Sphere& sphere) const
|
|
|
{
|
|
{
|
|
|
bool allInside = true;
|
|
bool allInside = true;
|
|
|
- for (unsigned i = 0; i < NUM_FRUSTUM_PLANES; ++i)
|
|
|
|
|
|
|
+ for (const auto& plane : planes_)
|
|
|
{
|
|
{
|
|
|
- float dist = planes_[i].Distance(sphere.center_);
|
|
|
|
|
|
|
+ float dist = plane.Distance(sphere.center_);
|
|
|
if (dist < -sphere.radius_)
|
|
if (dist < -sphere.radius_)
|
|
|
return OUTSIDE;
|
|
return OUTSIDE;
|
|
|
else if (dist < sphere.radius_)
|
|
else if (dist < sphere.radius_)
|
|
@@ -107,9 +107,9 @@ public:
|
|
|
/// Test if a sphere if (partially) inside or outside.
|
|
/// Test if a sphere if (partially) inside or outside.
|
|
|
Intersection IsInsideFast(const Sphere& sphere) const
|
|
Intersection IsInsideFast(const Sphere& sphere) const
|
|
|
{
|
|
{
|
|
|
- for (unsigned i = 0; i < NUM_FRUSTUM_PLANES; ++i)
|
|
|
|
|
|
|
+ for (const auto& plane : planes_)
|
|
|
{
|
|
{
|
|
|
- if (planes_[i].Distance(sphere.center_) < -sphere.radius_)
|
|
|
|
|
|
|
+ if (plane.Distance(sphere.center_) < -sphere.radius_)
|
|
|
return OUTSIDE;
|
|
return OUTSIDE;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -123,9 +123,8 @@ public:
|
|
|
Vector3 edge = center - box.min_;
|
|
Vector3 edge = center - box.min_;
|
|
|
bool allInside = true;
|
|
bool allInside = true;
|
|
|
|
|
|
|
|
- for (unsigned i = 0; i < NUM_FRUSTUM_PLANES; ++i)
|
|
|
|
|
|
|
+ for (const auto& plane : planes_)
|
|
|
{
|
|
{
|
|
|
- const Plane& plane = planes_[i];
|
|
|
|
|
float dist = plane.normal_.DotProduct(center) + plane.d_;
|
|
float dist = plane.normal_.DotProduct(center) + plane.d_;
|
|
|
float absDist = plane.absNormal_.DotProduct(edge);
|
|
float absDist = plane.absNormal_.DotProduct(edge);
|
|
|
|
|
|
|
@@ -144,9 +143,8 @@ public:
|
|
|
Vector3 center = box.Center();
|
|
Vector3 center = box.Center();
|
|
|
Vector3 edge = center - box.min_;
|
|
Vector3 edge = center - box.min_;
|
|
|
|
|
|
|
|
- for (unsigned i = 0; i < NUM_FRUSTUM_PLANES; ++i)
|
|
|
|
|
|
|
+ for (const auto& plane : planes_)
|
|
|
{
|
|
{
|
|
|
- const Plane& plane = planes_[i];
|
|
|
|
|
float dist = plane.normal_.DotProduct(center) + plane.d_;
|
|
float dist = plane.normal_.DotProduct(center) + plane.d_;
|
|
|
float absDist = plane.absNormal_.DotProduct(edge);
|
|
float absDist = plane.absNormal_.DotProduct(edge);
|
|
|
|
|
|
|
@@ -161,8 +159,8 @@ public:
|
|
|
float Distance(const Vector3& point) const
|
|
float Distance(const Vector3& point) const
|
|
|
{
|
|
{
|
|
|
float distance = 0.0f;
|
|
float distance = 0.0f;
|
|
|
- for (unsigned i = 0; i < NUM_FRUSTUM_PLANES; ++i)
|
|
|
|
|
- distance = Max(-planes_[i].Distance(point), distance);
|
|
|
|
|
|
|
+ for (const auto& plane : planes_)
|
|
|
|
|
+ distance = Max(-plane.Distance(point), distance);
|
|
|
|
|
|
|
|
return distance;
|
|
return distance;
|
|
|
}
|
|
}
|