diff options
-rw-r--r-- | source/BlockTracer.h | 6 | ||||
-rw-r--r-- | source/LineBlockTracer.cpp | 11 |
2 files changed, 10 insertions, 7 deletions
diff --git a/source/BlockTracer.h b/source/BlockTracer.h index 4adc61f00..6d67f1052 100644 --- a/source/BlockTracer.h +++ b/source/BlockTracer.h @@ -36,7 +36,7 @@ public: /** Called on each block encountered along the path, including the first block (path start), if chunk data is not loaded When this callback returns true, the tracing is aborted. */ - virtual bool OnNextBlockNoData(int a_BlockX, int a_BlockY, int a_BlockZ) {} + virtual bool OnNextBlockNoData(int a_BlockX, int a_BlockY, int a_BlockZ) { return false; } /** Called when the path goes out of world, either below (a_BlockY < 0) or above (a_BlockY >= cChunkDef::Height) The coords specify the exact point at which the path exited the world. @@ -44,7 +44,7 @@ public: Note that some paths can go out of the world and come back again (parabola), in such a case this callback is followed by OnIntoWorld() and further OnNextBlock() calls */ - virtual bool OnOutOfWorld(double a_BlockX, double a_BlockY, double a_BlockZ) {} + virtual bool OnOutOfWorld(double a_BlockX, double a_BlockY, double a_BlockZ) { return false; } /** Called when the path goes into the world, from either below (a_BlockY < 0) or above (a_BlockY >= cChunkDef::Height) The coords specify the exact point at which the path entered the world. @@ -52,7 +52,7 @@ public: Note that some paths can go out of the world and come back again (parabola), in such a case this callback is followed by further OnNextBlock() calls */ - virtual bool OnIntoWorld(double a_BlockX, double a_BlockY, double a_BlockZ) {} + virtual bool OnIntoWorld(double a_BlockX, double a_BlockY, double a_BlockZ) { return false; } /** Called when the path is sure not to hit any more blocks. Note that for some shapes this might never happen (line with constant Y) diff --git a/source/LineBlockTracer.cpp b/source/LineBlockTracer.cpp index c5939cb78..03464314a 100644 --- a/source/LineBlockTracer.cpp +++ b/source/LineBlockTracer.cpp @@ -148,8 +148,11 @@ bool cLineBlockTracer::MoveToNextBlock(void) if (abs(m_DiffX) > EPS) { double DestX = (m_DirX > 0) ? (m_CurrentX + 1) : m_CurrentX; - Coeff = (m_EndX - DestX) / m_DiffX; - Direction = dirX; + Coeff = (DestX - m_StartX) / m_DiffX; + if (Coeff <= 1) + { + Direction = dirX; + } } if (abs(m_DiffY) > EPS) { @@ -205,8 +208,8 @@ bool cLineBlockTracer::Item(cChunk * a_Chunk) { BLOCKTYPE BlockType; NIBBLETYPE BlockMeta; - int RelX = FAST_FLOOR_DIV(m_CurrentX, cChunkDef::Width); - int RelZ = FAST_FLOOR_DIV(m_CurrentZ, cChunkDef::Width); + int RelX = m_CurrentX - a_Chunk->GetPosX() * cChunkDef::Width; + int RelZ = m_CurrentZ - a_Chunk->GetPosZ() * cChunkDef::Width; a_Chunk->GetBlockTypeMeta(RelX, m_CurrentY, RelZ, BlockType, BlockMeta); if (m_Callbacks->OnNextBlock(m_CurrentX, m_CurrentY, m_CurrentZ, BlockType, BlockMeta)) { |