Line data Source code
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 : 21 : #include "simulation2/system/Component.h" 22 : #include "simulation2/system/Interface.h" 23 : 24 : #include <js/Value.h> 25 : #include <utility> 26 : #include <vector> 27 : 28 : class CBoundingSphere; 29 : class CEntityHandle; 30 : class CUnit; 31 : class CVector3D; 32 : 33 7 : class ICmpUnitRenderer : public IComponent 34 : { 35 : public: 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 0 : tag_t() : n(0) {} 43 : explicit tag_t(std::uint32_t n) : n(n) {} 44 7173 : bool valid() const { return n != 0; } 45 : 46 : std::uint32_t n; 47 : }; 48 : 49 : enum 50 : { 51 : ACTOR_ONLY = 1 << 0, 52 : VISIBLE_IN_ATLAS_ONLY = 1 << 1, 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 0 : DECLARE_INTERFACE_TYPE(UnitRenderer) 87 : }; 88 : 89 : #endif // INCLUDED_ICMPMODELRENDERER