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