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

#include <Cuboid.h>

Collaboration diagram for cCuboid:
Collaboration graph
[legend]

Public Member Functions

void Assign (const cCuboid &a_SrcCuboid)
 
void Assign (Vector3i a_Point1, Vector3i a_Point2)
 
 cCuboid (int a_X1, int a_Y1, int a_Z1)
 
 cCuboid (Vector3i a_p1, Vector3i a_p2)
 
 cCuboid (void)
 
void Clamp (const cCuboid &a_Limits)
 Clamps this cuboid, so that it doesn't reach outside of a_Limits in any direction. More...
 
void ClampSize (Vector3i a_MaxSize)
 Clamps this cuboid's p2 so that the cuboid's size doesn't exceed the specified max size. More...
 
void ClampX (int a_MinX, int a_MaxX)
 Clamps both X coords to the specified range. More...
 
void ClampY (int a_MinY, int a_MaxY)
 Clamps both Y coords to the specified range. More...
 
void ClampZ (int a_MinZ, int a_MaxZ)
 Clamps both Z coords to the specified range. More...
 
int DifX (void) const
 
int DifY (void) const
 
int DifZ (void) const
 
bool DoesIntersect (const cCuboid &a_Other) const
 Returns true if the cuboids have at least one voxel in common. More...
 
void Engulf (Vector3i a_Point)
 If needed, expands the cuboid so that it contains the specified point. More...
 
void Expand (int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ)
 Expands the cuboid by the specified amount in each direction. More...
 
int GetVolume (void) const
 Returns the volume of the cuboid, in blocks. More...
 
bool IsCompletelyInside (const cCuboid &a_Outer) const
 Returns true if this cuboid is completely inside the specified cuboid (in all 6 coords). More...
 
bool IsInside (Vector3d v) const
 
bool IsInside (Vector3i v) const
 
bool IsSorted (void) const
 Returns true if the coords are properly sorted (lesser in p1, greater in p2) More...
 
void Move (Vector3i a_Offset)
 Moves the cuboid by the specified offset. More...
 
bool operator!= (const cCuboid &aOther) const
 
bool operator== (const cCuboid &aOther) const
 Checks the two cuboids for equality. More...
 
void Sort (void)
 

Public Attributes

Vector3i p1
 
Vector3i p2
 

Static Private Member Functions

static bool DoIntervalsIntersect (int a_Min1, int a_Max1, int a_Min2, int a_Max2)
 Returns true if the two specified intervals have a non-empty union. More...
 

Detailed Description

Definition at line 9 of file Cuboid.h.

Constructor & Destructor Documentation

◆ cCuboid() [1/3]

cCuboid::cCuboid ( void  )
inline

Definition at line 15 of file Cuboid.h.

◆ cCuboid() [2/3]

cCuboid::cCuboid ( Vector3i  a_p1,
Vector3i  a_p2 
)
inline

Definition at line 16 of file Cuboid.h.

◆ cCuboid() [3/3]

cCuboid::cCuboid ( int  a_X1,
int  a_Y1,
int  a_Z1 
)
inline

Definition at line 17 of file Cuboid.h.

Member Function Documentation

◆ Assign() [1/2]

void cCuboid::Assign ( const cCuboid a_SrcCuboid)
inline

Definition at line 27 of file Cuboid.h.

◆ Assign() [2/2]

void cCuboid::Assign ( Vector3i  a_Point1,
Vector3i  a_Point2 
)

Definition at line 13 of file Cuboid.cpp.

◆ Clamp()

void cCuboid::Clamp ( const cCuboid a_Limits)

Clamps this cuboid, so that it doesn't reach outside of a_Limits in any direction.

Assumes both this and a_Limits are sorted.

Definition at line 124 of file Cuboid.cpp.

◆ ClampSize()

void cCuboid::ClampSize ( Vector3i  a_MaxSize)

Clamps this cuboid's p2 so that the cuboid's size doesn't exceed the specified max size.

Assumes this cuboid is sorted.

Definition at line 141 of file Cuboid.cpp.

◆ ClampX()

void cCuboid::ClampX ( int  a_MinX,
int  a_MaxX 
)

Clamps both X coords to the specified range.

Works on unsorted cuboids, too.

Definition at line 163 of file Cuboid.cpp.

◆ ClampY()

void cCuboid::ClampY ( int  a_MinY,
int  a_MaxY 
)

Clamps both Y coords to the specified range.

Works on unsorted cuboids, too.

Definition at line 173 of file Cuboid.cpp.

◆ ClampZ()

void cCuboid::ClampZ ( int  a_MinZ,
int  a_MaxZ 
)

Clamps both Z coords to the specified range.

Works on unsorted cuboids, too.

Definition at line 183 of file Cuboid.cpp.

◆ DifX()

int cCuboid::DifX ( void  ) const
inline

Definition at line 33 of file Cuboid.h.

◆ DifY()

int cCuboid::DifY ( void  ) const
inline

Definition at line 34 of file Cuboid.h.

◆ DifZ()

int cCuboid::DifZ ( void  ) const
inline

Definition at line 35 of file Cuboid.h.

◆ DoesIntersect()

bool cCuboid::DoesIntersect ( const cCuboid a_Other) const
inline

Returns true if the cuboids have at least one voxel in common.

Both coords are considered inclusive. Assumes both cuboids are sorted.

Definition at line 44 of file Cuboid.h.

◆ DoIntervalsIntersect()

static bool cCuboid::DoIntervalsIntersect ( int  a_Min1,
int  a_Max1,
int  a_Min2,
int  a_Max2 
)
inlinestaticprivate

Returns true if the two specified intervals have a non-empty union.

Definition at line 146 of file Cuboid.h.

◆ Engulf()

void cCuboid::Engulf ( Vector3i  a_Point)

If needed, expands the cuboid so that it contains the specified point.

Assumes sorted. Doesn't contract.

Definition at line 206 of file Cuboid.cpp.

◆ Expand()

void cCuboid::Expand ( int  a_SubMinX,
int  a_AddMaxX,
int  a_SubMinY,
int  a_AddMaxY,
int  a_SubMinZ,
int  a_AddMaxZ 
)

Expands the cuboid by the specified amount in each direction.

Works on unsorted cuboids as well. Note that this function doesn't check for underflows when using negative amounts.

Definition at line 84 of file Cuboid.cpp.

◆ GetVolume()

int cCuboid::GetVolume ( void  ) const

Returns the volume of the cuboid, in blocks.

Note that the volume considers both coords inclusive. Works on unsorted cuboids, too.

Definition at line 43 of file Cuboid.cpp.

◆ IsCompletelyInside()

bool cCuboid::IsCompletelyInside ( const cCuboid a_Outer) const

Returns true if this cuboid is completely inside the specified cuboid (in all 6 coords).

Assumes both cuboids are sorted.

Definition at line 55 of file Cuboid.cpp.

◆ IsInside() [1/2]

bool cCuboid::IsInside ( Vector3d  v) const
inline

Definition at line 69 of file Cuboid.h.

◆ IsInside() [2/2]

bool cCuboid::IsInside ( Vector3i  v) const
inline

Definition at line 60 of file Cuboid.h.

◆ IsSorted()

bool cCuboid::IsSorted ( void  ) const

Returns true if the coords are properly sorted (lesser in p1, greater in p2)

Definition at line 193 of file Cuboid.cpp.

◆ Move()

void cCuboid::Move ( Vector3i  a_Offset)

Moves the cuboid by the specified offset.

Exported in ManualBindings to support the old deprecated coord-based overload.

Definition at line 74 of file Cuboid.cpp.

◆ operator!=()

bool cCuboid::operator!= ( const cCuboid aOther) const
inline

Definition at line 135 of file Cuboid.h.

◆ operator==()

bool cCuboid::operator== ( const cCuboid aOther) const
inline

Checks the two cuboids for equality.

Definition at line 123 of file Cuboid.h.

◆ Sort()

void cCuboid::Sort ( void  )

Definition at line 23 of file Cuboid.cpp.

Member Data Documentation

◆ p1

Vector3i cCuboid::p1

Definition at line 13 of file Cuboid.h.

◆ p2

Vector3i cCuboid::p2

Definition at line 13 of file Cuboid.h.


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