1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
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.
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/>.
20 #include "animation_fx_id_array.h"
21 #include "sheet_manager.h"
24 #include "nel/3d/u_scene.h"
30 extern NL3D::UScene
*Scene
;
32 // *********************************************************************
33 CAnimationFXIDArray::CAnimationFXIDArray()
38 // *********************************************************************
39 void CAnimationFXIDArray::release()
42 if (Scene
&& _AnimSet
)
44 Driver
->deleteAnimationSet(_AnimSet
);
49 // *********************************************************************
50 void CAnimationFXIDArray::init(const CIDToStringArraySheet
&sheet
, NL3D::UAnimationSet
*animSet
, bool mustDeleteAnimSet
/* = false*/)
53 // retrieve pointer on all fxs
54 for(uint k
= 0; k
< sheet
.Array
.size(); ++k
)
56 const CAnimationFXSheet
*afs
= dynamic_cast<const CAnimationFXSheet
*>(SheetMngr
.get(NLMISC::CSheetId(sheet
.Array
[k
].String
)));
60 idToFX
.FX
.init(afs
, animSet
);
61 idToFX
.ID
= sheet
.Array
[k
].ID
;
62 _IDToFXArray
.push_back(idToFX
);
66 std::sort(_IDToFXArray
.begin(), _IDToFXArray
.end());
67 if (mustDeleteAnimSet
)
73 // *********************************************************************
74 void CAnimationFXIDArray::init(const std::string
&sheetName
, NL3D::UAnimationSet
*animSet
, bool mustDeleteAnimSet
/*= false*/)
76 CIDToStringArraySheet
*array
= dynamic_cast<CIDToStringArraySheet
*>(SheetMngr
.get(NLMISC::CSheetId(sheetName
)));
79 init(*array
, animSet
, mustDeleteAnimSet
);
84 // *********************************************************************
85 const CAnimationFX
*CAnimationFXIDArray::getFX(uint32 id
) const
87 // after init, element are sorted by ids
90 std::vector
<CIDToFX
>::const_iterator it
= std::lower_bound(_IDToFXArray
.begin(), _IDToFXArray
.end(), comp
);
91 if (it
== _IDToFXArray
.end()) return NULL
;
92 if (it
->ID
!= id
) return NULL
;