1
0

Tracer: removed the "start and end in the same block" warning, it is a normal condition.

git-svn-id: http://mc-server.googlecode.com/svn/trunk@1360 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com 2013-04-06 16:12:52 +00:00
parent d397dd263f
commit 045021e896

View File

@ -17,6 +17,10 @@
#include <stdlib.h> // abs()
#endif
cTracer::cTracer(cWorld * a_World)
: m_World(a_World)
{
@ -28,10 +32,18 @@ cTracer::cTracer(cWorld* a_World)
m_NormalTable[5].Set( 0,-1, 0);
}
cTracer::~cTracer()
{
}
float cTracer::SigNum( float a_Num )
{
if (a_Num < 0.f) return -1.f;
@ -39,6 +51,10 @@ float cTracer::SigNum( float a_Num )
return 0.f;
}
void cTracer::SetValues(const Vector3f & a_Start, const Vector3f & a_Direction)
{
// calculate the direction of the ray (linear algebra)
@ -55,17 +71,32 @@ void cTracer::SetValues( const Vector3f & a_Start, const Vector3f & a_Direction
// how far we must move in the ray direction before
// we encounter a new voxel in x-direction
// same but y-direction
if( dir.x != 0.f ) tDelta.x = 1/fabs(dir.x);
else tDelta.x = 0;
if( dir.y != 0.f ) tDelta.y = 1/fabs(dir.y);
else tDelta.y = 0;
if( dir.z != 0.f ) tDelta.z = 1/fabs(dir.z);
else tDelta.z = 0;
if (dir.x != 0.f)
{
tDelta.x = 1 / fabs(dir.x);
}
else
{
tDelta.x = 0;
}
if (dir.y != 0.f)
{
tDelta.y = 1 / fabs(dir.y);
}
else
{
tDelta.y = 0;
}
if (dir.z != 0.f)
{
tDelta.z = 1 / fabs(dir.z);
}
else
{
tDelta.z = 0;
}
// start voxel coordinates
// use your
// transformer
// function here
pos.x = (int)floorf(a_Start.x);
pos.y = (int)floorf(a_Start.y);
pos.z = (int)floorf(a_Start.z);
@ -129,7 +160,6 @@ int cTracer::Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int
// check if first is occupied
if (pos.Equals(end1))
{
LOG("WARNING: cTracer: Start and end in same block");
return 0;
}
@ -139,7 +169,7 @@ int cTracer::Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int
while (Iterations < a_Distance)
{
Iterations++;
if(tMax.x < tMax.y && tMax.x < tMax.z)
if ((tMax.x < tMax.y) && (tMax.x < tMax.z))
{
tMax.x += tDelta.x;
pos.x += step.x;