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 (double a_StartX, double a_StartY, double a_StartZ, double a_EndX, double a_EndY, double a_EndZ)
 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, double a_StartX, double a_StartY, double a_StartZ, double a_EndX, double a_EndY, double a_EndZ)
 Traces one line between Start and End; returns true if the entire line was traced (until OnNoMoreHits()) 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

eBlockFace m_CurrentFace
 The face through which the current block has been entered. More...
 
int m_CurrentX
 The current block. More...
 
int m_CurrentY
 
int m_CurrentZ
 
double m_DiffX
 The difference in coords, End - Start. More...
 
double m_DiffY
 
double m_DiffZ
 
int m_DirX
 The increment at which the block coords are going from Start to End; either +1 or -1. More...
 
int m_DirY
 
int m_DirZ
 
double m_EndX
 The end point of the trace. More...
 
double m_EndY
 
double m_EndZ
 
double m_StartX
 The start point of the trace. More...
 
double m_StartY
 
double m_StartZ
 

Private Types

typedef cBlockTracer super
 

Detailed Description

Definition at line 25 of file LineBlockTracer.h.

Member Typedef Documentation

typedef cBlockTracer cLineBlockTracer::super
private

Definition at line 28 of file LineBlockTracer.h.

Member Enumeration Documentation

Enumerator
losAir 
losWater 
losLava 
losAirWaterLava 
losAirWater 

Definition at line 31 of file LineBlockTracer.h.

Constructor & Destructor Documentation

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

Definition at line 16 of file LineBlockTracer.cpp.

Member Function Documentation

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 236 of file LineBlockTracer.cpp.

bool cLineBlockTracer::ChunkCallback ( cChunk a_Chunk)
protected

Definition at line 310 of file LineBlockTracer.cpp.

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 90 of file LineBlockTracer.cpp.

void cLineBlockTracer::FixStartAboveWorld ( void  )
protected

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

Definition at line 213 of file LineBlockTracer.cpp.

void cLineBlockTracer::FixStartBelowWorld ( void  )
protected

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

Definition at line 226 of file LineBlockTracer.cpp.

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 51 of file LineBlockTracer.cpp.

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 247 of file LineBlockTracer.cpp.

bool cLineBlockTracer::Trace ( double  a_StartX,
double  a_StartY,
double  a_StartZ,
double  a_EndX,
double  a_EndY,
double  a_EndZ 
)

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

Definition at line 156 of file LineBlockTracer.cpp.

bool cLineBlockTracer::Trace ( cWorld a_World,
cBlockTracer::cCallbacks &  a_Callbacks,
double  a_StartX,
double  a_StartY,
double  a_StartZ,
double  a_EndX,
double  a_EndY,
double  a_EndZ 
)
static

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

Definition at line 146 of file LineBlockTracer.cpp.

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 41 of file LineBlockTracer.cpp.

Member Data Documentation

eBlockFace cLineBlockTracer::m_CurrentFace
protected

The face through which the current block has been entered.

Definition at line 92 of file LineBlockTracer.h.

int cLineBlockTracer::m_CurrentX
protected

The current block.

Definition at line 89 of file LineBlockTracer.h.

int cLineBlockTracer::m_CurrentY
protected

Definition at line 89 of file LineBlockTracer.h.

int cLineBlockTracer::m_CurrentZ
protected

Definition at line 89 of file LineBlockTracer.h.

double cLineBlockTracer::m_DiffX
protected

The difference in coords, End - Start.

Definition at line 83 of file LineBlockTracer.h.

double cLineBlockTracer::m_DiffY
protected

Definition at line 83 of file LineBlockTracer.h.

double cLineBlockTracer::m_DiffZ
protected

Definition at line 83 of file LineBlockTracer.h.

int cLineBlockTracer::m_DirX
protected

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

Definition at line 86 of file LineBlockTracer.h.

int cLineBlockTracer::m_DirY
protected

Definition at line 86 of file LineBlockTracer.h.

int cLineBlockTracer::m_DirZ
protected

Definition at line 86 of file LineBlockTracer.h.

double cLineBlockTracer::m_EndX
protected

The end point of the trace.

Definition at line 80 of file LineBlockTracer.h.

double cLineBlockTracer::m_EndY
protected

Definition at line 80 of file LineBlockTracer.h.

double cLineBlockTracer::m_EndZ
protected

Definition at line 80 of file LineBlockTracer.h.

double cLineBlockTracer::m_StartX
protected

The start point of the trace.

Definition at line 77 of file LineBlockTracer.h.

double cLineBlockTracer::m_StartY
protected

Definition at line 77 of file LineBlockTracer.h.

double cLineBlockTracer::m_StartZ
protected

Definition at line 77 of file LineBlockTracer.h.


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