Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | List of all members
cLineBlockTracer Class Reference

#include <LineBlockTracer.h>

Inheritance diagram for cLineBlockTracer:
Inheritance graph
[legend]
Collaboration diagram for cLineBlockTracer:
Collaboration graph
[legend]

Public Types

enum  eLineOfSight {
  losAir = 1 , losWater = 2 , losLava = 4 , losAirWaterLava = losAir | losWater | losLava ,
  losAirWater = losAir | losWater
}
 

Public Member Functions

 cLineBlockTracer (cWorld &a_World, cCallbacks &a_Callbacks)
 
bool Trace (Vector3d a_Start, Vector3d a_End)
 Traces one line between Start and End; returns true if the entire line was traced (until OnNoMoreHits()) More...
 

Static Public Member Functions

static bool FirstSolidHitTrace (cWorld &a_World, const Vector3d &a_Start, const Vector3d &a_End, Vector3d &a_HitCoords, Vector3i &a_HitBlockCoords, eBlockFace &a_HitBlockFace)
 Traces until the first solid block is hit (or until end, whichever comes first. More...
 
static bool LineOfSightTrace (cWorld &a_World, const Vector3d &a_Start, const Vector3d &a_End, int a_Sight)
 Returns true if the two positions are within line of sight (not obscured by blocks). More...
 
static bool Trace (cWorld &a_World, cCallbacks &a_Callbacks, const Vector3d a_Start, const Vector3d a_End)
 Traces one line between Start and End; returns true if the entire line was traced (until OnNoMoreHits()) More...
 

Protected Member Functions

void CalcXZIntersection (double a_Y, double &a_IntersectX, double &a_IntersectZ)
 Calculates the XZ coords of an intersection with the specified Yconst plane; assumes that such an intersection exists. More...
 
bool ChunkCallback (cChunk *a_Chunk)
 
void FixStartAboveWorld (void)
 Adjusts the start point above the world to just at the world's top. More...
 
void FixStartBelowWorld (void)
 Adjusts the start point below the world to just at the world's bottom. More...
 
bool MoveToNextBlock (void)
 Moves m_Current to the next block on the line; returns false if no move is possible (reached the end) More...
 

Protected Attributes

Vector3i m_Current
 The current block. More...
 
eBlockFace m_CurrentFace
 The face through which the current block has been entered. More...
 
Vector3d m_Diff
 The difference in coords, End - Start. More...
 
Vector3i m_Dir
 The increment at which the block coords are going from Start to End; either +1 or -1. More...
 
Vector3d m_End
 The end point of the trace. More...
 
Vector3d m_Start
 The start point of the trace. More...
 

Private Types

using Super = cBlockTracer
 

Detailed Description

Definition at line 25 of file LineBlockTracer.h.

Member Typedef Documentation

◆ Super

using cLineBlockTracer::Super = cBlockTracer
private

Definition at line 28 of file LineBlockTracer.h.

Member Enumeration Documentation

◆ eLineOfSight

Enumerator
losAir 
losWater 
losLava 
losAirWaterLava 
losAirWater 

Definition at line 32 of file LineBlockTracer.h.

Constructor & Destructor Documentation

◆ cLineBlockTracer()

cLineBlockTracer::cLineBlockTracer ( cWorld a_World,
cCallbacks &  a_Callbacks 
)

Definition at line 17 of file LineBlockTracer.cpp.

Member Function Documentation

◆ CalcXZIntersection()

void cLineBlockTracer::CalcXZIntersection ( double  a_Y,
double &  a_IntersectX,
double &  a_IntersectZ 
)
protected

Calculates the XZ coords of an intersection with the specified Yconst plane; assumes that such an intersection exists.

Definition at line 209 of file LineBlockTracer.cpp.

◆ ChunkCallback()

bool cLineBlockTracer::ChunkCallback ( cChunk a_Chunk)
protected

Definition at line 283 of file LineBlockTracer.cpp.

◆ FirstSolidHitTrace()

bool cLineBlockTracer::FirstSolidHitTrace ( cWorld a_World,
const Vector3d a_Start,
const Vector3d a_End,
Vector3d a_HitCoords,
Vector3i a_HitBlockCoords,
eBlockFace a_HitBlockFace 
)
static

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.

Definition at line 81 of file LineBlockTracer.cpp.

◆ FixStartAboveWorld()

void cLineBlockTracer::FixStartAboveWorld ( void  )
protected

Adjusts the start point above the world to just at the world's top.

Definition at line 186 of file LineBlockTracer.cpp.

◆ FixStartBelowWorld()

void cLineBlockTracer::FixStartBelowWorld ( void  )
protected

Adjusts the start point below the world to just at the world's bottom.

Definition at line 199 of file LineBlockTracer.cpp.

◆ LineOfSightTrace()

bool cLineBlockTracer::LineOfSightTrace ( cWorld a_World,
const Vector3d a_Start,
const Vector3d a_End,
int  a_Sight 
)
static

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.

Definition at line 42 of file LineBlockTracer.cpp.

◆ MoveToNextBlock()

bool cLineBlockTracer::MoveToNextBlock ( void  )
protected

Moves m_Current to the next block on the line; returns false if no move is possible (reached the end)

Definition at line 220 of file LineBlockTracer.cpp.

◆ Trace() [1/2]

bool cLineBlockTracer::Trace ( cWorld a_World,
cBlockTracer::cCallbacks &  a_Callbacks,
const Vector3d  a_Start,
const Vector3d  a_End 
)
static

Traces one line between Start and End; returns true if the entire line was traced (until OnNoMoreHits())

Definition at line 32 of file LineBlockTracer.cpp.

◆ Trace() [2/2]

bool cLineBlockTracer::Trace ( Vector3d  a_Start,
Vector3d  a_End 
)

Traces one line between Start and End; returns true if the entire line was traced (until OnNoMoreHits())

Definition at line 137 of file LineBlockTracer.cpp.

Member Data Documentation

◆ m_Current

Vector3i cLineBlockTracer::m_Current
protected

The current block.

Definition at line 88 of file LineBlockTracer.h.

◆ m_CurrentFace

eBlockFace cLineBlockTracer::m_CurrentFace
protected

The face through which the current block has been entered.

Definition at line 91 of file LineBlockTracer.h.

◆ m_Diff

Vector3d cLineBlockTracer::m_Diff
protected

The difference in coords, End - Start.

Definition at line 82 of file LineBlockTracer.h.

◆ m_Dir

Vector3i cLineBlockTracer::m_Dir
protected

The increment at which the block coords are going from Start to End; either +1 or -1.

Definition at line 85 of file LineBlockTracer.h.

◆ m_End

Vector3d cLineBlockTracer::m_End
protected

The end point of the trace.

Definition at line 79 of file LineBlockTracer.h.

◆ m_Start

Vector3d cLineBlockTracer::m_Start
protected

The start point of the trace.

Definition at line 76 of file LineBlockTracer.h.


The documentation for this class was generated from the following files: