#include <vegetable_sort_block.h>
Inheritance diagram for NL3D::CVegetableSortBlock:
Nevrax France
Definition at line 56 of file vegetable_sort_block.h.
Public Member Functions | |
CVegetableSortBlock () | |
Constructor. | |
const CVector & | getCenter () const |
void | updateSortBlock (CVegetableManager &vegetManager) |
Data Fields | |
CTessNodeList * | Next |
CTessNodeList * | Prec |
Private Attributes | |
bool | _Dirty |
CTessList< CVegetableInstanceGroup > | _InstanceGroupList |
CVegetableClipBlock * | _Owner |
bool | _UnderWater |
bool | ZSortHardMode |
Fast sorting. | |
CVector | _Center |
center of the sort block. | |
uint | _NIndices |
number of indeices= numTriangles*3. | |
uint | _NTriangles |
number of triangles. | |
uint | _QuadrantId |
current quadrant used. computed at each render. | |
float | _Radius |
approximate Radius of the sort block. | |
NLMISC::CObjectVector< uint32, false > | _SortedTriangleArray |
uint32 * | _SortedTriangleIndices [NL3D_VEGETABLE_NUM_QUADRANT] |
start ptr. | |
float | _SortKey |
Positive value used for sort. (square of distance to viewer + threshold). temp computed at each render(). | |
Friends | |
class | CSortVSB |
class | CVegetableBlendLayerModel |
class | CVegetableClipBlock |
class | CVegetableManager |
|
Constructor.
Definition at line 46 of file vegetable_sort_block.cpp. References _NIndices, _NTriangles, _UnderWater, and ZSortHardMode.
00047 { 00048 ZSortHardMode= true; 00049 _NTriangles= 0; 00050 _NIndices= 0; 00051 _Dirty= false; 00052 _UnderWater= false; 00053 } |
|
Definition at line 64 of file vegetable_sort_block.h.
00064 {return _Center;} |
|
After adding some instance to any instance group of a sorted block, you must recall this method NB: CVegetableManager::addInstance() and CVegetableManager::deleteIg() flag this SB as Dirty, when needed only. if !Dirty, updateSortBlock() is a no-op. /see CVegetableManager::addInstance() CVegetableManager::deleteIg() Warning! Use OptFastFloor()! So call must be enclosed with a OptFastFloorBegin()/OptFastFloorEnd(). Definition at line 74 of file vegetable_sort_block.cpp. References _InstanceGroupList, _NIndices, _NTriangles, NL3D::CVegetableInstanceGroup::_RdrPass, _SortedTriangleArray, _SortedTriangleIndices, NL3D::CVegetableInstanceGroup::_TriangleQuadrantOrders, NL3D::CTessList< CVegetableInstanceGroup >::begin(), NLMISC::CObjectVector< uint32, false >::clear(), NL3D::CSortTri::Dist, NLMISC::CObjectVector< uint32, false >::getPtr(), H_AUTO, NL3D::CTessNodeList::Next, NL3D_VEGETABLE_NUM_QUADRANT, NL3D_VEGETABLE_RDRPASS_UNLIT_2SIDED_ZSORT, nlassert, NL3D::CVegetableInstanceGroup::CVegetableRdrPass::NTriangles, NLMISC::CObjectVector< uint32, false >::resize(), NL3D::CVegetableInstanceGroup::CVegetableRdrPass::TriangleIndices, NL3D::CSortTri::TriIndex, uint, and uint32. Referenced by NL3D::CLandscapeVegetableBlock::update().
00075 { 00076 H_AUTO( NL3D_Vegetable_Update_SortBlock ); 00077 00078 // if nothing to update (ie instance added/deleted do not impact me). 00079 if(!_Dirty) 00080 { 00081 // nothing to do. 00082 return; 00083 } 00084 else 00085 { 00086 // Ok clean me now. 00087 _Dirty= false; 00088 } 00089 00090 // compute number of triangles. 00091 _NTriangles= 0; 00092 CVegetableInstanceGroup *ptrIg= _InstanceGroupList.begin(); 00093 while(ptrIg) 00094 { 00095 // add only zsort rdrPass triangles. 00096 _NTriangles+= ptrIg->_RdrPass[NL3D_VEGETABLE_RDRPASS_UNLIT_2SIDED_ZSORT].NTriangles; 00097 00098 // next Ig in the SortBlock 00099 ptrIg= (CVegetableInstanceGroup*)(ptrIg->Next); 00100 } 00101 // compute number of indices 00102 _NIndices= _NTriangles*3; 00103 00104 00105 // if no triangles, clear and go 00106 if(_NTriangles == 0) 00107 { 00108 // reset the array of indices. 00109 _SortedTriangleArray.clear(); 00110 // bye 00111 return; 00112 } 00113 else 00114 { 00115 // else, re-allocate the array 00116 _SortedTriangleArray.resize(_NIndices * NL3D_VEGETABLE_NUM_QUADRANT); 00117 } 00118 00119 // resize an array for sorting. 00120 nlassert(_NTriangles < 65536); 00121 static std::vector<CSortTri> triSort; 00122 static std::vector<uint32> triIndices; 00123 // don't use resize because fill with default values. size() is the capacity here. 00124 if(triSort.size()<_NTriangles) 00125 { 00126 triSort.resize(_NTriangles); 00127 triIndices.resize(_NIndices); 00128 } 00129 00130 // fill indices with all ig info. 00131 //------------- 00132 { 00133 uint32 *triIdxPtr= &triIndices[0]; 00134 // for all igs in the sortBlock. 00135 ptrIg= _InstanceGroupList.begin(); 00136 while(ptrIg) 00137 { 00138 CVegetableInstanceGroup::CVegetableRdrPass &vegetRdrPass= ptrIg->_RdrPass[NL3D_VEGETABLE_RDRPASS_UNLIT_2SIDED_ZSORT]; 00139 uint32 *triSrcPtr= vegetRdrPass.TriangleIndices.getPtr(); 00140 00141 // add only zsort rdrPass triangles. 00142 for(uint i=0; i<vegetRdrPass.NTriangles; i++) 00143 { 00144 // fill the triangle indices. 00145 *(triIdxPtr++)= *(triSrcPtr++); 00146 *(triIdxPtr++)= *(triSrcPtr++); 00147 *(triIdxPtr++)= *(triSrcPtr++); 00148 } 00149 00150 // next Ig in the SortBlock 00151 ptrIg= (CVegetableInstanceGroup*)(ptrIg->Next); 00152 } 00153 } 00154 00155 // Sort for all quadrants 00156 //------------- 00157 for(uint quadrant=0; quadrant<NL3D_VEGETABLE_NUM_QUADRANT; quadrant++) 00158 { 00159 // ReFill SortTris with Start Data 00160 //------------- 00161 CSortTri *triPtr= &triSort[0]; 00162 uint triId= 0; 00163 // for all igs in the sortBlock. 00164 ptrIg= _InstanceGroupList.begin(); 00165 while(ptrIg) 00166 { 00167 CVegetableInstanceGroup::CVegetableRdrPass &vegetRdrPass= ptrIg->_RdrPass[NL3D_VEGETABLE_RDRPASS_UNLIT_2SIDED_ZSORT]; 00168 00169 // add only zsort rdrPass triangles. 00170 for(uint i=0; i<vegetRdrPass.NTriangles; i++, triPtr++, triId++) 00171 { 00172 // QSort. 00173 triPtr->Dist = ptrIg->_TriangleQuadrantOrders[quadrant][i]; 00174 00175 // copy tri info 00176 triPtr->TriIndex= triId; 00177 } 00178 00179 // next Ig in the SortBlock 00180 ptrIg= (CVegetableInstanceGroup*)(ptrIg->Next); 00181 } 00182 00183 // sort the array according to distance 00184 //------------- 00185 // QSort. 00186 sort(triSort.begin(), triSort.begin()+_NTriangles); 00187 00188 00189 // Fill result. 00190 //------------- 00191 // init quadrant ptr. 00192 _SortedTriangleIndices[quadrant]= _SortedTriangleArray.getPtr() + quadrant * _NIndices; 00193 00194 // fill the indices. 00195 uint32 *pIdx= _SortedTriangleIndices[quadrant]; 00196 for(uint i=0; i<_NTriangles; i++) 00197 { 00198 uint32 idTriIdx= triSort[i].TriIndex * 3; 00199 *(pIdx++)= triIndices[idTriIdx+0]; 00200 *(pIdx++)= triIndices[idTriIdx+1]; 00201 *(pIdx++)= triIndices[idTriIdx+2]; 00202 } 00203 } 00204 } |
|
Definition at line 78 of file vegetable_sort_block.h. |
|
Definition at line 80 of file vegetable_sort_block.h. |
|
Definition at line 79 of file vegetable_sort_block.h. |
|
Definition at line 77 of file vegetable_sort_block.h. |
|
center of the sort block.
Definition at line 96 of file vegetable_sort_block.h. Referenced by NL3D::CVegetableManager::addInstance(), NL3D::CVegetableManager::createSortBlock(), and NL3D::CVegetableManager::render(). |
|
Definition at line 88 of file vegetable_sort_block.h. Referenced by NL3D::CVegetableManager::addInstance(), and NL3D::CVegetableManager::deleteIg(). |
|
Definition at line 118 of file vegetable_sort_block.h. Referenced by NL3D::CVegetableManager::addInstance(), NL3D::CVegetableManager::createIg(), NL3D::CVegetableManager::deleteIg(), NL3D::CVegetableManager::deleteSortBlock(), NL3D::CVegetableManager::render(), and updateSortBlock(). |
|
number of indeices= numTriangles*3.
Definition at line 113 of file vegetable_sort_block.h. Referenced by CVegetableSortBlock(), and updateSortBlock(). |
|
number of triangles.
Definition at line 111 of file vegetable_sort_block.h. Referenced by CVegetableSortBlock(), NL3D::CVegetableManager::render(), NL3D::CVegetableBlendLayerModel::render(), and updateSortBlock(). |
|
Definition at line 84 of file vegetable_sort_block.h. Referenced by NL3D::CVegetableManager::createIg(), NL3D::CVegetableManager::createSortBlock(), and NL3D::CVegetableManager::deleteSortBlock(). |
|
current quadrant used. computed at each render.
Definition at line 103 of file vegetable_sort_block.h. Referenced by NL3D::CVegetableManager::render(), and NL3D::CVegetableBlendLayerModel::render(). |
|
approximate Radius of the sort block.
Definition at line 98 of file vegetable_sort_block.h. Referenced by NL3D::CVegetableManager::addInstance(), NL3D::CVegetableManager::createSortBlock(), and NL3D::CVegetableManager::render(). |
|
Quadrants. the big array of indices, for the NL3D_VEGETABLE_NUM_QUADRANT quadrants. Definition at line 107 of file vegetable_sort_block.h. Referenced by updateSortBlock(). |
|
start ptr.
Definition at line 109 of file vegetable_sort_block.h. Referenced by NL3D::CVegetableBlendLayerModel::render(), and updateSortBlock(). |
|
Positive value used for sort. (square of distance to viewer + threshold). temp computed at each render().
Definition at line 101 of file vegetable_sort_block.h. Referenced by NL3D::CSortVSB::operator<(), and NL3D::CVegetableManager::render(). |
|
Definition at line 91 of file vegetable_sort_block.h. Referenced by NL3D::CVegetableManager::addInstance(), CVegetableSortBlock(), and NL3D::CVegetableManager::render(). |
|
|
Definition at line 43 of file tess_list.h. Referenced by NL3D::CTessNodeList::CTessNodeList(). |
|
Definition at line 122 of file vegetable_sort_block.h. Referenced by NL3D::CVegetableManager::addInstance(), NL3D::CVegetableManager::createIg(), CVegetableSortBlock(), and NL3D::CVegetableBlendLayerModel::render(). |