Pyrogenesis  trunk
Public Member Functions | Static Public Member Functions | Protected Attributes | Private Types | Private Member Functions | Static Private Member Functions | List of all members
CCmpRallyPointRenderer Class Reference
Inheritance diagram for CCmpRallyPointRenderer:
Inheritance graph
[legend]
Collaboration diagram for CCmpRallyPointRenderer:
Collaboration graph
[legend]

Public Member Functions

virtual int GetComponentTypeId () const
 
virtual void Init (const CParamNode &paramNode)
 
virtual void Deinit ()
 
virtual void Serialize (ISerializer &serialize)
 
virtual void Deserialize (const CParamNode &paramNode, IDeserializer &deserialize)
 
virtual void HandleMessage (const CMessage &msg, bool global)
 
void UpdateMessageSubscriptions ()
 
virtual void AddPosition_wrapper (const CFixedVector2D &pos)
 Add another position at which a marker should be displayed, connected to the previous one. More...
 
virtual void SetPosition (const CFixedVector2D &pos)
 Sets the position at which the rally point marker should be displayed. More...
 
virtual void UpdatePosition (u32 rallyPointId, const CFixedVector2D &pos)
 Updates the position of one given rally point marker. More...
 
virtual void SetDisplayed (bool displayed)
 Sets whether the rally point marker and line should be displayed. More...
 
virtual void Reset ()
 Reset the positions of this rally point marker. More...
 
bool IsSet () const
 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...
 
- Public Member Functions inherited from IComponent
virtual ~IComponent ()
 
CEntityHandle GetEntityHandle () const
 
void SetEntityHandle (CEntityHandle ent)
 
entity_id_t GetEntityId () const
 
CEntityHandle GetSystemEntity () const
 
const CSimContextGetSimContext () const
 
void SetSimContext (const CSimContext &context)
 
virtual bool NewJSObject (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
 

Static Public Member Functions

static void ClassInit (CComponentManager &componentManager)
 
static IComponentAllocate (ScriptInterface &, JS::HandleValue)
 
static void Deallocate (IComponent *cmp)
 
static std::string GetSchema ()
 
- Static Public Member Functions inherited from IComponent
static std::string GetSchema ()
 
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::deque< std::deque< 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. the unit is selected/deselected) 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
 
LineCapType m_LineStartCapType
 
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 Types

typedef WaypointPath Path
 
typedef PathGoal Goal
 
typedef ICmpRangeManager::CLosQuerier CLosQuerier
 
typedef SOverlayTexturedLine::LineCapType LineCapType
 

Private Member Functions

void AddPosition (CFixedVector2D pos, bool recompute)
 Helper function for AddPosition_wrapper and SetPosition. 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 FixFootprintWaypoints (std::vector< CVector2D > &coords, CmpPtr< ICmpPosition > cmpPosition, CmpPtr< ICmpFootprint > cmpFootprint) const
 Removes points from coords that are obstructed by the originating building's footprint, and links up the last point nicely to the edge of the building's footprint. 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::deque< 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)
 

Static Private Member Functions

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

Member Typedef Documentation

Member Function Documentation

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

Helper function for AddPosition_wrapper and SetPosition.

virtual void CCmpRallyPointRenderer::AddPosition_wrapper ( const CFixedVector2D position)
inlinevirtual

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

Implements ICmpRallyPointRenderer.

static IComponent* CCmpRallyPointRenderer::Allocate ( ScriptInterface ,
JS::HandleValue   
)
inlinestatic
static void CCmpRallyPointRenderer::ClassInit ( CComponentManager componentManager)
inlinestatic
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.

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.

static void CCmpRallyPointRenderer::Deallocate ( IComponent cmp)
inlinestatic
virtual void CCmpRallyPointRenderer::Deinit ( )
inlinevirtual

Implements IComponent.

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

Implements IComponent.

void CCmpRallyPointRenderer::FixFootprintWaypoints ( std::vector< CVector2D > &  coords,
CmpPtr< ICmpPosition cmpPosition,
CmpPtr< ICmpFootprint cmpFootprint 
) const
private

Removes points from coords that are obstructed by the originating building's footprint, and links up the last point nicely to the edge of the building's footprint.

Only needed if the pathfinder can possibly return obstructed tile waypoints, i.e. when pathfinding is started from an obstructed tile.

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.

virtual int CCmpRallyPointRenderer::GetComponentTypeId ( ) const
inlinevirtual

Implements IComponent.

static std::string CCmpRallyPointRenderer::GetSchema ( )
inlinestatic
void CCmpRallyPointRenderer::GetVisibilitySegments ( std::deque< 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.

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

Reimplemented from IComponent.

void CCmpRallyPointRenderer::Init ( const CParamNode paramNode)
virtual

Implements IComponent.

bool CCmpRallyPointRenderer::IsSet ( ) const
inlinevirtual

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.

void CCmpRallyPointRenderer::MergeVisibilitySegments ( std::deque< 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.

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.

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.

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.

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

void CCmpRallyPointRenderer::RenderSubmit ( SceneCollector collector)
private
virtual void CCmpRallyPointRenderer::Reset ( )
inlinevirtual

Reset the positions of this rally point marker.

Implements ICmpRallyPointRenderer.

virtual void CCmpRallyPointRenderer::Serialize ( ISerializer serialize)
inlinevirtual

Implements IComponent.

virtual void CCmpRallyPointRenderer::SetDisplayed ( bool  displayed)
inlinevirtual

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

Implements ICmpRallyPointRenderer.

virtual void CCmpRallyPointRenderer::SetPosition ( const CFixedVector2D position)
inlinevirtual

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

Discards all previous positions

Implements ICmpRallyPointRenderer.

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.

void CCmpRallyPointRenderer::UpdateMessageSubscriptions ( )
inline
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.

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

Updates the position of one given rally point marker.

Implements ICmpRallyPointRenderer.

Member Data Documentation

std::vector<std::vector<SOverlayLine> > CCmpRallyPointRenderer::m_DebugNodeOverlays
protected
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)

bool CCmpRallyPointRenderer::m_EnableDebugNodeOverlay
protected

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

size_t CCmpRallyPointRenderer::m_LastMarkerCount
protected
player_id_t CCmpRallyPointRenderer::m_LastOwner
protected

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

CColor CCmpRallyPointRenderer::m_LineColor
protected
CColor CCmpRallyPointRenderer::m_LineDashColor
protected
LineCapType CCmpRallyPointRenderer::m_LineEndCapType
protected
std::string CCmpRallyPointRenderer::m_LinePassabilityClass
protected

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

LineCapType CCmpRallyPointRenderer::m_LineStartCapType
protected
std::wstring CCmpRallyPointRenderer::m_LineTextureMaskPath
protected
std::wstring CCmpRallyPointRenderer::m_LineTexturePath
protected
float CCmpRallyPointRenderer::m_LineThickness
protected

Marker connector line settings (loaded from XML)

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

Entity IDs of the rally point markers.

std::wstring CCmpRallyPointRenderer::m_MarkerTemplate
protected

Template name of the rally point markers.

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.

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).

bool CCmpRallyPointRenderer::m_SmoothPath
protected

Smooth the path before rendering?

CTexturePtr CCmpRallyPointRenderer::m_Texture
protected
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.

CTexturePtr CCmpRallyPointRenderer::m_TextureMask
protected
std::deque<std::deque<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 file: