Pyrogenesis  trunk
ICmpUnitRenderer.h
Go to the documentation of this file.
1 /* Copyright (C) 2017 Wildfire Games.
2  * This file is part of 0 A.D.
3  *
4  * 0 A.D. is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * 0 A.D. is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef INCLUDED_ICMPMODELRENDERER
19 #define INCLUDED_ICMPMODELRENDERER
20 
22 
23 class CUnit;
24 class CBoundingSphere;
25 class CVector3D;
26 
28 {
29 public:
30  /**
31  * External identifiers for models.
32  * (This is a struct rather than a raw u32 for type-safety.)
33  */
34  struct tag_t
35  {
36  tag_t() : n(0) {}
37  explicit tag_t(u32 n) : n(n) {}
38  bool valid() const { return n != 0; }
39 
40  u32 n;
41  };
42 
43  enum
44  {
45  ACTOR_ONLY = 1 << 0,
47  };
48 
49  virtual tag_t AddUnit(CEntityHandle entity, CUnit* unit, const CBoundingSphere& boundsApprox, int flags) = 0;
50 
51  virtual void RemoveUnit(tag_t tag) = 0;
52 
53  virtual void UpdateUnit(tag_t tag, CUnit* unit, const CBoundingSphere& boundsApprox) = 0;
54 
55  virtual void UpdateUnitPos(tag_t tag, bool inWorld, const CVector3D& pos0, const CVector3D& pos1) = 0;
56 
57  /**
58  * Return a list of visual entities along with their center point.
59  * Visual means they have an associated actor and a visual component,
60  * but they could still be hiden in the fog of war for a specific player,
61  * for example.
62  * NOTE: It's generally faster to do a lot of ray intersection tests than
63  * querying a lot of entities for component interfaces and doing these types
64  * of tests first.
65  */
66  virtual void PickAllEntitiesAtPoint(std::vector<std::pair<CEntityHandle, CVector3D> >& outEntities,
67  const CVector3D& origin, const CVector3D& dir,
68  bool allowEditorSelectables) const = 0;
69 
70  /**
71  * Returns the frame offset from the last Interpolate message.
72  */
73  virtual float GetFrameOffset() const = 0;
74 
75  /**
76  * Toggle the rendering of debug info.
77  */
78  virtual void SetDebugOverlay(bool enabled) = 0;
79 
80  DECLARE_INTERFACE_TYPE(UnitRenderer)
81 };
82 
83 #endif // INCLUDED_ICMPMODELRENDERER
Definition: IComponent.h:33
virtual float GetFrameOffset() const =0
Returns the frame offset from the last Interpolate message.
Definition: ICmpUnitRenderer.h:45
Object wrapping an entity_id_t, with a SEntityComponentCache to support fast QueryInterface() / CmpPt...
Definition: Entity.h:79
virtual tag_t AddUnit(CEntityHandle entity, CUnit *unit, const CBoundingSphere &boundsApprox, int flags)=0
Definition: Vector3D.h:28
u32 n
Definition: ICmpUnitRenderer.h:40
Definition: Unit.h:36
Definition: ICmpUnitRenderer.h:27
virtual void UpdateUnit(tag_t tag, CUnit *unit, const CBoundingSphere &boundsApprox)=0
tag_t(u32 n)
Definition: ICmpUnitRenderer.h:37
virtual void RemoveUnit(tag_t tag)=0
virtual void PickAllEntitiesAtPoint(std::vector< std::pair< CEntityHandle, CVector3D > > &outEntities, const CVector3D &origin, const CVector3D &dir, bool allowEditorSelectables) const =0
Return a list of visual entities along with their center point.
virtual void SetDebugOverlay(bool enabled)=0
Toggle the rendering of debug info.
uint32_t u32
Definition: types.h:39
#define DECLARE_INTERFACE_TYPE(iname)
Definition: Interface.h:23
Definition: ICmpUnitRenderer.h:46
tag_t()
Definition: ICmpUnitRenderer.h:36
Definition: BoundingSphere.h:24
bool valid() const
Definition: ICmpUnitRenderer.h:38
External identifiers for models.
Definition: ICmpUnitRenderer.h:34
virtual void UpdateUnitPos(tag_t tag, bool inWorld, const CVector3D &pos0, const CVector3D &pos1)=0