Tracer signum function now returns int
This commit is contained in:
parent
797e3130d2
commit
496e5b1000
@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const float FLOAT_EPSILON = 0.0001f; //TODO: Stash this in some header where it can be reused
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cTracer::cTracer(cWorld * a_World):
|
cTracer::cTracer(cWorld * a_World):
|
||||||
@ -37,7 +39,7 @@ cTracer::~cTracer()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
float cTracer::SigNum(float a_Num)
|
int cTracer::SigNum(float a_Num)
|
||||||
{
|
{
|
||||||
if (a_Num < 0.f)
|
if (a_Num < 0.f)
|
||||||
{
|
{
|
||||||
@ -63,9 +65,10 @@ void cTracer::SetValues(const Vector3f & a_Start, const Vector3f & a_Direction)
|
|||||||
dir = a_Direction;
|
dir = a_Direction;
|
||||||
|
|
||||||
// decide which direction to start walking in
|
// decide which direction to start walking in
|
||||||
step.x = (int) SigNum(dir.x);
|
step.x = SigNum(dir.x);
|
||||||
step.y = (int) SigNum(dir.y);
|
step.y = SigNum(dir.y);
|
||||||
step.z = (int) SigNum(dir.z);
|
step.z = SigNum(dir.z);
|
||||||
|
|
||||||
|
|
||||||
// normalize the direction vector
|
// normalize the direction vector
|
||||||
dir.Normalize();
|
dir.Normalize();
|
||||||
@ -302,8 +305,7 @@ int cTracer::intersect3D_SegmentPlane(const Vector3f & a_Origin, const Vector3f
|
|||||||
float D = a_PlaneNormal.Dot(u); // dot(Pn.n, u);
|
float D = a_PlaneNormal.Dot(u); // dot(Pn.n, u);
|
||||||
float N = -(a_PlaneNormal.Dot(w)); // -dot(a_Plane.n, w);
|
float N = -(a_PlaneNormal.Dot(w)); // -dot(a_Plane.n, w);
|
||||||
|
|
||||||
const float EPSILON = 0.0001f;
|
if (fabs(D) < FLOAT_EPSILON)
|
||||||
if (fabs(D) < EPSILON)
|
|
||||||
{
|
{
|
||||||
// segment is parallel to plane
|
// segment is parallel to plane
|
||||||
if (N == 0.0)
|
if (N == 0.0)
|
||||||
|
@ -61,7 +61,8 @@ private:
|
|||||||
/// Return 1 through 6 for the following block faces, repectively: -x, -z, x, z, y, -y
|
/// Return 1 through 6 for the following block faces, repectively: -x, -z, x, z, y, -y
|
||||||
int GetHitNormal( const Vector3f & start, const Vector3f & end, const Vector3i & a_BlockPos);
|
int GetHitNormal( const Vector3f & start, const Vector3f & end, const Vector3i & a_BlockPos);
|
||||||
|
|
||||||
float SigNum( float a_Num);
|
/// Signum function
|
||||||
|
int SigNum( float a_Num);
|
||||||
cWorld* m_World;
|
cWorld* m_World;
|
||||||
|
|
||||||
Vector3f m_NormalTable[6];
|
Vector3f m_NormalTable[6];
|
||||||
|
Loading…
Reference in New Issue
Block a user