Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
ICmpUnitRenderer.h
Go to the documentation of this file.
1/* Copyright (C) 2026 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
23
24#include <js/Value.h>
25#include <utility>
26#include <vector>
27
28class CBoundingSphere;
29class CEntityHandle;
30class CUnit;
31class CVector3D;
32
34{
35public:
36 /**
37 * External identifiers for models.
38 * (This is a struct rather than a raw std::uint32_t for type-safety.)
39 */
40 struct tag_t
41 {
42 tag_t() : n(0) {}
43 explicit tag_t(std::uint32_t n) : n(n) {}
44 bool valid() const { return n != 0; }
45
46 std::uint32_t n;
47 };
48
49 enum
50 {
51 ACTOR_ONLY = 1 << 0,
53 };
54
55 virtual tag_t AddUnit(CEntityHandle entity, CUnit* unit, const CBoundingSphere& boundsApprox, int flags) = 0;
56
57 virtual void RemoveUnit(tag_t tag) = 0;
58
59 virtual void UpdateUnit(tag_t tag, CUnit* unit, const CBoundingSphere& boundsApprox) = 0;
60
61 virtual void UpdateUnitPos(tag_t tag, bool inWorld, const CVector3D& pos0, const CVector3D& pos1) = 0;
62
63 /**
64 * Return a list of visual entities along with their center point.
65 * Visual means they have an associated actor and a visual component,
66 * but they could still be hiden in the fog of war for a specific player,
67 * for example.
68 * NOTE: It's generally faster to do a lot of ray intersection tests than
69 * querying a lot of entities for component interfaces and doing these types
70 * of tests first.
71 */
72 virtual void PickAllEntitiesAtPoint(std::vector<std::pair<CEntityHandle, CVector3D> >& outEntities,
73 const CVector3D& origin, const CVector3D& dir,
74 bool allowEditorSelectables) const = 0;
75
76 /**
77 * Returns the frame offset from the last Interpolate message.
78 */
79 virtual float GetFrameOffset() const = 0;
80
81 /**
82 * Toggle the rendering of debug info.
83 */
84 virtual void SetDebugOverlay(bool enabled) = 0;
85
86 DECLARE_INTERFACE_TYPE(UnitRenderer)
87};
88
89#endif // INCLUDED_ICMPMODELRENDERER
Definition: BoundingSphere.h:26
Object wrapping an entity_id_t, with a SEntityComponentCache to support fast QueryInterface() / CmpPt...
Definition: Entity.h:80
Definition: Unit.h:40
Definition: Vector3D.h:32
Definition: ICmpUnitRenderer.h:34
virtual void SetDebugOverlay(bool enabled)=0
Toggle the rendering of debug info.
virtual void UpdateUnit(tag_t tag, CUnit *unit, const CBoundingSphere &boundsApprox)=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.
@ VISIBLE_IN_ATLAS_ONLY
Definition: ICmpUnitRenderer.h:52
@ ACTOR_ONLY
Definition: ICmpUnitRenderer.h:51
virtual void RemoveUnit(tag_t tag)=0
virtual void UpdateUnitPos(tag_t tag, bool inWorld, const CVector3D &pos0, const CVector3D &pos1)=0
virtual tag_t AddUnit(CEntityHandle entity, CUnit *unit, const CBoundingSphere &boundsApprox, int flags)=0
virtual float GetFrameOffset() const =0
Returns the frame offset from the last Interpolate message.
Definition: IComponent.h:33
#define DECLARE_INTERFACE_TYPE(iname)
Definition: Interface.h:23
External identifiers for models.
Definition: ICmpUnitRenderer.h:41
std::uint32_t n
Definition: ICmpUnitRenderer.h:46
tag_t(std::uint32_t n)
Definition: ICmpUnitRenderer.h:43
tag_t()
Definition: ICmpUnitRenderer.h:42
bool valid() const
Definition: ICmpUnitRenderer.h:44