1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
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/>.
19 #include "nel/3d/anim_detail_trav.h"
20 #include "nel/3d/hrc_trav.h"
21 #include "nel/3d/transform.h"
22 #include "nel/3d/skeleton_model.h"
23 #include "nel/misc/hierarchical_timer.h"
24 #include "nel/misc/debug.h"
27 using namespace NLMISC
;
37 // ***************************************************************************
38 CAnimDetailTrav::CAnimDetailTrav()
42 _VisibleList
.resize(1024);
43 _CurrentNumVisibleModels
= 0;
46 // ***************************************************************************
47 void CAnimDetailTrav::clearVisibleList()
49 _CurrentNumVisibleModels
= 0;
53 // ***************************************************************************
54 void CAnimDetailTrav::traverse()
56 H_AUTO( NL3D_TravAnimDetail
);
61 // Traverse all nodes of the visibility list.
62 for(uint i
=0; i
<_CurrentNumVisibleModels
; i
++)
64 // NB: some model creation may be done by CParticleSystemModel during this pass.
65 // createModel() may resize _VisibleList.
66 // Hence, must test the actual _VisibleList vector, and not a temporary pointer.
67 CTransform
*model
= _VisibleList
[i
];
68 // If this object has an ancestorSkeletonModel
69 if(model
->_AncestorSkeletonModel
)
71 // then just skip it! because it will be parsed hierarchically by the first
72 // skeletonModel whith _AncestorSkeletonModel==NULL. (only if this one is visible)
77 // If this is a skeleton model, and because _AncestorSkeletonModel==NULL,
78 // then it means that it is the Root of a hierarchy of transform that have
79 // _AncestorSkeletonModel!=NULL.
80 if( model
->isSkeleton() )
82 // Then I must update hierarchically me and the sons (according to HRC hierarchy graph) of this model.
83 traverseHrcRecurs(model
);
87 // else, just traverse AnimDetail, an do nothing for Hrc sons
88 model
->traverseAnimDetail();
95 // ***************************************************************************
96 void CAnimDetailTrav::traverseHrcRecurs(CTransform
*model
)
98 // first, just doIt me
99 model
->traverseAnimDetail();
102 // then doIt my sons in Hrc.
103 uint num
= model
->hrcGetNumChildren();
104 for(uint i
=0;i
<num
;i
++)
105 traverseHrcRecurs(model
->hrcGetChild(i
));
109 // ***************************************************************************
110 void CAnimDetailTrav::reserveVisibleList(uint numModels
)
113 if(numModels
>_VisibleList
.size())
114 _VisibleList
.resize(numModels
);