Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
CCmpRallyPointRenderer Class Referencefinal

#include <CCmpRallyPointRenderer.h>

Inheritance diagram for CCmpRallyPointRenderer:
Collaboration diagram for CCmpRallyPointRenderer:

Public Member Functions

void Init (const CParamNode &paramNode) override
 
void Deinit () override
 
void Serialize (ISerializer &serialize) override
 
void Deserialize (const CParamNode &paramNode, IDeserializer &deserialize) override
 
void HandleMessage (const CMessage &msg, bool global) override
 
virtual void UpdateMessageSubscriptions ()
 
void AddPosition_wrapper (const CFixedVector2D &pos) override
 Add another position at which a marker should be displayed, connected to the previous one. More...
 
void SetPosition (const CFixedVector2D &pos) override
 Sets the position at which the rally point marker should be displayed. More...
 
void UpdatePosition (u32 rallyPointId, const CFixedVector2D &pos) override
 Updates the position of one given rally point marker. More...
 
void SetDisplayed (bool displayed) override
 Sets whether the rally point marker and line should be displayed. More...
 
void Reset () override
 Reset the positions of this rally point marker. More...
 
void UpdateColor () override
 Updates the line color. More...
 
bool IsSet () const override
 Returns true if at least one display rally point is set; i.e., if we have a point to render our marker/line at. More...
 
int GetComponentTypeId () const override
 
virtual void SetDisplayed (bool displayed)=0
 Sets whether the rally point marker and line should be displayed. More...
 
virtual void SetPosition (const CFixedVector2D &position)=0
 Sets the position at which the rally point marker should be displayed. More...
 
virtual void UpdatePosition (u32 rallyPointId, const CFixedVector2D &position)=0
 Updates the position of one given rally point marker. More...
 
virtual void AddPosition_wrapper (const CFixedVector2D &position)=0
 Add another position at which a marker should be displayed, connected to the previous one. More...
 
virtual void Reset ()=0
 Reset the positions of this rally point marker. More...
 
virtual bool IsSet () const =0
 Returns true if at least one display rally point is set. More...
 
virtual void UpdateColor ()=0
 Updates the line color. 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 std::string GetSchema ()
 
static void ClassInit (CComponentManager &componentManager)
 
static IComponentAllocate (const ScriptInterface &, JS::HandleValue)
 
static void Deallocate (IComponent *cmp)
 
- 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 ()
 

Protected Attributes

std::vector< CFixedVector2Dm_RallyPoints
 Display position of the rally points. More...
 
std::vector< std::vector< CVector2D > > m_Path
 Full path to the rally points as returned by the pathfinder, with some post-processing applied to reduce zig/zagging. More...
 
std::vector< std::vector< SVisibilitySegment > > m_VisibilitySegments
 Visibility segments of the rally point paths; splits the path into SoD/non-SoD segments. More...
 
bool m_Displayed
 Should we render the rally points and the path lines? (set from JS when e.g. More...
 
bool m_SmoothPath
 Smooth the path before rendering? More...
 
std::vector< entity_id_tm_MarkerEntityIds
 Entity IDs of the rally point markers. More...
 
size_t m_LastMarkerCount
 
player_id_t m_LastOwner
 Last seen owner of this entity (used to keep track of ownership changes). More...
 
std::wstring m_MarkerTemplate
 Template name of the rally point markers. More...
 
float m_LineThickness
 Marker connector line settings (loaded from XML) More...
 
CColor m_LineColor
 
CColor m_LineDashColor
 
SOverlayTexturedLine::LineCapType m_LineStartCapType
 
SOverlayTexturedLine::LineCapType m_LineEndCapType
 
std::wstring m_LineTexturePath
 
std::wstring m_LineTextureMaskPath
 
std::string m_LinePassabilityClass
 Pathfinder passability class to use for computing the (long-range) marker line path. More...
 
CTexturePtr m_Texture
 
CTexturePtr m_TextureMask
 
std::vector< std::vector< SOverlayTexturedLine > > m_TexturedOverlayLines
 Textured overlay lines to be used for rendering the marker line. More...
 
bool m_EnableDebugNodeOverlay
 Draw little overlay circles to indicate where the exact path points are. More...
 
std::vector< std::vector< SOverlayLine > > m_DebugNodeOverlays
 

Private Member Functions

void AddPosition (CFixedVector2D pos, bool recompute)
 Helper function for AddPosition_wrapper and SetPosition. More...
 
void UpdateLineColor ()
 Helper function to set the line color to its owner's color. More...
 
void UpdateMarkers ()
 Repositions the rally point markers; moves them outside of the world (ie. More...
 
void RecomputeAllRallyPointPaths ()
 Recomputes all the full paths from this entity to the rally point and from the rally point to the next, and does all the necessary post-processing to make them prettier. More...
 
void RecomputeRallyPointPath_wrapper (size_t index)
 Recomputes the full path for m_Path[ index], and does all the necessary post-processing to make it prettier. More...
 
void RecomputeRallyPointPath (size_t index, CmpPtr< ICmpPosition > &cmpPosition, CmpPtr< ICmpFootprint > &cmpFootprint, CmpPtr< ICmpPathfinder > cmpPathfinder)
 Recomputes the full path from this entity/the previous rally point to the next rally point, and does all the necessary post-processing to make it prettier. More...
 
void UpdateOverlayLines ()
 Checks for changes to the SoD to the previously saved state, and reconstructs the visibility segments and overlay lines to match if necessary. More...
 
void ConstructAllOverlayLines ()
 Sets up all overlay lines for rendering according to the current full path and visibility segments. More...
 
void ConstructOverlayLines (size_t index)
 Sets up the overlay lines for rendering according to the full path and visibility segments at index. More...
 
void GetClosestsEdgePointFrom (CFixedVector2D &result, CFixedVector2D &start, CmpPtr< ICmpPosition > cmpPosition, CmpPtr< ICmpFootprint > cmpFootprint) const
 Get the point on the footprint edge that's as close from "start" as possible. More...
 
void GetVisibilitySegments (std::vector< SVisibilitySegment > &out, size_t index) const
 Returns a list of indices of waypoints in the current path (m_Path[index]) where the LOS visibility changes, ordered from building/previous rally point to rally point. More...
 
void ReduceSegmentsByVisibility (std::vector< CVector2D > &coords, unsigned maxSegmentLinks=0, bool floating=true) const
 Simplifies the path by removing waypoints that lie between two points that are visible from one another. More...
 
void RenderSubmit (SceneCollector &collector, const CFrustum &frustum, bool culling)
 

Static Private Member Functions

static void MergeVisibilitySegments (std::vector< SVisibilitySegment > &segments)
 Helper function to GetVisibilitySegments, factored out for testing. More...
 

Additional Inherited Members

- Public Types inherited from IComponent
using AllocFunc = IComponent *(*)(const ScriptInterface &scriptInterface, JS::HandleValue ctor)
 
using DeallocFunc = void(*)(IComponent *)
 

Member Function Documentation

◆ AddPosition()

void CCmpRallyPointRenderer::AddPosition ( CFixedVector2D  pos,
bool  recompute 
)
private

Helper function for AddPosition_wrapper and SetPosition.

◆ AddPosition_wrapper()

void CCmpRallyPointRenderer::AddPosition_wrapper ( const CFixedVector2D position)
overridevirtual

Add another position at which a marker should be displayed, connected to the previous one.

Implements ICmpRallyPointRenderer.

◆ Allocate()

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

◆ ClassInit()

void CCmpRallyPointRenderer::ClassInit ( CComponentManager componentManager)
static

◆ ConstructAllOverlayLines()

void CCmpRallyPointRenderer::ConstructAllOverlayLines ( )
private

Sets up all overlay lines for rendering according to the current full path and visibility segments.

Splits the line into solid and dashed pieces (for the SoD). Should be called whenever the SoD has changed. If no full path is currently set, this method does nothing.

◆ ConstructOverlayLines()

void CCmpRallyPointRenderer::ConstructOverlayLines ( size_t  index)
private

Sets up the overlay lines for rendering according to the full path and visibility segments at index.

Splits the line into solid and dashed pieces (for the SoD). Should be called whenever the SoD of the path at index has changed.

◆ Deallocate()

static void CCmpRallyPointRenderer::Deallocate ( IComponent cmp)
inlinestatic

◆ Deinit()

void CCmpRallyPointRenderer::Deinit ( )
overridevirtual

Implements IComponent.

◆ Deserialize()

void CCmpRallyPointRenderer::Deserialize ( const CParamNode paramNode,
IDeserializer deserialize 
)
overridevirtual

Implements IComponent.

◆ GetClosestsEdgePointFrom()

void CCmpRallyPointRenderer::GetClosestsEdgePointFrom ( CFixedVector2D result,
CFixedVector2D start,
CmpPtr< ICmpPosition cmpPosition,
CmpPtr< ICmpFootprint cmpFootprint 
) const
private

Get the point on the footprint edge that's as close from "start" as possible.

◆ GetComponentTypeId()

int CCmpRallyPointRenderer::GetComponentTypeId ( ) const
inlineoverridevirtual

Implements IComponent.

◆ GetSchema()

std::string CCmpRallyPointRenderer::GetSchema ( )
static

◆ GetVisibilitySegments()

void CCmpRallyPointRenderer::GetVisibilitySegments ( std::vector< SVisibilitySegment > &  out,
size_t  index 
) const
private

Returns a list of indices of waypoints in the current path (m_Path[index]) where the LOS visibility changes, ordered from building/previous rally point to rally point.

Used to construct the overlay line segments and track changes to the SoD.

◆ HandleMessage()

void CCmpRallyPointRenderer::HandleMessage ( const CMessage msg,
bool  global 
)
overridevirtual

Reimplemented from IComponent.

◆ Init()

void CCmpRallyPointRenderer::Init ( const CParamNode paramNode)
overridevirtual

Implements IComponent.

◆ IsSet()

bool CCmpRallyPointRenderer::IsSet ( ) const
overridevirtual

Returns true if at least one display rally point is set; i.e., if we have a point to render our marker/line at.

Implements ICmpRallyPointRenderer.

◆ MergeVisibilitySegments()

void CCmpRallyPointRenderer::MergeVisibilitySegments ( std::vector< SVisibilitySegment > &  segments)
staticprivate

Helper function to GetVisibilitySegments, factored out for testing.

Merges single-point segments with its neighbouring segments. You should not have to call this method directly.

◆ RecomputeAllRallyPointPaths()

void CCmpRallyPointRenderer::RecomputeAllRallyPointPaths ( )
private

Recomputes all the full paths from this entity to the rally point and from the rally point to the next, and does all the necessary post-processing to make them prettier.

Should be called whenever all rally points' position changes.

◆ RecomputeRallyPointPath()

void CCmpRallyPointRenderer::RecomputeRallyPointPath ( size_t  index,
CmpPtr< ICmpPosition > &  cmpPosition,
CmpPtr< ICmpFootprint > &  cmpFootprint,
CmpPtr< ICmpPathfinder cmpPathfinder 
)
private

Recomputes the full path from this entity/the previous rally point to the next rally point, and does all the necessary post-processing to make it prettier.

This doesn't check if we have a valid position or if a rally point is set.

You shouldn't need to call this method directly.

◆ RecomputeRallyPointPath_wrapper()

void CCmpRallyPointRenderer::RecomputeRallyPointPath_wrapper ( size_t  index)
private

Recomputes the full path for m_Path[ index], and does all the necessary post-processing to make it prettier.

Should be called whenever either the starting position or the rally point's position changes.

◆ ReduceSegmentsByVisibility()

void CCmpRallyPointRenderer::ReduceSegmentsByVisibility ( std::vector< CVector2D > &  coords,
unsigned  maxSegmentLinks = 0,
bool  floating = true 
) const
private

Simplifies the path by removing waypoints that lie between two points that are visible from one another.

This is primarily intended to reduce some unnecessary curviness of the path; the pathfinder returns a mathematically (near-)optimal path, which will happily curve and bend to reduce costs. Visually, it doesn't make sense for a rally point path to curve and bend when it could just as well have gone in a straight line; that's why we have this, to make it look more natural.

coords array of path coordinates to simplify maxSegmentLinks if non-zero, indicates the maximum amount of consecutive node-to-node links that can be joined into a single link. If this value is set to e.g. 1, then no reductions will be performed. A value of 3 means that at most 3 consecutive node links will be joined into a single link. floating whether to consider nodes who are under the water level as floating on top of the water

◆ RenderSubmit()

void CCmpRallyPointRenderer::RenderSubmit ( SceneCollector collector,
const CFrustum frustum,
bool  culling 
)
private

◆ Reset()

void CCmpRallyPointRenderer::Reset ( )
overridevirtual

Reset the positions of this rally point marker.

Implements ICmpRallyPointRenderer.

◆ Serialize()

void CCmpRallyPointRenderer::Serialize ( ISerializer serialize)
overridevirtual

Implements IComponent.

◆ SetDisplayed()

void CCmpRallyPointRenderer::SetDisplayed ( bool  displayed)
overridevirtual

Sets whether the rally point marker and line should be displayed.

Implements ICmpRallyPointRenderer.

◆ SetPosition()

void CCmpRallyPointRenderer::SetPosition ( const CFixedVector2D position)
overridevirtual

Sets the position at which the rally point marker should be displayed.

Discards all previous positions

Implements ICmpRallyPointRenderer.

◆ UpdateColor()

void CCmpRallyPointRenderer::UpdateColor ( )
overridevirtual

Updates the line color.

Implements ICmpRallyPointRenderer.

◆ UpdateLineColor()

void CCmpRallyPointRenderer::UpdateLineColor ( )
private

Helper function to set the line color to its owner's color.

◆ UpdateMarkers()

void CCmpRallyPointRenderer::UpdateMarkers ( )
private

Repositions the rally point markers; moves them outside of the world (ie.

hides them), or positions them at the currently set rally points. Also updates the actor's variation according to the entity's current owning player's civilization.

Should be called whenever either the position of a rally point changes (including whether it is set or not), or the display flag changes, or the ownership of the entity changes.

◆ UpdateMessageSubscriptions()

void CCmpRallyPointRenderer::UpdateMessageSubscriptions ( )
virtual

◆ UpdateOverlayLines()

void CCmpRallyPointRenderer::UpdateOverlayLines ( )
private

Checks for changes to the SoD to the previously saved state, and reconstructs the visibility segments and overlay lines to match if necessary.

Does nothing if the rally point lines are not currently set to be displayed, or if no rally point is set.

◆ UpdatePosition()

void CCmpRallyPointRenderer::UpdatePosition ( u32  rallyPointId,
const CFixedVector2D position 
)
overridevirtual

Updates the position of one given rally point marker.

Implements ICmpRallyPointRenderer.

Member Data Documentation

◆ m_DebugNodeOverlays

std::vector<std::vector<SOverlayLine> > CCmpRallyPointRenderer::m_DebugNodeOverlays
protected

◆ m_Displayed

bool CCmpRallyPointRenderer::m_Displayed
protected

Should we render the rally points and the path lines? (set from JS when e.g.

the unit is selected/deselected)

◆ m_EnableDebugNodeOverlay

bool CCmpRallyPointRenderer::m_EnableDebugNodeOverlay
protected

Draw little overlay circles to indicate where the exact path points are.

◆ m_LastMarkerCount

size_t CCmpRallyPointRenderer::m_LastMarkerCount
protected

◆ m_LastOwner

player_id_t CCmpRallyPointRenderer::m_LastOwner
protected

Last seen owner of this entity (used to keep track of ownership changes).

◆ m_LineColor

CColor CCmpRallyPointRenderer::m_LineColor
protected

◆ m_LineDashColor

CColor CCmpRallyPointRenderer::m_LineDashColor
protected

◆ m_LineEndCapType

SOverlayTexturedLine::LineCapType CCmpRallyPointRenderer::m_LineEndCapType
protected

◆ m_LinePassabilityClass

std::string CCmpRallyPointRenderer::m_LinePassabilityClass
protected

Pathfinder passability class to use for computing the (long-range) marker line path.

◆ m_LineStartCapType

SOverlayTexturedLine::LineCapType CCmpRallyPointRenderer::m_LineStartCapType
protected

◆ m_LineTextureMaskPath

std::wstring CCmpRallyPointRenderer::m_LineTextureMaskPath
protected

◆ m_LineTexturePath

std::wstring CCmpRallyPointRenderer::m_LineTexturePath
protected

◆ m_LineThickness

float CCmpRallyPointRenderer::m_LineThickness
protected

Marker connector line settings (loaded from XML)

◆ m_MarkerEntityIds

std::vector<entity_id_t> CCmpRallyPointRenderer::m_MarkerEntityIds
protected

Entity IDs of the rally point markers.

◆ m_MarkerTemplate

std::wstring CCmpRallyPointRenderer::m_MarkerTemplate
protected

Template name of the rally point markers.

◆ m_Path

std::vector<std::vector<CVector2D> > CCmpRallyPointRenderer::m_Path
protected

Full path to the rally points as returned by the pathfinder, with some post-processing applied to reduce zig/zagging.

◆ m_RallyPoints

std::vector<CFixedVector2D> CCmpRallyPointRenderer::m_RallyPoints
protected

Display position of the rally points.

Note that this are merely the display positions; they not necessarily the same as the actual positions used in the simulation at any given time. In particular, we need this separate copy to support instantaneously rendering the rally point markers/lines when the user sets one in-game (instead of waiting until the network-synchronization code sets it on the RallyPoint component, which might take up to half a second).

◆ m_SmoothPath

bool CCmpRallyPointRenderer::m_SmoothPath
protected

Smooth the path before rendering?

◆ m_Texture

CTexturePtr CCmpRallyPointRenderer::m_Texture
protected

◆ m_TexturedOverlayLines

std::vector<std::vector<SOverlayTexturedLine> > CCmpRallyPointRenderer::m_TexturedOverlayLines
protected

Textured overlay lines to be used for rendering the marker line.

There can be multiple because we may need to render dashes for segments that are inside the SoD.

◆ m_TextureMask

CTexturePtr CCmpRallyPointRenderer::m_TextureMask
protected

◆ m_VisibilitySegments

std::vector<std::vector<SVisibilitySegment> > CCmpRallyPointRenderer::m_VisibilitySegments
protected

Visibility segments of the rally point paths; splits the path into SoD/non-SoD segments.


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