1
0

cTracer: Fixed asserts for invalid coords

git-svn-id: http://mc-server.googlecode.com/svn/trunk@1327 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com 2013-03-30 10:54:05 +00:00
parent 674ed9d43a
commit 51596c60a9

View File

@ -99,11 +99,27 @@ void cTracer::SetValues( const Vector3f & a_Start, const Vector3f & a_Direction
}
}
int cTracer::Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int a_Distance)
{
if (a_Start.y < 0)
{
LOGD("%s: Start is below the world", __FUNCTION__);
return 0;
}
SetValues(a_Start, a_Direction);
const Vector3f End = a_Start + (dir * (float)a_Distance);
Vector3f End = a_Start + (dir * (float)a_Distance);
if (End.y < 0)
{
float dist = -a_Start.y / dir.y;
End = a_Start + (dir * dist);
}
// end voxel coordinates
end1.x = (int)floorf(End.x);
@ -180,9 +196,9 @@ int cTracer::Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int
return false;
}
char BlockID = m_World->GetBlock( pos.x, pos.y, pos.z );
BLOCKTYPE BlockID = m_World->GetBlock( pos.x, pos.y, pos.z );
// No collision with water ;)
if ( BlockID != E_BLOCK_AIR || IsBlockWater(BlockID))
if ((BlockID != E_BLOCK_AIR) || IsBlockWater(BlockID)) // _X 2013_03_29: Why is the IsBlockWater condition here? water equals air?
{
BlockHitPosition = pos;
int Normal = GetHitNormal(a_Start, End, pos );
@ -196,6 +212,10 @@ int cTracer::Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int
return 0;
}
// return 1 = hit, other is not hit
int LinesCross(float x0,float y0,float x1,float y1,float x2,float y2,float x3,float y3)
{