Pyrogenesis
trunk
|
Efficiently(ish) renders all the units in the world. More...
Classes | |
struct | SUnit |
Public Member Functions | |
int | GetComponentTypeId () const override |
void | Init (const CParamNode ¶mNode) override |
void | Deinit () override |
void | Serialize (ISerializer &serialize) override |
void | Deserialize (const CParamNode ¶mNode, IDeserializer &deserialize) override |
void | HandleMessage (const CMessage &msg, bool global) override |
SUnit * | LookupUnit (tag_t tag) |
tag_t | AddUnit (CEntityHandle entity, CUnit *actor, const CBoundingSphere &boundsApprox, int flags) override |
void | RemoveUnit (tag_t tag) override |
void | RecomputeSweptBounds (SUnit *unit) |
void | UpdateUnit (tag_t tag, CUnit *actor, const CBoundingSphere &boundsApprox) override |
void | UpdateUnitPos (tag_t tag, bool inWorld, const CVector3D &pos0, const CVector3D &pos1) override |
void | TurnStart () |
void | Interpolate (float frameTime, float frameOffset) |
void | RenderSubmit (SceneCollector &collector, const CFrustum &frustum, bool culling) |
void | UpdateVisibility (SUnit &unit) const |
float | GetFrameOffset () const override |
Returns the frame offset from the last Interpolate message. More... | |
void | SetDebugOverlay (bool enabled) override |
Toggle the rendering of debug info. More... | |
void | PickAllEntitiesAtPoint (std::vector< std::pair< CEntityHandle, CVector3D > > &outEntities, const CVector3D &origin, const CVector3D &dir, bool allowEditorSelectables) const override |
Return a list of visual entities along with their center point. 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 CSimContext & | GetSimContext () const |
void | SetSimContext (const CSimContext &context) |
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 |
Static Public Member Functions | |
static void | ClassInit (CComponentManager &componentManager) |
static IComponent * | Allocate (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 | |
std::vector< SUnit > | m_Units |
std::vector< tag_t > | m_UnitTagsFree |
int | m_FrameNumber |
float | m_FrameOffset |
bool | m_EnableDebugOverlays |
std::vector< SOverlaySphere > | m_DebugSpheres |
Additional Inherited Members | |
Public Types inherited from ICmpUnitRenderer | |
enum | { ACTOR_ONLY = 1 << 0, VISIBLE_IN_ATLAS_ONLY = 1 << 1 } |
Public Types inherited from IComponent | |
using | AllocFunc = IComponent *(*)(const ScriptInterface &scriptInterface, JS::HandleValue ctor) |
using | DeallocFunc = void(*)(IComponent *) |
Efficiently(ish) renders all the units in the world.
The class maintains a list of all units that currently exist, and the data needed for frustum-culling them. To minimise the amount of work done per frame (despite a unit's interpolated position changing every frame), the culling data is only updated once per turn: we store the position at the start of the turn, and the position at the end of the turn, and assume the unit might be anywhere between those two points (linearly).
(Note this is a slightly invalid assumption: units don't always move linearly, since their interpolated position depends on terrain and water. But over a single turn it's probably going to be a good enough approximation, and will only break for units that both start and end the turn off-screen.)
We want to ignore rotation entirely, since it's a complex function of interpolated position and terrain. So we store a bounding sphere, which is rotation-independent, instead of a bounding box.
|
inlineoverridevirtual |
Implements ICmpUnitRenderer.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlineoverridevirtual |
Implements IComponent.
|
inlineoverridevirtual |
Implements IComponent.
|
inlineoverridevirtual |
Implements IComponent.
|
inlineoverridevirtual |
Returns the frame offset from the last Interpolate message.
Implements ICmpUnitRenderer.
|
inlinestatic |
|
inlineoverridevirtual |
Reimplemented from IComponent.
|
inlineoverridevirtual |
Implements IComponent.
void CCmpUnitRenderer::Interpolate | ( | float | frameTime, |
float | frameOffset | ||
) |
|
inlineoverridevirtual |
Return a list of visual entities along with their center point.
Visual means they have an associated actor and a visual component, but they could still be hiden in the fog of war for a specific player, for example. NOTE: It's generally faster to do a lot of ray intersection tests than querying a lot of entities for component interfaces and doing these types of tests first.
Implements ICmpUnitRenderer.
|
inline |
|
inlineoverridevirtual |
Implements ICmpUnitRenderer.
void CCmpUnitRenderer::RenderSubmit | ( | SceneCollector & | collector, |
const CFrustum & | frustum, | ||
bool | culling | ||
) |
|
inlineoverridevirtual |
Implements IComponent.
|
inlineoverridevirtual |
Toggle the rendering of debug info.
Implements ICmpUnitRenderer.
void CCmpUnitRenderer::TurnStart | ( | ) |
|
inlineoverridevirtual |
Implements ICmpUnitRenderer.
|
inlineoverridevirtual |
Implements ICmpUnitRenderer.
void CCmpUnitRenderer::UpdateVisibility | ( | SUnit & | unit | ) | const |
std::vector<SOverlaySphere> CCmpUnitRenderer::m_DebugSpheres |
bool CCmpUnitRenderer::m_EnableDebugOverlays |
int CCmpUnitRenderer::m_FrameNumber |
float CCmpUnitRenderer::m_FrameOffset |
std::vector<SUnit> CCmpUnitRenderer::m_Units |
std::vector<tag_t> CCmpUnitRenderer::m_UnitTagsFree |