Pyrogenesis  trunk
Classes | Enumerations | Functions | Variables
anonymous_namespace{CCmpRangeManager.cpp} Namespace Reference

Classes

struct  EntityData
 
class  EntityDistanceOrdering
 Functor for sorting entities by distance from a source point. More...
 
struct  EntityParabolicRangeOutline
 
struct  Query
 Representation of a range query. More...
 

Enumerations

enum  FlagMasks {
  None = 0x00, Normal = 0x01, Injured = 0x02, AllQuery = Normal | Injured,
  InWorld = 0x08, RetainInFog = 0x10, RevealShore = 0x20, ScriptedVisibility = 0x40,
  SharedVision = 0x80
}
 Representation of an entity, with the data needed for queries. More...
 

Functions

u32 CalcOwnerMask (player_id_t owner)
 Convert an owner ID (-1 = unowned, 0 = gaia, 1..30 = players) into a 32-bit mask for quick set-membership tests. More...
 
u32 CalcPlayerLosMask (player_id_t player)
 Returns LOS mask for given player. More...
 
u32 CalcSharedLosMask (std::vector< player_id_t > players)
 Returns shared LOS mask for given list of players. More...
 
bool SetPlayerSharedDirtyVisibilityBit (u16 &mask, player_id_t player, bool enable)
 Add/remove a player to/from mask, which is a 1-bit mask representing a list of players. More...
 
LosVisibility GetPlayerVisibility (u32 visibilities, player_id_t player)
 Computes the 2-bit visibility for one player, given the total 32-bit visibilities. More...
 
bool IsVisibilityDirty (u16 dirty, player_id_t player)
 Test whether the visibility is dirty for a given LoS region and a given player. More...
 
bool HasVisionSharing (u16 visionSharing, player_id_t player)
 Test whether a player share this vision. More...
 
u16 CalcVisionSharingMask (player_id_t player)
 Computes the shared vision mask for the player. More...
 
static bool InParabolicRange (CFixedVector3D v, fixed range)
 Checks whether v is in a parabolic range of (0,0,0) The highest point of the paraboloid is (0,range/2,0) and the circle of distance 'range' around (0,0,0) on height y=0 is part of the paraboloid This equates to computing f(x, z) = y = -(xx + zz)/(2*range) + range/2 > 0, or alternatively sqrt(xx+zz) <= sqrt(range^2 - 2range*y). More...
 

Variables

constexpr int LOS_REGION_RATIO = 8
 How many LOS vertices to have per region. More...
 
const fixed PARABOLIC_RANGE_TOLERANCE = fixed::FromInt(1)/2
 Tolerance for parabolic range calculations. More...
 
static std::map< entity_id_t, EntityParabolicRangeOutlineParabolicRangesOutlines
 

Enumeration Type Documentation

◆ FlagMasks

enum anonymous_namespace{CCmpRangeManager.cpp}::FlagMasks

Representation of an entity, with the data needed for queries.

Enumerator
None 
Normal 
Injured 
AllQuery 
InWorld 
RetainInFog 
RevealShore 
ScriptedVisibility 
SharedVision 

Function Documentation

◆ CalcOwnerMask()

u32 anonymous_namespace{CCmpRangeManager.cpp}::CalcOwnerMask ( player_id_t  owner)

Convert an owner ID (-1 = unowned, 0 = gaia, 1..30 = players) into a 32-bit mask for quick set-membership tests.

◆ CalcPlayerLosMask()

u32 anonymous_namespace{CCmpRangeManager.cpp}::CalcPlayerLosMask ( player_id_t  player)

Returns LOS mask for given player.

◆ CalcSharedLosMask()

u32 anonymous_namespace{CCmpRangeManager.cpp}::CalcSharedLosMask ( std::vector< player_id_t players)

Returns shared LOS mask for given list of players.

◆ CalcVisionSharingMask()

u16 anonymous_namespace{CCmpRangeManager.cpp}::CalcVisionSharingMask ( player_id_t  player)

Computes the shared vision mask for the player.

◆ GetPlayerVisibility()

LosVisibility anonymous_namespace{CCmpRangeManager.cpp}::GetPlayerVisibility ( u32  visibilities,
player_id_t  player 
)

Computes the 2-bit visibility for one player, given the total 32-bit visibilities.

◆ HasVisionSharing()

bool anonymous_namespace{CCmpRangeManager.cpp}::HasVisionSharing ( u16  visionSharing,
player_id_t  player 
)

Test whether a player share this vision.

◆ InParabolicRange()

static bool anonymous_namespace{CCmpRangeManager.cpp}::InParabolicRange ( CFixedVector3D  v,
fixed  range 
)
static

Checks whether v is in a parabolic range of (0,0,0) The highest point of the paraboloid is (0,range/2,0) and the circle of distance 'range' around (0,0,0) on height y=0 is part of the paraboloid This equates to computing f(x, z) = y = -(xx + zz)/(2*range) + range/2 > 0, or alternatively sqrt(xx+zz) <= sqrt(range^2 - 2range*y).

Avoids sqrting and overflowing.

◆ IsVisibilityDirty()

bool anonymous_namespace{CCmpRangeManager.cpp}::IsVisibilityDirty ( u16  dirty,
player_id_t  player 
)

Test whether the visibility is dirty for a given LoS region and a given player.

◆ SetPlayerSharedDirtyVisibilityBit()

bool anonymous_namespace{CCmpRangeManager.cpp}::SetPlayerSharedDirtyVisibilityBit ( u16 mask,
player_id_t  player,
bool  enable 
)

Add/remove a player to/from mask, which is a 1-bit mask representing a list of players.

Returns true if the mask is modified.

Variable Documentation

◆ LOS_REGION_RATIO

constexpr int anonymous_namespace{CCmpRangeManager.cpp}::LOS_REGION_RATIO = 8

How many LOS vertices to have per region.

LOS regions are used to keep track of units.

◆ PARABOLIC_RANGE_TOLERANCE

const fixed anonymous_namespace{CCmpRangeManager.cpp}::PARABOLIC_RANGE_TOLERANCE = fixed::FromInt(1)/2

Tolerance for parabolic range calculations.

TODO C++20: change this to constexpr by fixing CFixed with std::is_constant_evaluated

◆ ParabolicRangesOutlines

std::map<entity_id_t, EntityParabolicRangeOutline> anonymous_namespace{CCmpRangeManager.cpp}::ParabolicRangesOutlines
static