Resolve "Toggle Free Look with Hotkey"
[ryzomcore.git] / ryzom / client / src / streamable_entity_composite.cpp
blob01e4aff177ca1a8746923d625f45f731f732fcfc
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/>.
19 #include "stdpch.h"
21 #include "streamable_entity_composite.h"
22 #include "nel/misc/progress_callback.h"
24 #ifdef DEBUG_NEW
25 #define new DEBUG_NEW
26 #endif
28 H_AUTO_DECL(RZ_StremableEntityComposite)
30 //===============================================================================
31 CStreamableEntityComposite::~CStreamableEntityComposite()
33 H_AUTO_USE(RZ_StremableEntityComposite)
34 for(TStreambleEntities::iterator it = _Entities.begin(); it != _Entities.end(); ++it)
36 delete *it;
40 //===============================================================================
41 void CStreamableEntityComposite::add(IStreamableEntity *entity)
43 H_AUTO_USE(RZ_StremableEntityComposite)
44 nlassert (entity);
45 nlassert(std::find(_Entities.begin(), _Entities.end(), entity) == _Entities.end());
46 _Entities.push_back(entity);
49 //===============================================================================
50 void CStreamableEntityComposite::remove(IStreamableEntity *entity)
52 H_AUTO_USE(RZ_StremableEntityComposite)
53 TStreambleEntities::iterator it = std::find(_Entities.begin(), _Entities.end(), entity);
54 nlassert(it != _Entities.end());
55 _Entities.erase(it);
56 delete entity;
59 //===============================================================================
60 /*virtual*/ bool CStreamableEntityComposite::needCompleteLoading(const NLMISC::CVector &pos) const
62 H_AUTO_USE(RZ_StremableEntityComposite)
63 for(TStreambleEntities::const_iterator it = _Entities.begin(); it != _Entities.end(); ++it)
65 if ((*it)->needCompleteLoading(pos)) return true;
67 return false;
70 //===============================================================================
71 /*virtual*/ void CStreamableEntityComposite::update(const NLMISC::CVector &pos)
73 H_AUTO_USE(RZ_StremableEntityComposite)
74 for(TStreambleEntities::iterator it = _Entities.begin(); it != _Entities.end(); ++it)
76 (*it)->update(pos);
80 //===============================================================================
81 /*virtual*/ void CStreamableEntityComposite::forceUpdate(const NLMISC::CVector &pos, NLMISC::IProgressCallback &progress)
83 H_AUTO_USE(RZ_StremableEntityComposite)
84 const uint size = (uint)_Entities.size();
85 uint count = 0;
86 for(TStreambleEntities::iterator it = _Entities.begin(); it != _Entities.end(); ++it)
88 // Progress
89 progress.progress((float)count/(float)size);
90 progress.pushCropedValues((float)count/(float)size, (float)(count+1)/(float)size);
92 (*it)->forceUpdate(pos, progress);
93 count++;
95 progress.popCropedValues();
99 //===============================================================================
100 void CStreamableEntityComposite::reserve(uint size)
102 H_AUTO_USE(RZ_StremableEntityComposite)
103 _Entities.reserve(size);
106 //===============================================================================
107 void CStreamableEntityComposite::removeAll()
109 H_AUTO_USE(RZ_StremableEntityComposite)
110 for(TStreambleEntities::iterator it = _Entities.begin(); it != _Entities.end(); ++it)
112 delete *it;
114 NLMISC::contReset(_Entities);
118 //===============================================================================
119 void CStreamableEntityComposite::forceUnload()
121 H_AUTO_USE(RZ_StremableEntityComposite)
122 for(TStreambleEntities::iterator it = _Entities.begin(); it != _Entities.end(); ++it)
124 (*it)->forceUnload();