diff options
author | Mattes D <github@xoft.cz> | 2017-05-11 14:34:36 +0200 |
---|---|---|
committer | worktycho <work.tycho@gmail.com> | 2017-05-11 14:34:36 +0200 |
commit | 2c3c1f15273835923d9bd4950a19ee88a95ee0f4 (patch) | |
tree | cda390aa07a202497271439c2b330643074239df /src/LineBlockTracer.h | |
parent | Exported cFallingBlock and cExpOrb (#3700) (diff) | |
download | cuberite-2c3c1f15273835923d9bd4950a19ee88a95ee0f4.tar cuberite-2c3c1f15273835923d9bd4950a19ee88a95ee0f4.tar.gz cuberite-2c3c1f15273835923d9bd4950a19ee88a95ee0f4.tar.bz2 cuberite-2c3c1f15273835923d9bd4950a19ee88a95ee0f4.tar.lz cuberite-2c3c1f15273835923d9bd4950a19ee88a95ee0f4.tar.xz cuberite-2c3c1f15273835923d9bd4950a19ee88a95ee0f4.tar.zst cuberite-2c3c1f15273835923d9bd4950a19ee88a95ee0f4.zip |
Diffstat (limited to '')
-rw-r--r-- | src/LineBlockTracer.h | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/LineBlockTracer.h b/src/LineBlockTracer.h index 37493ce5c..2851cfbd7 100644 --- a/src/LineBlockTracer.h +++ b/src/LineBlockTracer.h @@ -33,6 +33,19 @@ class cLineBlockTracer : typedef cBlockTracer super; public: + enum eLineOfSight + { + // Bit flags used for LineOfSightTrace's Sight parameter: + losAir = 1, // Can see through air + losWater = 2, // Can see through water + losLava = 4, // Can see through lava + + // Common combinations: + losAirWaterLava = losAir | losWater | losLava, + losAirWater = losAir | losWater, + }; + + cLineBlockTracer(cWorld & a_World, cCallbacks & a_Callbacks); /** Traces one line between Start and End; returns true if the entire line was traced (until OnNoMoreHits()) */ @@ -46,6 +59,24 @@ public: /** Traces one line between Start and End; returns true if the entire line was traced (until OnNoMoreHits()) */ static bool Trace(cWorld & a_World, cCallbacks & a_Callbacks, const Vector3d & a_Start, const Vector3d & a_End); + /** Returns true if the two positions are within line of sight (not obscured by blocks). + a_Sight specifies which blocks are considered transparent for the trace, is an OR-combination of eLineOfSight constants. */ + static bool LineOfSightTrace(cWorld & a_World, const Vector3d & a_Start, const Vector3d & a_End, int a_Sight); + + /** Traces until the first solid block is hit (or until end, whichever comes first. + If a solid block was hit, returns true and fills a_HitCoords, a_HitBlockCoords and a_HitBlockFace. + If a_End is encountered without hitting any solid block, returns false and doesn't touch a_HitCoords, a_HitBlockCoords nor a_HitBlockFace. + a_HitCoords is the exact coords of the hit, + a_HitBlockCoords are the coords of the solid block that was hit, + a_HitBlockFace is the face of the solid block that was hit. */ + static bool FirstSolidHitTrace( + cWorld & a_World, + const Vector3d & a_Start, const Vector3d & a_End, + Vector3d & a_HitCoords, + Vector3i & a_HitBlockCoords, + eBlockFace & a_HitBlockFace + ); + protected: /** The start point of the trace */ double m_StartX, m_StartY, m_StartZ; @@ -63,7 +94,7 @@ protected: int m_CurrentX, m_CurrentY, m_CurrentZ; /** The face through which the current block has been entered */ - char m_CurrentFace; + eBlockFace m_CurrentFace; /** Adjusts the start point above the world to just at the world's top */ |