summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-03-30 11:54:05 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-03-30 11:54:05 +0100
commit51596c60a904a82e38deac9ba79c528bf51f5a7a (patch)
tree854628f362ce4b08246828daabf50e6e438b041b
parentMineShafts: implemented basic corridors, without any embellishments or branching yet. (diff)
downloadcuberite-51596c60a904a82e38deac9ba79c528bf51f5a7a.tar
cuberite-51596c60a904a82e38deac9ba79c528bf51f5a7a.tar.gz
cuberite-51596c60a904a82e38deac9ba79c528bf51f5a7a.tar.bz2
cuberite-51596c60a904a82e38deac9ba79c528bf51f5a7a.tar.lz
cuberite-51596c60a904a82e38deac9ba79c528bf51f5a7a.tar.xz
cuberite-51596c60a904a82e38deac9ba79c528bf51f5a7a.tar.zst
cuberite-51596c60a904a82e38deac9ba79c528bf51f5a7a.zip
Diffstat (limited to '')
-rw-r--r--source/Tracer.cpp32
1 files changed, 26 insertions, 6 deletions
diff --git a/source/Tracer.cpp b/source/Tracer.cpp
index fb1ab6c3b..548be8163 100644
--- a/source/Tracer.cpp
+++ b/source/Tracer.cpp
@@ -99,17 +99,33 @@ 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)
{
- SetValues( a_Start, a_Direction );
+ 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);
end1.y = (int)floorf(End.y);
end1.z = (int)floorf(End.z);
-
+
// check if first is occupied
if( pos.Equals( end1 ) )
{
@@ -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 );
- //No collision with water ;)
- if ( BlockID != E_BLOCK_AIR || IsBlockWater(BlockID))
+ BLOCKTYPE BlockID = m_World->GetBlock( pos.x, pos.y, pos.z );
+ // No collision with water ;)
+ 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)
{