summaryrefslogtreecommitdiffstats
path: root/source/Tracer.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2013-11-05 22:35:21 +0100
committerMattes D <github@xoft.cz>2013-11-05 22:35:21 +0100
commitf0a2d49acacd2f472b15820dc01a518a06449ecb (patch)
tree6da96033cf71e122effe77e9ea1104d4fbb5a470 /source/Tracer.cpp
parentMerge pull request #309 from mc-server/configautogen (diff)
parentMore documentation. (diff)
downloadcuberite-f0a2d49acacd2f472b15820dc01a518a06449ecb.tar
cuberite-f0a2d49acacd2f472b15820dc01a518a06449ecb.tar.gz
cuberite-f0a2d49acacd2f472b15820dc01a518a06449ecb.tar.bz2
cuberite-f0a2d49acacd2f472b15820dc01a518a06449ecb.tar.lz
cuberite-f0a2d49acacd2f472b15820dc01a518a06449ecb.tar.xz
cuberite-f0a2d49acacd2f472b15820dc01a518a06449ecb.tar.zst
cuberite-f0a2d49acacd2f472b15820dc01a518a06449ecb.zip
Diffstat (limited to 'source/Tracer.cpp')
-rw-r--r--source/Tracer.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/source/Tracer.cpp b/source/Tracer.cpp
index 42f1ae5dd..ef136302f 100644
--- a/source/Tracer.cpp
+++ b/source/Tracer.cpp
@@ -131,12 +131,12 @@ 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)
+bool cTracer::Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int a_Distance, bool a_LineOfSight)
{
if ((a_Start.y < 0) || (a_Start.y >= cChunkDef::Height))
{
LOGD("%s: Start Y is outside the world (%.2f), not tracing.", __FUNCTION__, a_Start.y);
- return 0;
+ return false;
}
SetValues(a_Start, a_Direction);
@@ -157,7 +157,7 @@ int cTracer::Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int
// check if first is occupied
if (pos.Equals(end1))
{
- return 0;
+ return false;
}
bool reachedX = false, reachedY = false, reachedZ = false;
@@ -224,8 +224,9 @@ int cTracer::Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int
}
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?
+ // Block is counted as a collision if we are not doing a line of sight and it is solid,
+ // or if the block is not air and not water. That way mobs can still see underwater.
+ if ((!a_LineOfSight && g_BlockIsSolid[BlockID]) || (a_LineOfSight && (BlockID != E_BLOCK_AIR) && !IsBlockWater(BlockID)))
{
BlockHitPosition = pos;
int Normal = GetHitNormal(a_Start, End, pos );
@@ -233,10 +234,10 @@ int cTracer::Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int
{
HitNormal = m_NormalTable[Normal-1];
}
- return 1;
+ return true;
}
}
- return 0;
+ return false;
}