Emergency 2017 Dokumentation  v3.0.1
qsf::NodesComponent Class Referenceabstract

Abstract node collection component class. More...

#include <NodesComponent.h>

Public Types

enum  DebugFlags {
  DEBUG_NODES = 1<<0, DEBUG_NODES_ID = 1<<1, DEBUG_CENTER = 1<<2, DEBUG_EDGES = 1<<3,
  DEBUG_GATEWAYS = 1<<4, DEBUG_POLYGON = 1<<5
}
 Debug flags. More...
 
typedef BitFlagSet< uint8, DebugFlagsDebugFlagSet
 
- Public Types inherited from qsf::Component
enum  TransformChangeFlag {
  TRANSFORM_CHANGE_POSITION = 0x01, TRANSFORM_CHANGE_ROTATION = 0x02, TRANSFORM_CHANGE_SCALE = 0x04, TRANSFORM_CHANGE_TRANSFORM = 0x07,
  TRANSFORM_CHANGE_FOR_SIMULATION = 0x08, TRANSFORM_CHANGE_FOR_ANIMATION = 0x10
}
 
typedef BitFlagSet< uint8, TransformChangeFlagTransformChangeFlags
 
- Public Types inherited from qsf::Object
enum  PropertyOverrideState { PROPERTY_INVALID, PROPERTY_DEFAULT, PROPERTY_OVERRIDE, PROPERTY_REMOVED }
 
enum  SerializationMethod { SERIALIZE_FLAT, SERIALIZE_COMPLETE, SERIALIZE_DIFFERENTIAL, SERIALIZE_IGNORE_UNKNOWN }
 
enum  SerializationMode { MODE_MINIMAL, MODE_COMPATIBLE }
 

Public Member Functions

 NodesComponent (Prototype *prototype)
 Constructor. More...
 
virtual ~NodesComponent ()
 Destructor. More...
 
const DebugFlagSetgetDebugFlagSet () const
 Return the debug flag set. More...
 
void setDebugFlagSet (const DebugFlagSet &debugFlagSet)
 Set the debug flag set. More...
 
glm::vec3 calculateCenterPosition () const
 Calculate the center position of the nodes. More...
 
bool hitNodeWithRay (const Ray &ray, int &nodeIndex) const
 Checks if the given ray is hitting a node. More...
 
int getClosestSegmentIndexToPoint (const glm::vec3 &point, glm::vec3 *closestPoint=nullptr) const
 Return the closed segment of the nodes from the given point. More...
 
uint32 getNumberOfNodes () const
 Return the number of nodes. More...
 
void createNodeGeometryOnNode (uint32 nodeIndex, const Color4 &color, float boxRadius=0.5f, DebugDrawProxy *debugDrawProxy=nullptr, bool doInitialization=false)
 Creates a visual box (looking like a bounding box) around the given node. More...
 
virtual void setNode (std::size_t index, const Node &value)
 
virtual void insertNode (std::size_t before, const Node &value)
 
virtual void removeNode (std::size_t index)
 
virtual uint32 getMiniumNumberOfNodes () const
 Return the minimum number of nodes the concrete nodes component instance needs to be valid. More...
 
virtual void setNodeToPosition (uint32 nodeIndex, const glm::vec3 &newPosition)
 
virtual void setNodeToTransform (uint32 nodeIndex, const Transform &newTransform)
 Changes the transform of a node and propagates the property change. More...
 
virtual void addPosition (const glm::vec3 &position)
 Add a position to all nodes. More...
 
virtual const std::vector< Node > & getNodes () const
 
virtual void setNodes (const std::vector< Node > &nodes)
 
virtual void serialize (BinarySerializer &serializer) override
 Serialize or deserialize the component using a binary serializer. More...
 
- Public Member Functions inherited from qsf::Component
virtual ~Component ()
 Destructor. More...
 
PrototypegetPrototype () const
 Return the prototype this component is in. More...
 
EntitygetEntity () const
 Return a reference to the entity this component is in. More...
 
uint32 getId () const
 Return the unique component identifier. More...
 
ComponentManagergetComponentManager () const
 Return the component manager that's responsible for this component instance. More...
 
ComponentCollectiongetComponentCollection () const
 Return the component collection that's responsible for this component instance. More...
 
bool isSimulating () const
 Return whether or not the component is in simulating mode. More...
 
bool isActive () const
 Return whether or not the component is considered to be active. More...
 
void setActive (bool active)
 Set whether or not the component is considered to be active. More...
 
bool isDebug () const
 Return whether or not the component is considered to be in debug mode. More...
 
bool isHidden () const
 Return whether or not the component is hidden. More...
 
void setHidden (bool hidden)
 Set whether or not the component is hidden. More...
 
bool isGloballyHidden () const
 Return whether or not the component is globally hidden. More...
 
void setGloballyHidden (bool globallyHidden)
 Set whether or not the component is globally hidden. More...
 
bool isReallyHidden () const
 Return whether or not the component is really hidden. More...
 
bool startup ()
 Startup the component. More...
 
bool isRunning () const
 Return whether or not the component is up-and-running. More...
 
void shutdown ()
 Shutdown the component. More...
 
uint64 getPrototypeId () const
 Return the ID of the prototype this component is in. More...
 
uint64 getEntityId () const
 Return the ID of the entity this component is in. More...
 
virtual void onInvalidation ()
 Invalidate the component. More...
 
virtual void setDebug (bool debugMode)
 Set whether or not the component is considered to be in debug mode. More...
 
- Public Member Functions inherited from qsf::InheritedObject
void copyPropertyOverrideStateFrom (const InheritedObject &object, bool add=false)
 
void setAllPropertyOverrideFlags (bool value)
 
void autoCreatePropertyOverrideState ()
 
virtual camp::Value getPropertyDefaultValue (const StringHash &propertyId) const override
 
virtual PropertyOverrideState getPropertyOverrideState (const StringHash &propertyId) const override
 
virtual bool setPropertyOverrideState (const StringHash &propertyId, PropertyOverrideState overrideState) override
 
- Public Member Functions inherited from qsf::Object
virtual ~Object ()
 Destructor. More...
 
const camp::Class & getCampClass () const
 Return the CAMP class. More...
 
int getPropertyIndexById (const StringHash &propertyId) const
 Return the CAMP property index by using the unique class property ID. More...
 
uint32 getPropertyIdByIndex (int index) const
 Return the unique class property ID with the given index. More...
 
std::string getPropertyNameById (const StringHash &propertyId) const
 Return the CAMP property name by using the unique class property ID. More...
 
const camp::Property * getCampPropertyById (const StringHash &propertyId) const
 Return the CAMP property by using the unique class property ID. More...
 
void setPropertyValuesByString (const std::string &values)
 Set CAMP reflection property values by using a given string. More...
 
void setPropertiesToDefaultValues ()
 Set all CAMP reflection system properties to their default values. More...
 
void serializeToBoostPTree (boost::property_tree::ptree &pTree, SerializationMethod serializationMethod=SERIALIZE_DIFFERENTIAL) const
 
void serializeToBoostPTree (boost::property_tree::ptree &pTree, const camp::Class &campClass, SerializationMethod serializationMethod=SERIALIZE_DIFFERENTIAL) const
 
bool deserializeFromBoostPTree (const boost::property_tree::ptree &pTree, SerializationMethod serializationMethod=SERIALIZE_DIFFERENTIAL)
 
bool deserializeFromBoostPTree (const boost::property_tree::ptree &pTree, const camp::Class &campClass, SerializationMethod serializationMethod=SERIALIZE_DIFFERENTIAL)
 
void serializeToBinarySerializer (BinarySerializer &serializer, SerializationMode mode=MODE_MINIMAL, SerializationMethod serializationMethod=SERIALIZE_DIFFERENTIAL) const
 
void deserializeFromBinarySerializer (BinarySerializer &serializer, SerializationMode mode=MODE_MINIMAL, SerializationMethod serializationMethod=SERIALIZE_DIFFERENTIAL, bool setOverrideState=true)
 
virtual void onPreDeserialize ()
 Called right before the object is deserialized using any of the above methods. Default implementation is empty. More...
 
virtual void onPostDeserialize ()
 Called right after the object was deserialized using any of the above methods. Default implementation is empty. More...
 
virtual ScriptgetAssociatedScript () const
 Return the script instance associated with this object instance. More...
 

Static Public Attributes

static const uint32 COMPONENT_ID
 "qsf::NodesComponent" unique component ID More...
 
static const uint32 NODES
 "Nodes" unique class property ID inside the class More...
 
- Static Public Attributes inherited from qsf::Component
static const uint32 COMPONENT_ID
 "qsf::Component" unique component ID More...
 

Protected Member Functions

virtual bool closedContinuousLines () const =0
 Return whether or not closed continuous lines are used. More...
 
virtual void onSetDebugFlagSet ()
 Called if there's a debug flag set change. More...
 
virtual void startDebugDrawing ()
 Start debug visualization. More...
 
virtual void onUpdateNodes ()
 
virtual bool implementsOnComponentPropertyChange () const override
 Signal whether this component needs the "onComponentPropertyChange" callback at all. More...
 
virtual void onComponentPropertyChange (const Component &component, uint32 propertyId) override
 Called in case a component property value was changed. More...
 
virtual void onSetDebug (bool debug) override
 Set whether or not the component is considered to be in debug mode. More...
 
void cancelDebugDrawing ()
 
 QSF_CAMP_RTTI () QSF_CAMP_ARRAY_PROPERTY(Nodes
 
- Protected Member Functions inherited from qsf::Component
 Component (Prototype *prototype)
 Constructor. More...
 
void promotePropertyChange (uint32 propertyId)
 A component property value was changed. More...
 
template<typename T , typename S >
bool assignAndPromoteChange (T &variable, const S &newValue, uint32 propertyId)
 Comfort function for updating an exported member variable and promoting any change that happened. More...
 
void setRegisterForSimulationTransformChanges (bool enable)
 Register or unregister this component as simulation transform listener. More...
 
void setRegisterForAnimationTransformChanges (bool enable)
 Register or unregister this component as animation transform listener. More...
 
virtual const ObjectgetPropertyDefaultsProvider () const override
 
virtual void onComponentTransformChange (const Transform &transform, TransformChangeFlags flags)
 Called in case a component transformation value was changed. More...
 
virtual void onSetSimulating (bool simulating)
 Set whether or not the component is in simulating mode. More...
 
virtual void onSetActive (bool active)
 Set whether or not the component is considered to be active. More...
 
virtual void onSetHidden (bool hidden)
 Set whether or not the component is considered to be hidden. More...
 
virtual bool onStartup ()
 Startup the component. More...
 
virtual void onShutdown ()
 Shutdown the component. More...
 
- Protected Member Functions inherited from qsf::InheritedObject
 InheritedObject ()
 Default constructor. More...
 
- Protected Member Functions inherited from qsf::Object
 Object ()
 Default constructor. More...
 
- Protected Member Functions inherited from qsf::WeakPtrTarget
 WeakPtrTarget ()
 Default constructor. More...
 
 WeakPtrTarget (const WeakPtrTarget &other)
 Copy constructor. More...
 
 WeakPtrTarget (WeakPtrTarget &&)=delete
 Delete the move constructor, as WeakPtrTarget would need a proper move constructor-implementation that ensures that its pointer gets updated in the WeakPtrBase as well. More...
 
 ~WeakPtrTarget ()
 Destructor. More...
 
void invalidateAllWeakPtr ()
 Invalidate all weak pointers to this object. More...
 
void operator= (const WeakPtrTarget &other)
 Copy operator. More...
 

Protected Attributes

std::vector< NodemNodes
 The local space nodes. More...
 
DebugFlagSet mDebugFlagSet
 Debug flag set. More...
 
DebugDrawProxy mDebugDrawProxy
 Debug draw proxy for visualization. More...
 
 NodesComponent
 
- Protected Attributes inherited from qsf::InheritedObject
std::bitset< 128 > mPropertyOverrideFlags
 One bit for each property; if set, the property is overridden. More...
 

Detailed Description

Abstract node collection component class.

Note
  • All nodes are stored in local space coordinates. If working with them, you will probably have to convert them to world space (e.g. using the EntityHelper).
  • Nodes are identified using their internal index, beginning with 0.
Todo:
  • TODO(co) Sadly, the interface is error prone and a little bit complicated at some places, make a refactoring of this class ensure it's well documented

Definition at line 53 of file NodesComponent.h.

Member Typedef Documentation

Member Enumeration Documentation

Debug flags.

Enumerator
DEBUG_NODES 

Debug nodes.

DEBUG_NODES_ID 

Debug node IDs.

DEBUG_CENTER 

Debug nodes center.

DEBUG_EDGES 

Debug edges.

DEBUG_GATEWAYS 

Debug gateways // TODO(co) Move this into street component.

DEBUG_POLYGON 

Debug polygon // TODO(co) Move this into polygon component.

Definition at line 68 of file NodesComponent.h.

Constructor & Destructor Documentation

qsf::NodesComponent::NodesComponent ( Prototype prototype)
explicit

Constructor.

Parameters
[in]prototypeThe prototype this component is in, no null pointer allowed
virtual qsf::NodesComponent::~NodesComponent ( )
virtual

Destructor.

Member Function Documentation

virtual void qsf::NodesComponent::addPosition ( const glm::vec3 &  position)
virtual

Add a position to all nodes.

Parameters
[in]positionThe local space position to add

Reimplemented in qsf::StreetSectionComponent, qsf::PathMeshComponent, qsf::DecalGeometricComponent, and qsf::PolygonComponent.

glm::vec3 qsf::NodesComponent::calculateCenterPosition ( ) const

Calculate the center position of the nodes.

Returns
The local space center position of the nodes
void qsf::NodesComponent::cancelDebugDrawing ( )
protected
virtual bool qsf::NodesComponent::closedContinuousLines ( ) const
protectedpure virtual

Return whether or not closed continuous lines are used.

Note
  • This information is relevant for e.g. "qsf::NodesComponent::getClosestSegmentIndexToPoint()"
  • While a simple path usually does not form a circle (segment from end to start node), a polygon is usually closed

Implemented in qsf::StreetComponent, qsf::PolygonComponent, qsf::DecalComponent, qsf::LiquidPolygonComponent, and qsf::PathComponent.

void qsf::NodesComponent::createNodeGeometryOnNode ( uint32  nodeIndex,
const Color4 color,
float  boxRadius = 0.5f,
DebugDrawProxy debugDrawProxy = nullptr,
bool  doInitialization = false 
)

Creates a visual box (looking like a bounding box) around the given node.

Parameters
[in]nodeIndexNode index
[in]colorColor to use
[in]boxRadiusLocal space box radius
[in]debugDrawProxyDebug draw proxy to write the visualization to, can be a null pointer to use the internal one
[in]doInitializationIf "true", the debug draw request will be (re-)registered and its transform set accordingly
int qsf::NodesComponent::getClosestSegmentIndexToPoint ( const glm::vec3 &  point,
glm::vec3 *  closestPoint = nullptr 
) const

Return the closed segment of the nodes from the given point.

Parameters
[in]pointThe point from what the calculation checks the closest segment
[out]closestPointIn case the function finds a segment, it returns the closest point on this segment, this can be a null pointer
Returns
The index of a node
const NodesComponent::DebugFlagSet & qsf::NodesComponent::getDebugFlagSet ( ) const
inline

Return the debug flag set.

Returns
The debug flag set, do not destroy the instance

Definition at line 20 of file NodesComponent-inl.h.

uint32 qsf::NodesComponent::getMiniumNumberOfNodes ( ) const
inlinevirtual

Return the minimum number of nodes the concrete nodes component instance needs to be valid.

Returns
The minimum number of nodes the concrete nodes component instance needs to be valid

Reimplemented in qsf::PolygonComponent.

Definition at line 47 of file NodesComponent-inl.h.

const std::vector< Node > & qsf::NodesComponent::getNodes ( ) const
inlinevirtual

Definition at line 52 of file NodesComponent-inl.h.

uint32 qsf::NodesComponent::getNumberOfNodes ( ) const
inline

Return the number of nodes.

Note
  • Connected to the CAMP reflection system
  • The only reason this tiny redundant method exists is to have a read only number of nodes CAMP property

Definition at line 38 of file NodesComponent-inl.h.

bool qsf::NodesComponent::hitNodeWithRay ( const Ray ray,
int &  nodeIndex 
) const

Checks if the given ray is hitting a node.

Parameters
[in]rayLocal space ray
[out]nodeIndexThe index of the closest node, hitten by the ray
Returns
True if an node is hidden, otherwise false
virtual bool qsf::NodesComponent::implementsOnComponentPropertyChange ( ) const
inlineoverrideprotectedvirtual

Signal whether this component needs the "onComponentPropertyChange" callback at all.

Returns
If "true", this component can receive property change callbacks, otherwise "onComponentPropertyChange" won't get called

Reimplemented from qsf::Component.

Reimplemented in qsf::StreetSectionComponent, qsf::DecalGeometricComponent, qsf::StreetCrossingComponent, qsf::AmbientPolygonComponent, qsf::TraceDecalComponent, qsf::GroundTypePolygonComponent, qsf::LiquidPolygonComponent, qsf::DecalProjectedComponent, and em5::WaterDeepTypePolygonComponent.

Definition at line 278 of file NodesComponent.h.

virtual void qsf::NodesComponent::insertNode ( std::size_t  before,
const Node value 
)
virtual
virtual void qsf::NodesComponent::onComponentPropertyChange ( const Component component,
uint32  propertyId 
)
overrideprotectedvirtual

Called in case a component property value was changed.

Parameters
[in]componentComponent instance which had a property value change
[in]propertyIdUnique class property ID the component property which values was changed
Note
  • The default implementation is empty
  • The unique class property identifier is generated by "qsf::StringHash" by using the class property name (e.g. qsf::StringHash("Position") generating the hash value 3091144222)

Reimplemented from qsf::Component.

Reimplemented in qsf::StreetSectionComponent, qsf::DecalGeometricComponent, qsf::StreetCrossingComponent, qsf::AmbientPolygonComponent, qsf::TraceDecalComponent, qsf::GroundTypePolygonComponent, qsf::LiquidPolygonComponent, qsf::DecalProjectedComponent, and em5::WaterDeepTypePolygonComponent.

virtual void qsf::NodesComponent::onSetDebug ( bool  debug)
overrideprotectedvirtual

Set whether or not the component is considered to be in debug mode.

Parameters
[in]debug"true" if the component is considered to be in debug mode, else "false"
Note
  • The default implementation is empty
  • This method is only called in case there's a real state change
See also
  • "qsf::Component::setDebug()"

Reimplemented from qsf::Component.

virtual void qsf::NodesComponent::onSetDebugFlagSet ( )
protectedvirtual

Called if there's a debug flag set change.

Note
  • This method is only called in case there's a real state change
See also
  • "qsf::NodesComponent::setDebugFlags()"
virtual void qsf::NodesComponent::onUpdateNodes ( )
protectedvirtual

Reimplemented in qsf::LiquidPolygonComponent.

qsf::NodesComponent::QSF_CAMP_RTTI ( )
protected
virtual void qsf::NodesComponent::removeNode ( std::size_t  index)
virtual
virtual void qsf::NodesComponent::serialize ( BinarySerializer serializer)
overridevirtual

Serialize or deserialize the component using a binary serializer.

Parameters
[in]serializerThe serializer, which can be either in read or write mode

Reimplemented from qsf::Component.

Reimplemented in qsf::StreetSectionComponent, qsf::PathMeshComponent, qsf::PolygonComponent, qsf::StreetComponent, and qsf::StreetCrossingComponent.

void qsf::NodesComponent::setDebugFlagSet ( const DebugFlagSet debugFlagSet)
inline

Set the debug flag set.

Parameters
[in]debugFlagSetThe debug flag set to set

Definition at line 25 of file NodesComponent-inl.h.

virtual void qsf::NodesComponent::setNode ( std::size_t  index,
const Node value 
)
virtual
virtual void qsf::NodesComponent::setNodes ( const std::vector< Node > &  nodes)
virtual
virtual void qsf::NodesComponent::setNodeToPosition ( uint32  nodeIndex,
const glm::vec3 &  newPosition 
)
virtual
virtual void qsf::NodesComponent::setNodeToTransform ( uint32  nodeIndex,
const Transform newTransform 
)
virtual

Changes the transform of a node and propagates the property change.

Parameters
[in]nodeIndexNode which transform should be changed
[in]newTransformLocal transformation which should be applied to the node
virtual void qsf::NodesComponent::startDebugDrawing ( )
protectedvirtual

Member Data Documentation

const uint32 qsf::NodesComponent::COMPONENT_ID
static

"qsf::NodesComponent" unique component ID

Definition at line 61 of file NodesComponent.h.

DebugDrawProxy qsf::NodesComponent::mDebugDrawProxy
protected

Debug draw proxy for visualization.

Definition at line 298 of file NodesComponent.h.

DebugFlagSet qsf::NodesComponent::mDebugFlagSet
protected

Debug flag set.

Definition at line 297 of file NodesComponent.h.

std::vector<Node> qsf::NodesComponent::mNodes
protected

The local space nodes.

Definition at line 295 of file NodesComponent.h.

const uint32 qsf::NodesComponent::NODES
static

"Nodes" unique class property ID inside the class

Definition at line 62 of file NodesComponent.h.

qsf::NodesComponent::NodesComponent
protected

Definition at line 305 of file NodesComponent.h.


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