Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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:
ICmpRallyPointRenderer IComponent

Public Member Functions

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)
 
virtual void AddPosition_wrapper (CFixedVector2D pos)
 Add another position at which a marker should be displayed, connected to the previous one. More...
 
virtual void SetPosition (CFixedVector2D pos)
 Sets the position at which the rally point marker should be displayed. 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...
 
- 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 JSClass * GetJSClass () const
 
virtual jsval GetJSInstance () const
 

Static Public Member Functions

static void ClassInit (CComponentManager &componentManager)
 
static IComponentAllocate (ScriptInterface &, jsval)
 
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...
 
std::string m_LineCostClass
 Pathfinder cost 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 ICmpPathfinder::Path Path
 
typedef ICmpPathfinder::Goal Goal
 
typedef ICmpPathfinder::Waypoint Waypoint
 
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...
 
bool IsSet ()
 Returns true iff at least one display rally point is set; i.e., if we have a point to render our marker/line at. 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)
 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 GetVisibilitySegments (std::deque< SVisibilitySegment > &out, size_t index)
 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)
 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...
 

Detailed Description

Definition at line 68 of file CCmpRallyPointRenderer.cpp.

Member Typedef Documentation

Definition at line 74 of file CCmpRallyPointRenderer.cpp.

Definition at line 72 of file CCmpRallyPointRenderer.cpp.

Definition at line 75 of file CCmpRallyPointRenderer.cpp.

Definition at line 71 of file CCmpRallyPointRenderer.cpp.

Definition at line 73 of file CCmpRallyPointRenderer.cpp.

Member Function Documentation

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

Helper function for AddPosition_wrapper and SetPosition.

Definition at line 307 of file CCmpRallyPointRenderer.cpp.

virtual void CCmpRallyPointRenderer::AddPosition_wrapper ( CFixedVector2D  position)
inlinevirtual

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

Implements ICmpRallyPointRenderer.

Definition at line 266 of file CCmpRallyPointRenderer.cpp.

static IComponent* CCmpRallyPointRenderer::Allocate ( ScriptInterface ,
jsval   
)
inlinestatic

Definition at line 87 of file CCmpRallyPointRenderer.cpp.

static void CCmpRallyPointRenderer::ClassInit ( CComponentManager componentManager)
inlinestatic

Definition at line 78 of file CCmpRallyPointRenderer.cpp.

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.

Definition at line 712 of file CCmpRallyPointRenderer.cpp.

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.

Definition at line 720 of file CCmpRallyPointRenderer.cpp.

static void CCmpRallyPointRenderer::Deallocate ( IComponent cmp)
inlinestatic

Definition at line 87 of file CCmpRallyPointRenderer.cpp.

virtual void CCmpRallyPointRenderer::Deinit ( )
inlinevirtual

Implements IComponent.

Definition at line 207 of file CCmpRallyPointRenderer.cpp.

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

Implements IComponent.

Definition at line 216 of file CCmpRallyPointRenderer.cpp.

void CCmpRallyPointRenderer::FixFootprintWaypoints ( std::vector< CVector2D > &  coords,
CmpPtr< ICmpPosition cmpPosition,
CmpPtr< ICmpFootprint cmpFootprint 
)
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.

Definition at line 906 of file CCmpRallyPointRenderer.cpp.

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

Definition at line 133 of file CCmpRallyPointRenderer.cpp.

void CCmpRallyPointRenderer::GetVisibilitySegments ( std::deque< SVisibilitySegment > &  out,
size_t  index 
)
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.

Definition at line 1085 of file CCmpRallyPointRenderer.cpp.

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

Reimplemented from IComponent.

Definition at line 221 of file CCmpRallyPointRenderer.cpp.

void CCmpRallyPointRenderer::Init ( const CParamNode paramNode)
virtual

Implements IComponent.

Definition at line 415 of file CCmpRallyPointRenderer.cpp.

bool CCmpRallyPointRenderer::IsSet ( )
inlineprivate

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

Definition at line 321 of file CCmpRallyPointRenderer.cpp.

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.

Definition at line 1131 of file CCmpRallyPointRenderer.cpp.

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.

Definition at line 537 of file CCmpRallyPointRenderer.cpp.

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.

Definition at line 579 of file CCmpRallyPointRenderer.cpp.

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.

Definition at line 564 of file CCmpRallyPointRenderer.cpp.

void CCmpRallyPointRenderer::ReduceSegmentsByVisibility ( std::vector< CVector2D > &  coords,
unsigned  maxSegmentLinks = 0,
bool  floating = true 
)
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

Definition at line 991 of file CCmpRallyPointRenderer.cpp.

void CCmpRallyPointRenderer::RenderSubmit ( SceneCollector collector)
private

Definition at line 1195 of file CCmpRallyPointRenderer.cpp.

virtual void CCmpRallyPointRenderer::Reset ( )
inlinevirtual

Reset the positions of this rally point marker.

Implements ICmpRallyPointRenderer.

Definition at line 296 of file CCmpRallyPointRenderer.cpp.

virtual void CCmpRallyPointRenderer::Serialize ( ISerializer serialize)
inlinevirtual

Implements IComponent.

Definition at line 211 of file CCmpRallyPointRenderer.cpp.

virtual void CCmpRallyPointRenderer::SetDisplayed ( bool  displayed)
inlinevirtual

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

Implements ICmpRallyPointRenderer.

Definition at line 280 of file CCmpRallyPointRenderer.cpp.

virtual void CCmpRallyPointRenderer::SetPosition ( CFixedVector2D  position)
inlinevirtual

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

Discards all previous positions

Implements ICmpRallyPointRenderer.

Definition at line 271 of file CCmpRallyPointRenderer.cpp.

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.

Definition at line 469 of file CCmpRallyPointRenderer.cpp.

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.

Definition at line 869 of file CCmpRallyPointRenderer.cpp.

Member Data Documentation

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

Definition at line 129 of file CCmpRallyPointRenderer.cpp.

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)

Definition at line 101 of file CCmpRallyPointRenderer.cpp.

bool CCmpRallyPointRenderer::m_EnableDebugNodeOverlay
protected

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

Definition at line 128 of file CCmpRallyPointRenderer.cpp.

size_t CCmpRallyPointRenderer::m_LastMarkerCount
protected

Definition at line 105 of file CCmpRallyPointRenderer.cpp.

player_id_t CCmpRallyPointRenderer::m_LastOwner
protected

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

Definition at line 106 of file CCmpRallyPointRenderer.cpp.

CColor CCmpRallyPointRenderer::m_LineColor
protected

Definition at line 111 of file CCmpRallyPointRenderer.cpp.

std::string CCmpRallyPointRenderer::m_LineCostClass
protected

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

Definition at line 118 of file CCmpRallyPointRenderer.cpp.

CColor CCmpRallyPointRenderer::m_LineDashColor
protected

Definition at line 112 of file CCmpRallyPointRenderer.cpp.

LineCapType CCmpRallyPointRenderer::m_LineEndCapType
protected

Definition at line 114 of file CCmpRallyPointRenderer.cpp.

std::string CCmpRallyPointRenderer::m_LinePassabilityClass
protected

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

Definition at line 117 of file CCmpRallyPointRenderer.cpp.

LineCapType CCmpRallyPointRenderer::m_LineStartCapType
protected

Definition at line 113 of file CCmpRallyPointRenderer.cpp.

std::wstring CCmpRallyPointRenderer::m_LineTextureMaskPath
protected

Definition at line 116 of file CCmpRallyPointRenderer.cpp.

std::wstring CCmpRallyPointRenderer::m_LineTexturePath
protected

Definition at line 115 of file CCmpRallyPointRenderer.cpp.

float CCmpRallyPointRenderer::m_LineThickness
protected

Marker connector line settings (loaded from XML)

Definition at line 110 of file CCmpRallyPointRenderer.cpp.

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

Entity IDs of the rally point markers.

Definition at line 104 of file CCmpRallyPointRenderer.cpp.

std::wstring CCmpRallyPointRenderer::m_MarkerTemplate
protected

Template name of the rally point markers.

Definition at line 107 of file CCmpRallyPointRenderer.cpp.

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.

Definition at line 97 of file CCmpRallyPointRenderer.cpp.

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

Definition at line 95 of file CCmpRallyPointRenderer.cpp.

bool CCmpRallyPointRenderer::m_SmoothPath
protected

Smooth the path before rendering?

Definition at line 102 of file CCmpRallyPointRenderer.cpp.

CTexturePtr CCmpRallyPointRenderer::m_Texture
protected

Definition at line 120 of file CCmpRallyPointRenderer.cpp.

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.

Definition at line 125 of file CCmpRallyPointRenderer.cpp.

CTexturePtr CCmpRallyPointRenderer::m_TextureMask
protected

Definition at line 121 of file CCmpRallyPointRenderer.cpp.

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

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

Definition at line 99 of file CCmpRallyPointRenderer.cpp.


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