00001 00005 /* Copyright, 2001 Nevrax Ltd. 00006 * 00007 * This file is part of NEVRAX NEL. 00008 * NEVRAX NEL is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2, or (at your option) 00011 * any later version. 00012 00013 * NEVRAX NEL is distributed in the hope that it will be useful, but 00014 * WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * General Public License for more details. 00017 00018 * You should have received a copy of the GNU General Public License 00019 * along with NEVRAX NEL; see the file COPYING. If not, write to the 00020 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 00021 * MA 02111-1307, USA. 00022 */ 00023 00024 #include "std3d.h" 00025 00026 #include "nel/3d/anim_detail_trav.h" 00027 #include "nel/3d/hrc_trav.h" 00028 #include "nel/3d/transform.h" 00029 #include "nel/3d/skeleton_model.h" 00030 #include "nel/misc/hierarchical_timer.h" 00031 #include "nel/misc/debug.h" 00032 00033 00034 using namespace NLMISC; 00035 00036 00037 namespace NL3D 00038 { 00039 00040 00041 // *************************************************************************** 00042 CAnimDetailTrav::CAnimDetailTrav() 00043 { 00044 CurrentDate=0; 00045 // prepare some space 00046 _VisibleList.resize(1024); 00047 _CurrentNumVisibleModels= 0; 00048 } 00049 00050 // *************************************************************************** 00051 void CAnimDetailTrav::clearVisibleList() 00052 { 00053 _CurrentNumVisibleModels= 0; 00054 } 00055 00056 00057 // *************************************************************************** 00058 void CAnimDetailTrav::traverse() 00059 { 00060 H_AUTO( NL3D_TravAnimDetail ); 00061 00062 // Inc the date. 00063 CurrentDate++; 00064 00065 // Traverse all nodes of the visibility list. 00066 for(uint i=0; i<_CurrentNumVisibleModels; i++) 00067 { 00068 // NB: some model creation may be done by CParticleSystemModel during this pass. 00069 // createModel() may resize _VisibleList. 00070 // Hence, must test the actual _VisibleList vector, and not a temporary pointer. 00071 CTransform *model= _VisibleList[i]; 00072 // If this object has an ancestorSkeletonModel 00073 if(model->_AncestorSkeletonModel) 00074 { 00075 // then just skip it! because it will be parsed hierarchically by the first 00076 // skeletonModel whith _AncestorSkeletonModel==NULL. (only if this one is visible) 00077 continue; 00078 } 00079 else 00080 { 00081 // If this is a skeleton model, and because _AncestorSkeletonModel==NULL, 00082 // then it means that it is the Root of a hierarchy of transform that have 00083 // _AncestorSkeletonModel!=NULL. 00084 if( model->isSkeleton() ) 00085 { 00086 // Then I must update hierarchically me and the sons (according to HRC hierarchy graph) of this model. 00087 traverseHrcRecurs(model); 00088 } 00089 else 00090 { 00091 // else, just traverse AnimDetail, an do nothing for Hrc sons 00092 model->traverseAnimDetail(); 00093 } 00094 } 00095 } 00096 } 00097 00098 00099 // *************************************************************************** 00100 void CAnimDetailTrav::traverseHrcRecurs(CTransform *model) 00101 { 00102 // first, just doIt me 00103 model->traverseAnimDetail(); 00104 00105 00106 // then doIt my sons in Hrc. 00107 uint num= model->hrcGetNumChildren(); 00108 for(uint i=0;i<num;i++) 00109 traverseHrcRecurs(model->hrcGetChild(i)); 00110 } 00111 00112 00113 // *************************************************************************** 00114 void CAnimDetailTrav::reserveVisibleList(uint numModels) 00115 { 00116 // enlarge only. 00117 if(numModels>_VisibleList.size()) 00118 _VisibleList.resize(numModels); 00119 } 00120 00121 00122 } // NL3D
1.6.1