Merge branch '138-toggle-free-look-with-hotkey' into main/gingo-test
[ryzomcore.git] / ryzom / client / src / r2 / auto_group.h
blob78fa7718e0b44e2015d8edd43cf0ef8bab07f4ac
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program 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 Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef R2_AUTO_GROUP_H
18 #define R2_AUTO_GROUP_H
20 #include "instance.h"
21 #include "prim_render.h"
23 namespace R2
27 class CAutoGroup
29 public:
30 CAutoGroup();
31 ~CAutoGroup();
32 // update new tesing position position for auto group & update the display (may disable auto grouping if 'valid' is false)
33 void update(const NLMISC::CVector &testPos, const std::string &paletteEntry, bool valid);
34 // compute current grouping candidate, based on the last info given to 'update'
35 CInstance *getGroupingCandidate();
36 /** Send the appropriate request to group the description of a new entity with the new grouping candidate
37 * The new grouping candidate is then reset (as if 'update' had been called with 'valid' == false)
38 * Caller should check that there's enough room in the scenario for that operation
39 * No-op if getGroupingCandidate() is false
41 void group(CObject *newEntityDesc, const NLMISC::CVectorD &createPosition);
42 private:
43 //CInstance::TRefPtr _GroupingCandidate;
44 CPrimRender _AutoGroup; // display of auto group in scene / minimap
45 struct CComponentSort
47 float Dist;
48 CInstance *Instance;
49 bool operator<(const CComponentSort &other) const { return Dist < other.Dist; }
51 std::vector<CComponentSort> _SortedComponents;
52 std::vector<CVector> _PrimRenderVertices;
54 NLMISC::CVector _TestPos; // testing pos for grouping candidate
55 std::string _PaletteEntry; // palete entry used for group testing
56 bool _AutoGroupEnabled;
58 private:
59 void updateCandidateInstance(const CVector &testPos, const std::string &paletteEntry);
60 CInstance *getGroupingCandidateInternal(std::vector<CComponentSort> &sortedComponents);
61 void clear();
65 } // R2
69 #endif