Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
CCmpObstructionManager Class Referencefinal
Inheritance diagram for CCmpObstructionManager:
Collaboration diagram for CCmpObstructionManager:

Public Member Functions

int GetComponentTypeId () const override
 
void Init (const CParamNode &paramNode) override
 
void Deinit () override
 
template<typename S >
void SerializeCommon (S &serialize)
 
void Serialize (ISerializer &serialize) override
 
void Deserialize (const CParamNode &paramNode, IDeserializer &deserialize) override
 
void HandleMessage (const CMessage &msg, bool global) override
 
void SetBounds (entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1) override
 Set the bounds of the world. More...
 
void ResetSubdivisions (entity_pos_t x1, entity_pos_t z1)
 
tag_t AddUnitShape (entity_id_t ent, entity_pos_t x, entity_pos_t z, entity_pos_t clearance, flags_t flags, entity_id_t group) override
 Register a unit shape. More...
 
tag_t AddStaticShape (entity_id_t ent, entity_pos_t x, entity_pos_t z, entity_angle_t a, entity_pos_t w, entity_pos_t h, flags_t flags, entity_id_t group, entity_id_t group2) override
 Register a static shape. More...
 
ObstructionSquare GetUnitShapeObstruction (entity_pos_t x, entity_pos_t z, entity_pos_t clearance) const override
 
ObstructionSquare GetStaticShapeObstruction (entity_pos_t x, entity_pos_t z, entity_angle_t a, entity_pos_t w, entity_pos_t h) const override
 
void MoveShape (tag_t tag, entity_pos_t x, entity_pos_t z, entity_angle_t a) override
 Adjust the position and angle of an existing shape. More...
 
void SetUnitMovingFlag (tag_t tag, bool moving) override
 Set whether a unit shape is moving or stationary. More...
 
void SetUnitControlGroup (tag_t tag, entity_id_t group) override
 Set the control group of a unit shape. More...
 
void SetStaticControlGroup (tag_t tag, entity_id_t group, entity_id_t group2) override
 Sets the control group of a static shape. More...
 
void RemoveShape (tag_t tag) override
 Remove an existing shape. More...
 
ObstructionSquare GetObstruction (tag_t tag) const override
 Get the obstruction square representing the given shape. More...
 
fixed DistanceToPoint (entity_id_t ent, entity_pos_t px, entity_pos_t pz) const override
 DistanceTo function family, all end up in calculating a vector length, DistanceBetweenShapes or MaxDistanceBetweenShapes. More...
 
fixed MaxDistanceToPoint (entity_id_t ent, entity_pos_t px, entity_pos_t pz) const override
 Calculate the largest straight line distance between the entity and the point. More...
 
fixed DistanceToTarget (entity_id_t ent, entity_id_t target) const override
 Calculate the shortest distance between the entity and the target. More...
 
fixed MaxDistanceToTarget (entity_id_t ent, entity_id_t target) const override
 Calculate the largest straight line distance between the entity and the target. More...
 
fixed DistanceBetweenShapes (const ObstructionSquare &source, const ObstructionSquare &target) const override
 Calculate the shortest straight line distance between the source and the target. More...
 
fixed MaxDistanceBetweenShapes (const ObstructionSquare &source, const ObstructionSquare &target) const override
 Calculate the largest straight line distance between the source and the target. More...
 
bool IsInPointRange (entity_id_t ent, entity_pos_t px, entity_pos_t pz, entity_pos_t minRange, entity_pos_t maxRange, bool opposite) const override
 IsInRange function family depending on the DistanceTo family. More...
 
bool IsInTargetRange (entity_id_t ent, entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange, bool opposite) const override
 Check if the given entity is in range of the target given those parameters. More...
 
bool IsInTargetParabolicRange (entity_id_t ent, entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange, entity_pos_t yOrigin, bool opposite) const override
 Check if the given entity is in parabolic range of the target given those parameters. More...
 
bool IsPointInPointRange (entity_pos_t x, entity_pos_t z, entity_pos_t px, entity_pos_t pz, entity_pos_t minRange, entity_pos_t maxRange) const override
 Check if the given point is in range of the other point given those parameters. More...
 
bool AreShapesInRange (const ObstructionSquare &source, const ObstructionSquare &target, entity_pos_t minRange, entity_pos_t maxRange, bool opposite) const override
 Check if the given shape is in range of the target shape given those parameters. More...
 
bool TestLine (const IObstructionTestFilter &filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, entity_pos_t r, bool relaxClearanceForUnits=false) const override
 Collision test a flat-ended thick line against the current set of shapes. More...
 
bool TestStaticShape (const IObstructionTestFilter &filter, entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w, entity_pos_t h, std::vector< entity_id_t > *out) const override
 Collision test a static square shape against the current set of shapes. More...
 
bool TestUnitShape (const IObstructionTestFilter &filter, entity_pos_t x, entity_pos_t z, entity_pos_t r, std::vector< entity_id_t > *out) const override
 Collision test a unit shape against the current set of registered shapes, and optionally writes a list of the colliding shapes' entities to an output list. More...
 
void Rasterize (Grid< NavcellData > &grid, const std::vector< PathfinderPassability > &passClasses, bool fullUpdate) override
 Convert the current set of shapes onto a navcell grid, for all passability classes contained in passClasses. More...
 
void GetObstructionsInRange (const IObstructionTestFilter &filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, std::vector< ObstructionSquare > &squares) const override
 Find all the obstructions that are inside (or partially inside) the given range. More...
 
void GetUnitObstructionsInRange (const IObstructionTestFilter &filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, std::vector< ObstructionSquare > &squares) const override
 
void GetStaticObstructionsInRange (const IObstructionTestFilter &filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, std::vector< ObstructionSquare > &squares) const override
 
void GetUnitsOnObstruction (const ObstructionSquare &square, std::vector< entity_id_t > &out, const IObstructionTestFilter &filter, bool strict=false) const override
 Returns the entity IDs of all unit shapes that intersect the given obstruction square, filtering out using the given filter. More...
 
void GetStaticObstructionsOnObstruction (const ObstructionSquare &square, std::vector< entity_id_t > &out, const IObstructionTestFilter &filter) const override
 
void SetPassabilityCircular (bool enabled) override
 Set the passability to be restricted to a circular map. More...
 
bool GetPassabilityCircular () const override
 
void SetDebugOverlay (bool enabled) override
 Toggle the rendering of debug info. More...
 
void RenderSubmit (SceneCollector &collector)
 
void UpdateInformations (GridUpdateInformation &informations) override
 Gets dirtiness information and resets it afterwards. More...
 
virtual void SetBounds (entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1)=0
 Set the bounds of the world. More...
 
virtual tag_t AddStaticShape (entity_id_t ent, entity_pos_t x, entity_pos_t z, entity_angle_t a, entity_pos_t w, entity_pos_t h, flags_t flags, entity_id_t group, entity_id_t group2=INVALID_ENTITY)=0
 Register a static shape. More...
 
virtual tag_t AddUnitShape (entity_id_t ent, entity_pos_t x, entity_pos_t z, entity_pos_t clearance, flags_t flags, entity_id_t group)=0
 Register a unit shape. More...
 
virtual void MoveShape (tag_t tag, entity_pos_t x, entity_pos_t z, entity_angle_t a)=0
 Adjust the position and angle of an existing shape. More...
 
virtual void SetUnitMovingFlag (tag_t tag, bool moving)=0
 Set whether a unit shape is moving or stationary. More...
 
virtual void SetUnitControlGroup (tag_t tag, entity_id_t group)=0
 Set the control group of a unit shape. More...
 
virtual void SetStaticControlGroup (tag_t tag, entity_id_t group, entity_id_t group2)=0
 Sets the control group of a static shape. More...
 
virtual void RemoveShape (tag_t tag)=0
 Remove an existing shape. More...
 
virtual fixed DistanceToPoint (entity_id_t ent, entity_pos_t px, entity_pos_t pz) const =0
 Returns the distance from the obstruction to the point (px, pz), or -1 if the entity is out of the world. More...
 
virtual fixed MaxDistanceToPoint (entity_id_t ent, entity_pos_t px, entity_pos_t pz) const =0
 Calculate the largest straight line distance between the entity and the point. More...
 
virtual fixed DistanceToTarget (entity_id_t ent, entity_id_t target) const =0
 Calculate the shortest distance between the entity and the target. More...
 
virtual fixed MaxDistanceToTarget (entity_id_t ent, entity_id_t target) const =0
 Calculate the largest straight line distance between the entity and the target. More...
 
virtual fixed DistanceBetweenShapes (const ObstructionSquare &source, const ObstructionSquare &target) const =0
 Calculate the shortest straight line distance between the source and the target. More...
 
virtual fixed MaxDistanceBetweenShapes (const ObstructionSquare &source, const ObstructionSquare &target) const =0
 Calculate the largest straight line distance between the source and the target. More...
 
virtual bool IsInPointRange (entity_id_t ent, entity_pos_t px, entity_pos_t pz, entity_pos_t minRange, entity_pos_t maxRange, bool opposite) const =0
 Check if the given entity is in range of the other point given those parameters. More...
 
virtual bool IsInTargetRange (entity_id_t ent, entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange, bool opposite) const =0
 Check if the given entity is in range of the target given those parameters. More...
 
virtual bool IsInTargetParabolicRange (entity_id_t ent, entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange, entity_pos_t yOrigin, bool opposite) const =0
 Check if the given entity is in parabolic range of the target given those parameters. More...
 
virtual bool IsPointInPointRange (entity_pos_t x, entity_pos_t z, entity_pos_t px, entity_pos_t pz, entity_pos_t minRange, entity_pos_t maxRange) const =0
 Check if the given point is in range of the other point given those parameters. More...
 
virtual bool AreShapesInRange (const ObstructionSquare &source, const ObstructionSquare &target, entity_pos_t minRange, entity_pos_t maxRange, bool opposite) const =0
 Check if the given shape is in range of the target shape given those parameters. More...
 
virtual bool TestLine (const IObstructionTestFilter &filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, entity_pos_t r, bool relaxClearanceForUnits) const =0
 Collision test a flat-ended thick line against the current set of shapes. More...
 
virtual bool TestStaticShape (const IObstructionTestFilter &filter, entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w, entity_pos_t h, std::vector< entity_id_t > *out) const =0
 Collision test a static square shape against the current set of shapes. More...
 
virtual bool TestUnitShape (const IObstructionTestFilter &filter, entity_pos_t x, entity_pos_t z, entity_pos_t clearance, std::vector< entity_id_t > *out) const =0
 Collision test a unit shape against the current set of registered shapes, and optionally writes a list of the colliding shapes' entities to an output list. More...
 
virtual void Rasterize (Grid< NavcellData > &grid, const std::vector< PathfinderPassability > &passClasses, bool fullUpdate)=0
 Convert the current set of shapes onto a navcell grid, for all passability classes contained in passClasses. More...
 
virtual void UpdateInformations (GridUpdateInformation &informations)=0
 Gets dirtiness information and resets it afterwards. More...
 
virtual void GetObstructionsInRange (const IObstructionTestFilter &filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, std::vector< ObstructionSquare > &squares) const =0
 Find all the obstructions that are inside (or partially inside) the given range. More...
 
virtual void GetStaticObstructionsInRange (const IObstructionTestFilter &filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, std::vector< ObstructionSquare > &squares) const =0
 
virtual void GetUnitObstructionsInRange (const IObstructionTestFilter &filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, std::vector< ObstructionSquare > &squares) const =0
 
virtual void GetStaticObstructionsOnObstruction (const ObstructionSquare &square, std::vector< entity_id_t > &out, const IObstructionTestFilter &filter) const =0
 
virtual void GetUnitsOnObstruction (const ObstructionSquare &square, std::vector< entity_id_t > &out, const IObstructionTestFilter &filter, bool strict=false) const =0
 Returns the entity IDs of all unit shapes that intersect the given obstruction square, filtering out using the given filter. More...
 
virtual ObstructionSquare GetObstruction (tag_t tag) const =0
 Get the obstruction square representing the given shape. More...
 
virtual ObstructionSquare GetUnitShapeObstruction (entity_pos_t x, entity_pos_t z, entity_pos_t clearance) const =0
 
virtual ObstructionSquare GetStaticShapeObstruction (entity_pos_t x, entity_pos_t z, entity_angle_t a, entity_pos_t w, entity_pos_t h) const =0
 
virtual void SetPassabilityCircular (bool enabled)=0
 Set the passability to be restricted to a circular map. More...
 
virtual bool GetPassabilityCircular () const =0
 
virtual void SetDebugOverlay (bool enabled)=0
 Toggle the rendering of debug info. More...
 
- Public Member Functions inherited from IComponent
virtual ~IComponent ()
 
virtual void Init (const CParamNode &paramNode)=0
 
virtual void Deinit ()=0
 
virtual void HandleMessage (const CMessage &msg, bool global)
 
CEntityHandle GetEntityHandle () const
 
void SetEntityHandle (CEntityHandle ent)
 
entity_id_t GetEntityId () const
 
CEntityHandle GetSystemEntity () const
 
const CSimContextGetSimContext () const
 
void SetSimContext (const CSimContext &context)
 
virtual void Serialize (ISerializer &serialize)=0
 
virtual void Deserialize (const CParamNode &paramNode, IDeserializer &deserialize)=0
 
virtual bool NewJSObject (const ScriptInterface &scriptInterface, JS::MutableHandleObject out) const
 Returns false by default, indicating that a scripted wrapper of this IComponent is not supported. More...
 
virtual JS::Value GetJSInstance () const
 
virtual int GetComponentTypeId () const =0
 

Static Public Member Functions

static void ClassInit (CComponentManager &componentManager)
 
static IComponentAllocate (const ScriptInterface &, JS::HandleValue)
 
static void Deallocate (IComponent *cmp)
 
static std::string GetSchema ()
 
- Static Public Member Functions inherited from IComponent
static std::string GetSchema ()
 
static void RegisterComponentType (CComponentManager &mgr, EInterfaceId iid, EComponentTypeId cid, AllocFunc alloc, DeallocFunc dealloc, const char *name, const std::string &schema)
 
static void RegisterComponentTypeScriptWrapper (CComponentManager &mgr, EInterfaceId iid, EComponentTypeId cid, AllocFunc alloc, DeallocFunc dealloc, const char *name, const std::string &schema)
 
static u8 GetSerializationVersion ()
 

Public Attributes

bool m_DebugOverlayEnabled
 
bool m_DebugOverlayDirty
 
std::vector< SOverlayLinem_DebugOverlayLines
 
SpatialSubdivision m_UnitSubdivision
 
SpatialSubdivision m_StaticSubdivision
 
std::map< u32, UnitShape > m_UnitShapes
 
std::map< u32, StaticShape > m_StaticShapes
 
u32 m_UnitShapeNext
 
u32 m_StaticShapeNext
 
entity_pos_t m_MaxClearance
 
bool m_PassabilityCircular
 
entity_pos_t m_WorldX0
 
entity_pos_t m_WorldZ0
 
entity_pos_t m_WorldX1
 
entity_pos_t m_WorldZ1
 

Private Member Functions

void MakeDirtyAll ()
 Mark all previous Rasterize()d grids as dirty, and the debug display. More...
 
void MakeDirtyDebug ()
 Mark the debug display as dirty. More...
 
void MarkDirtinessGrid (const entity_pos_t &x, const entity_pos_t &z, const entity_pos_t &r)
 
void MarkDirtinessGrid (const entity_pos_t &x, const entity_pos_t &z, const CFixedVector2D &hbox)
 
void MakeDirtyStatic (flags_t flags, u32 index, const StaticShape &shape)
 Mark all previous Rasterize()d grids as dirty, if they depend on this shape. More...
 
void MakeDirtyUnit (flags_t flags, u32 index, const UnitShape &shape)
 Mark all previous Rasterize()d grids as dirty, if they depend on this shape. More...
 
bool IsInWorld (entity_pos_t x, entity_pos_t z, entity_pos_t r) const
 Return whether the given point is within the world bounds by at least r. More...
 
bool IsInWorld (const CFixedVector2D &p) const
 Return whether the given point is within the world bounds. More...
 
void RasterizeHelper (Grid< NavcellData > &grid, ICmpObstructionManager::flags_t requireMask, bool fullUpdate, pass_class_t appliedMask, entity_pos_t clearance=fixed::Zero()) const
 

Private Attributes

GridUpdateInformation m_UpdateInformations
 
std::vector< u32m_DirtyStaticShapes
 
std::vector< u32m_DirtyUnitShapes
 

Additional Inherited Members

- Public Types inherited from ICmpObstructionManager
enum  EFlags {
  FLAG_BLOCK_MOVEMENT = (1 << 0) , FLAG_BLOCK_FOUNDATION = (1 << 1) , FLAG_BLOCK_CONSTRUCTION = (1 << 2) , FLAG_BLOCK_PATHFINDING = (1 << 3) ,
  FLAG_MOVING = (1 << 4) , FLAG_DELETE_UPON_CONSTRUCTION = (1 << 5)
}
 Boolean flags affecting the obstruction behaviour of a shape. More...
 
typedef u8 flags_t
 Bitmask of EFlag values. More...
 
- Public Types inherited from IComponent
using AllocFunc = IComponent *(*)(const ScriptInterface &scriptInterface, JS::HandleValue ctor)
 
using DeallocFunc = void(*)(IComponent *)
 

Member Function Documentation

◆ AddStaticShape()

tag_t CCmpObstructionManager::AddStaticShape ( entity_id_t  ent,
entity_pos_t  x,
entity_pos_t  z,
entity_angle_t  a,
entity_pos_t  w,
entity_pos_t  h,
flags_t  flags,
entity_id_t  group,
entity_id_t  group2 
)
inlineoverridevirtual

Register a static shape.

Parameters
ententity ID associated with this shape (or INVALID_ENTITY if none)
x,zcoordinates of center, in world space
aangle of rotation (clockwise from +Z direction)
wwidth (size along X axis)
hheight (size along Z axis)
flagsa set of EFlags values
groupprimary control group of the shape. Must be a valid control group ID.
group2Optional; secondary control group of the shape. Defaults to INVALID_ENTITY.
Returns
a valid tag for manipulating the shape
See also
StaticShape

Implements ICmpObstructionManager.

◆ AddUnitShape()

tag_t CCmpObstructionManager::AddUnitShape ( entity_id_t  ent,
entity_pos_t  x,
entity_pos_t  z,
entity_pos_t  clearance,
flags_t  flags,
entity_id_t  group 
)
inlineoverridevirtual

Register a unit shape.

Parameters
ententity ID associated with this shape (or INVALID_ENTITY if none)
x,zcoordinates of center, in world space
clearancepathfinding clearance of the unit (works as a radius)
flagsa set of EFlags values
groupcontrol group (typically the owner entity, or a formation controller entity
  • units ignore collisions with others in the same group)
Returns
a valid tag for manipulating the shape
See also
UnitShape

Implements ICmpObstructionManager.

◆ Allocate()

static IComponent * CCmpObstructionManager::Allocate ( const ScriptInterface ,
JS::HandleValue   
)
inlinestatic

◆ AreShapesInRange()

bool CCmpObstructionManager::AreShapesInRange ( const ObstructionSquare source,
const ObstructionSquare target,
entity_pos_t  minRange,
entity_pos_t  maxRange,
bool  opposite 
) const
overridevirtual

Check if the given shape is in range of the target shape given those parameters.

Parameters
maxRange- Can be a nonnegative decimal, ALWAYS_IN_RANGE or NEVER_IN_RANGE.

Implements ICmpObstructionManager.

◆ ClassInit()

static void CCmpObstructionManager::ClassInit ( CComponentManager componentManager)
inlinestatic

◆ Deallocate()

static void CCmpObstructionManager::Deallocate ( IComponent cmp)
inlinestatic

◆ Deinit()

void CCmpObstructionManager::Deinit ( )
inlineoverridevirtual

Implements IComponent.

◆ Deserialize()

void CCmpObstructionManager::Deserialize ( const CParamNode paramNode,
IDeserializer deserialize 
)
inlineoverridevirtual

Implements IComponent.

◆ DistanceBetweenShapes()

fixed CCmpObstructionManager::DistanceBetweenShapes ( const ObstructionSquare source,
const ObstructionSquare target 
) const
overridevirtual

Calculate the shortest straight line distance between the source and the target.

Implements ICmpObstructionManager.

◆ DistanceToPoint()

fixed CCmpObstructionManager::DistanceToPoint ( entity_id_t  ent,
entity_pos_t  px,
entity_pos_t  pz 
) const
overridevirtual

DistanceTo function family, all end up in calculating a vector length, DistanceBetweenShapes or MaxDistanceBetweenShapes.

The MaxFoo family calculates the opposite edge opposite edge distance. When the distance is undefined we return -1.

Implements ICmpObstructionManager.

◆ DistanceToTarget()

fixed CCmpObstructionManager::DistanceToTarget ( entity_id_t  ent,
entity_id_t  target 
) const
overridevirtual

Calculate the shortest distance between the entity and the target.

Implements ICmpObstructionManager.

◆ GetComponentTypeId()

int CCmpObstructionManager::GetComponentTypeId ( ) const
inlineoverridevirtual

Implements IComponent.

◆ GetObstruction()

ObstructionSquare CCmpObstructionManager::GetObstruction ( tag_t  tag) const
inlineoverridevirtual

Get the obstruction square representing the given shape.

Parameters
tagtag of shape (must be valid)

Implements ICmpObstructionManager.

◆ GetObstructionsInRange()

void CCmpObstructionManager::GetObstructionsInRange ( const IObstructionTestFilter filter,
entity_pos_t  x0,
entity_pos_t  z0,
entity_pos_t  x1,
entity_pos_t  z1,
std::vector< ObstructionSquare > &  squares 
) const
overridevirtual

Find all the obstructions that are inside (or partially inside) the given range.

Parameters
filterfilter to restrict the shapes that are counted
x0X coordinate of left edge of range
z0Z coordinate of bottom edge of range
x1X coordinate of right edge of range
z1Z coordinate of top edge of range
squaresoutput list of obstructions

Implements ICmpObstructionManager.

◆ GetPassabilityCircular()

bool CCmpObstructionManager::GetPassabilityCircular ( ) const
inlineoverridevirtual

◆ GetSchema()

static std::string CCmpObstructionManager::GetSchema ( )
inlinestatic

◆ GetStaticObstructionsInRange()

void CCmpObstructionManager::GetStaticObstructionsInRange ( const IObstructionTestFilter filter,
entity_pos_t  x0,
entity_pos_t  z0,
entity_pos_t  x1,
entity_pos_t  z1,
std::vector< ObstructionSquare > &  squares 
) const
overridevirtual

◆ GetStaticObstructionsOnObstruction()

void CCmpObstructionManager::GetStaticObstructionsOnObstruction ( const ObstructionSquare square,
std::vector< entity_id_t > &  out,
const IObstructionTestFilter filter 
) const
overridevirtual

◆ GetStaticShapeObstruction()

ObstructionSquare CCmpObstructionManager::GetStaticShapeObstruction ( entity_pos_t  x,
entity_pos_t  z,
entity_angle_t  a,
entity_pos_t  w,
entity_pos_t  h 
) const
inlineoverridevirtual

◆ GetUnitObstructionsInRange()

void CCmpObstructionManager::GetUnitObstructionsInRange ( const IObstructionTestFilter filter,
entity_pos_t  x0,
entity_pos_t  z0,
entity_pos_t  x1,
entity_pos_t  z1,
std::vector< ObstructionSquare > &  squares 
) const
overridevirtual

◆ GetUnitShapeObstruction()

ObstructionSquare CCmpObstructionManager::GetUnitShapeObstruction ( entity_pos_t  x,
entity_pos_t  z,
entity_pos_t  clearance 
) const
inlineoverridevirtual

◆ GetUnitsOnObstruction()

void CCmpObstructionManager::GetUnitsOnObstruction ( const ObstructionSquare square,
std::vector< entity_id_t > &  out,
const IObstructionTestFilter filter,
bool  strict = false 
) const
overridevirtual

Returns the entity IDs of all unit shapes that intersect the given obstruction square, filtering out using the given filter.

Parameters
squarethe Obstruction squre we want to compare with.
outoutput list of obstructions
filterfilter for the obstructing units
strictwhether to be strict in the check or more permissive (ie rasterize more or less). Default false.

Implements ICmpObstructionManager.

◆ HandleMessage()

void CCmpObstructionManager::HandleMessage ( const CMessage msg,
bool  global 
)
inlineoverridevirtual

Reimplemented from IComponent.

◆ Init()

void CCmpObstructionManager::Init ( const CParamNode paramNode)
inlineoverridevirtual

Implements IComponent.

◆ IsInPointRange()

bool CCmpObstructionManager::IsInPointRange ( entity_id_t  ent,
entity_pos_t  px,
entity_pos_t  pz,
entity_pos_t  minRange,
entity_pos_t  maxRange,
bool  opposite 
) const
overridevirtual

IsInRange function family depending on the DistanceTo family.

In range if the edge to edge distance is inferior to maxRange and if the opposite edge to opposite edge distance is greater than minRange when the opposite bool is true or when the opposite bool is false the edge to edge distance is more than minRange.

Using the opposite egde for minRange means that a unit is in range of a building if it is farther than clearance-buildingsize, which is generally going to be negative (and thus this returns true). NB: from a game POV, this means units can easily fire on buildings, which is good, but it also means that buildings can easily fire on units. Buildings are usually meant to fire from the edge, not the opposite edge, so this looks odd. For this reason one can choose to set the opposite bool false and use the edge to egde distance.

We don't use squares because the are likely to overflow. TODO Avoid the overflows and use squares instead. We use a 0.0001 margin to avoid rounding errors.

Implements ICmpObstructionManager.

◆ IsInTargetParabolicRange()

bool CCmpObstructionManager::IsInTargetParabolicRange ( entity_id_t  ent,
entity_id_t  target,
entity_pos_t  minRange,
entity_pos_t  maxRange,
entity_pos_t  yOrigin,
bool  opposite 
) const
overridevirtual

Check if the given entity is in parabolic range of the target given those parameters.

Parameters
maxRange- Can be a nonnegative decimal, ALWAYS_IN_RANGE or NEVER_IN_RANGE.

Implements ICmpObstructionManager.

◆ IsInTargetRange()

bool CCmpObstructionManager::IsInTargetRange ( entity_id_t  ent,
entity_id_t  target,
entity_pos_t  minRange,
entity_pos_t  maxRange,
bool  opposite 
) const
overridevirtual

Check if the given entity is in range of the target given those parameters.

Parameters
maxRange- Can be a nonnegative decimal, ALWAYS_IN_RANGE or NEVER_IN_RANGE.

Implements ICmpObstructionManager.

◆ IsInWorld() [1/2]

bool CCmpObstructionManager::IsInWorld ( const CFixedVector2D p) const
inlineprivate

Return whether the given point is within the world bounds.

◆ IsInWorld() [2/2]

bool CCmpObstructionManager::IsInWorld ( entity_pos_t  x,
entity_pos_t  z,
entity_pos_t  r 
) const
inlineprivate

Return whether the given point is within the world bounds by at least r.

◆ IsPointInPointRange()

bool CCmpObstructionManager::IsPointInPointRange ( entity_pos_t  x,
entity_pos_t  z,
entity_pos_t  px,
entity_pos_t  pz,
entity_pos_t  minRange,
entity_pos_t  maxRange 
) const
overridevirtual

Check if the given point is in range of the other point given those parameters.

Parameters
maxRange- Can be a nonnegative decimal, ALWAYS_IN_RANGE or NEVER_IN_RANGE.

Implements ICmpObstructionManager.

◆ MakeDirtyAll()

void CCmpObstructionManager::MakeDirtyAll ( )
inlineprivate

Mark all previous Rasterize()d grids as dirty, and the debug display.

Call this when the world bounds have changed.

◆ MakeDirtyDebug()

void CCmpObstructionManager::MakeDirtyDebug ( )
inlineprivate

Mark the debug display as dirty.

Call this when nothing has changed except a unit's 'moving' flag.

◆ MakeDirtyStatic()

void CCmpObstructionManager::MakeDirtyStatic ( flags_t  flags,
u32  index,
const StaticShape &  shape 
)
inlineprivate

Mark all previous Rasterize()d grids as dirty, if they depend on this shape.

Call this when a static shape has changed.

◆ MakeDirtyUnit()

void CCmpObstructionManager::MakeDirtyUnit ( flags_t  flags,
u32  index,
const UnitShape &  shape 
)
inlineprivate

Mark all previous Rasterize()d grids as dirty, if they depend on this shape.

Call this when a unit shape has changed.

◆ MarkDirtinessGrid() [1/2]

void CCmpObstructionManager::MarkDirtinessGrid ( const entity_pos_t x,
const entity_pos_t z,
const CFixedVector2D hbox 
)
inlineprivate

◆ MarkDirtinessGrid() [2/2]

void CCmpObstructionManager::MarkDirtinessGrid ( const entity_pos_t x,
const entity_pos_t z,
const entity_pos_t r 
)
inlineprivate

◆ MaxDistanceBetweenShapes()

fixed CCmpObstructionManager::MaxDistanceBetweenShapes ( const ObstructionSquare source,
const ObstructionSquare target 
) const
overridevirtual

Calculate the largest straight line distance between the source and the target.

Implements ICmpObstructionManager.

◆ MaxDistanceToPoint()

fixed CCmpObstructionManager::MaxDistanceToPoint ( entity_id_t  ent,
entity_pos_t  px,
entity_pos_t  pz 
) const
overridevirtual

Calculate the largest straight line distance between the entity and the point.

Implements ICmpObstructionManager.

◆ MaxDistanceToTarget()

fixed CCmpObstructionManager::MaxDistanceToTarget ( entity_id_t  ent,
entity_id_t  target 
) const
overridevirtual

Calculate the largest straight line distance between the entity and the target.

Implements ICmpObstructionManager.

◆ MoveShape()

void CCmpObstructionManager::MoveShape ( tag_t  tag,
entity_pos_t  x,
entity_pos_t  z,
entity_angle_t  a 
)
inlineoverridevirtual

Adjust the position and angle of an existing shape.

Parameters
tagtag of shape (must be valid)
xX coordinate of center, in world space
zZ coordinate of center, in world space
aangle of rotation (clockwise from +Z direction); ignored for unit shapes

Implements ICmpObstructionManager.

◆ Rasterize()

void CCmpObstructionManager::Rasterize ( Grid< NavcellData > &  grid,
const std::vector< PathfinderPassability > &  passClasses,
bool  fullUpdate 
)
overridevirtual

Convert the current set of shapes onto a navcell grid, for all passability classes contained in passClasses.

If fullUpdate is false, the function will only go through dirty shapes. Shapes are expanded by the passClasses clearances, by ORing their masks onto the grid.

Implements ICmpObstructionManager.

◆ RasterizeHelper()

void CCmpObstructionManager::RasterizeHelper ( Grid< NavcellData > &  grid,
ICmpObstructionManager::flags_t  requireMask,
bool  fullUpdate,
pass_class_t  appliedMask,
entity_pos_t  clearance = fixed::Zero() 
) const
private

◆ RemoveShape()

void CCmpObstructionManager::RemoveShape ( tag_t  tag)
inlineoverridevirtual

Remove an existing shape.

The tag will be made invalid and must not be used after this.

Parameters
tagtag of shape (must be valid)

Implements ICmpObstructionManager.

◆ RenderSubmit()

void CCmpObstructionManager::RenderSubmit ( SceneCollector collector)

◆ ResetSubdivisions()

void CCmpObstructionManager::ResetSubdivisions ( entity_pos_t  x1,
entity_pos_t  z1 
)
inline

◆ Serialize()

void CCmpObstructionManager::Serialize ( ISerializer serialize)
inlineoverridevirtual

Implements IComponent.

◆ SerializeCommon()

template<typename S >
void CCmpObstructionManager::SerializeCommon ( S &  serialize)
inline

◆ SetBounds()

void CCmpObstructionManager::SetBounds ( entity_pos_t  x0,
entity_pos_t  z0,
entity_pos_t  x1,
entity_pos_t  z1 
)
inlineoverridevirtual

Set the bounds of the world.

Any point outside the bounds is considered obstructed.

Parameters
x0,z0,x1,z1Coordinates of the corners of the world

Implements ICmpObstructionManager.

◆ SetDebugOverlay()

void CCmpObstructionManager::SetDebugOverlay ( bool  enabled)
inlineoverridevirtual

Toggle the rendering of debug info.

Implements ICmpObstructionManager.

◆ SetPassabilityCircular()

void CCmpObstructionManager::SetPassabilityCircular ( bool  enabled)
inlineoverridevirtual

Set the passability to be restricted to a circular map.

Implements ICmpObstructionManager.

◆ SetStaticControlGroup()

void CCmpObstructionManager::SetStaticControlGroup ( tag_t  tag,
entity_id_t  group,
entity_id_t  group2 
)
inlineoverridevirtual

Sets the control group of a static shape.

Parameters
tagTag of the shape to set the control group for. Must be a valid and static shape tag.
groupControl group entity ID.

Implements ICmpObstructionManager.

◆ SetUnitControlGroup()

void CCmpObstructionManager::SetUnitControlGroup ( tag_t  tag,
entity_id_t  group 
)
inlineoverridevirtual

Set the control group of a unit shape.

Parameters
tagtag of shape (must be valid and a unit shape)
groupcontrol group entity ID

Implements ICmpObstructionManager.

◆ SetUnitMovingFlag()

void CCmpObstructionManager::SetUnitMovingFlag ( tag_t  tag,
bool  moving 
)
inlineoverridevirtual

Set whether a unit shape is moving or stationary.

Parameters
tagtag of shape (must be valid and a unit shape)
movingwhether the unit is currently moving through the world or is stationary

Implements ICmpObstructionManager.

◆ TestLine()

bool CCmpObstructionManager::TestLine ( const IObstructionTestFilter filter,
entity_pos_t  x0,
entity_pos_t  z0,
entity_pos_t  x1,
entity_pos_t  z1,
entity_pos_t  r,
bool  relaxClearanceForUnits = false 
) const
overridevirtual

Collision test a flat-ended thick line against the current set of shapes.

The line caps extend by r beyond the end points. Only intersections going from outside to inside a shape are counted.

Parameters
filterfilter to restrict the shapes that are counted
x0X coordinate of line's first point
z0Z coordinate of line's first point
x1X coordinate of line's second point
z1Z coordinate of line's second point
rradius (half width) of line
relaxClearanceForUnitswhether unit-unit collisions should be more permissive.
Returns
true if there is a collision

Implements ICmpObstructionManager.

◆ TestStaticShape()

bool CCmpObstructionManager::TestStaticShape ( const IObstructionTestFilter filter,
entity_pos_t  x,
entity_pos_t  z,
entity_pos_t  a,
entity_pos_t  w,
entity_pos_t  h,
std::vector< entity_id_t > *  out 
) const
overridevirtual

Collision test a static square shape against the current set of shapes.

Parameters
filterfilter to restrict the shapes that are being tested against
xX coordinate of center
zZ coordinate of center
aangle of rotation (clockwise from +Z direction)
wwidth (size along X axis)
hheight (size along Z axis)
outif non-NULL, all colliding shapes' entities will be added to this list
Returns
true if there is a collision

Implements ICmpObstructionManager.

◆ TestUnitShape()

bool CCmpObstructionManager::TestUnitShape ( const IObstructionTestFilter filter,
entity_pos_t  x,
entity_pos_t  z,
entity_pos_t  clearance,
std::vector< entity_id_t > *  out 
) const
overridevirtual

Collision test a unit shape against the current set of registered shapes, and optionally writes a list of the colliding shapes' entities to an output list.

Parameters
filterfilter to restrict the shapes that are being tested against
xX coordinate of shape's center
zZ coordinate of shape's center
clearanceclearance of the shape's unit
outif non-NULL, all colliding shapes' entities will be added to this list
Returns
true if there is a collision

Implements ICmpObstructionManager.

◆ UpdateInformations()

void CCmpObstructionManager::UpdateInformations ( GridUpdateInformation informations)
inlineoverridevirtual

Gets dirtiness information and resets it afterwards.

Then it's the role of CCmpPathfinder to pass the information to other components if needed. (AIs, etc.) The return value is false if an update is unnecessary.

Implements ICmpObstructionManager.

Member Data Documentation

◆ m_DebugOverlayDirty

bool CCmpObstructionManager::m_DebugOverlayDirty

◆ m_DebugOverlayEnabled

bool CCmpObstructionManager::m_DebugOverlayEnabled

◆ m_DebugOverlayLines

std::vector<SOverlayLine> CCmpObstructionManager::m_DebugOverlayLines

◆ m_DirtyStaticShapes

std::vector<u32> CCmpObstructionManager::m_DirtyStaticShapes
private

◆ m_DirtyUnitShapes

std::vector<u32> CCmpObstructionManager::m_DirtyUnitShapes
private

◆ m_MaxClearance

entity_pos_t CCmpObstructionManager::m_MaxClearance

◆ m_PassabilityCircular

bool CCmpObstructionManager::m_PassabilityCircular

◆ m_StaticShapeNext

u32 CCmpObstructionManager::m_StaticShapeNext

◆ m_StaticShapes

std::map<u32, StaticShape> CCmpObstructionManager::m_StaticShapes

◆ m_StaticSubdivision

SpatialSubdivision CCmpObstructionManager::m_StaticSubdivision

◆ m_UnitShapeNext

u32 CCmpObstructionManager::m_UnitShapeNext

◆ m_UnitShapes

std::map<u32, UnitShape> CCmpObstructionManager::m_UnitShapes

◆ m_UnitSubdivision

SpatialSubdivision CCmpObstructionManager::m_UnitSubdivision

◆ m_UpdateInformations

GridUpdateInformation CCmpObstructionManager::m_UpdateInformations
private

◆ m_WorldX0

entity_pos_t CCmpObstructionManager::m_WorldX0

◆ m_WorldX1

entity_pos_t CCmpObstructionManager::m_WorldX1

◆ m_WorldZ0

entity_pos_t CCmpObstructionManager::m_WorldZ0

◆ m_WorldZ1

entity_pos_t CCmpObstructionManager::m_WorldZ1

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