Bounding sphere
#ifndef BOUNDING_SPHERE_H
#define BOUNDING_SPHERE_H
#include "BoundingVolume.h"
namespace Math
{
// Bounding sphere.
class BoundingSphere:public BoundingVolume
{
public:
// @desc: None.
BoundingSphere();
// @desc: Set member variable to the values that the parameters specified.
BoundingSphere(const Vector3& p_vec3Center, float p_fRadius);
// @desc: None.
virtual ~BoundingSphere();
// @desc: Check the visibility of bounding sphere.
virtual bool CheckVisible(const Frustum& p_Frustum);
// The center of bounding sphere.
Vector3 m_vec3Center;
// The radius of bounding sphere.
float m_fRadius;
};
// @desc: None.
BoundingSphere::BoundingSphere():m_vec3Center(),m_fRadius(0.0f){}
// @desc: Set member variable to the values that the parameters specified.
BoundingSphere::BoundingSphere(const Vector3& p_vec3Center, float p_fRadius):m_vec3Center(p_vec3Center),m_fRadius(p_fRadius){}
// @desc: None.
BoundingSphere::~BoundingSphere(){}
// @desc: Check the visibility of bounding sphere.
bool BoundingSphere::CheckVisible(const Frustum& p_Frustum)
{
const float fNegativeRadius = -m_fRadius;
const Plane* pClipPlane = p_Frustum.GetClipPlane();
for (unsigned i = 0U; i < Frustum::s_uiPlaneNumber; ++i)
{
if (PointToPlane(pClipPlane[i], m_vec3Center) < fNegativeRadius)
{
return false;
}
}
return true;
}
}
#endif
#define BOUNDING_SPHERE_H
#include "BoundingVolume.h"
namespace Math
{
// Bounding sphere.
class BoundingSphere:public BoundingVolume
{
public:
// @desc: None.
BoundingSphere();
// @desc: Set member variable to the values that the parameters specified.
BoundingSphere(const Vector3& p_vec3Center, float p_fRadius);
// @desc: None.
virtual ~BoundingSphere();
// @desc: Check the visibility of bounding sphere.
virtual bool CheckVisible(const Frustum& p_Frustum);
// The center of bounding sphere.
Vector3 m_vec3Center;
// The radius of bounding sphere.
float m_fRadius;
};
// @desc: None.
BoundingSphere::BoundingSphere():m_vec3Center(),m_fRadius(0.0f){}
// @desc: Set member variable to the values that the parameters specified.
BoundingSphere::BoundingSphere(const Vector3& p_vec3Center, float p_fRadius):m_vec3Center(p_vec3Center),m_fRadius(p_fRadius){}
// @desc: None.
BoundingSphere::~BoundingSphere(){}
// @desc: Check the visibility of bounding sphere.
bool BoundingSphere::CheckVisible(const Frustum& p_Frustum)
{
const float fNegativeRadius = -m_fRadius;
const Plane* pClipPlane = p_Frustum.GetClipPlane();
for (unsigned i = 0U; i < Frustum::s_uiPlaneNumber; ++i)
{
if (PointToPlane(pClipPlane[i], m_vec3Center) < fNegativeRadius)
{
return false;
}
}
return true;
}
}
#endif
浙公网安备 33010602011771号