#include <landscape_vegetable_block.h>
Inheritance diagram for NL3D::CLandscapeVegetableBlock:
Nevrax France
Definition at line 63 of file landscape_vegetable_block.h.
Public Member Functions | |
CLandscapeVegetableBlock () | |
Constructor. | |
void | init (const CVector ¢er, CVegetableManager *vegetManager, CVegetableClipBlock *vegetableClipBlock, CPatch *patch, uint ts, uint tt, CTessList< CLandscapeVegetableBlock > &list) |
build the vegetable block, create sortBlocks, and append to list. | |
void | release (CVegetableManager *vegeManager, CTessList< CLandscapeVegetableBlock > &list) |
release all IGs, reset the Vegetable block and remove from list. call before destruction. | |
void | update (const CVector &viewCenter, CVegetableManager *vegeManager) |
Data Fields | |
CTessNodeList * | Next |
CTessNodeList * | Prec |
Private Member Functions | |
void | createVegetableIGForDistType (uint i, CVegetableManager *vegeManager, CLandscapeVegetableBlockCreateContext &vbCreateCtx) |
Private Attributes | |
CVector | _Center |
The center of this object, to compute distance. | |
uint8 | _CurDistType |
The current distance type. 0 means all IG are created. NL3D_VEGETABLE_BLOCK_NUMDIST means none. | |
CPatch * | _Patch |
Which patch owns this block. | |
uint8 | _Ts |
Coordinate of the lower-left tile. 2x2 tile vegetables are generated. | |
uint8 | _Tt |
Coordinate of the lower-left tile. 2x2 tile vegetables are generated. | |
CVegetableClipBlock * | _VegetableClipBlock |
To which VegetableClipBlock we must add vegetables IGs. | |
CVegetableInstanceGroup * | _VegetableIG [NL3D_TESSBLOCK_TILESIZE][NL3D_VEGETABLE_BLOCK_NUMDIST] |
CVegetableSortBlock * | _VegetableSortBlock [NL3D_TESSBLOCK_TILESIZE] |
The sortBlocks generated by this vegetable block, one for each tilematerial. |
|
Constructor.
Definition at line 71 of file landscape_vegetable_block.cpp. References _CurDistType, _VegetableClipBlock, _VegetableIG, _VegetableSortBlock, NL3D_TESSBLOCK_TILESIZE, NL3D_VEGETABLE_BLOCK_NUMDIST, and uint.
00072 { 00073 _VegetableClipBlock= NULL; 00074 _CurDistType= NL3D_VEGETABLE_BLOCK_NUMDIST; 00075 00076 for(uint j=0;j<NL3D_TESSBLOCK_TILESIZE;j++) 00077 { 00078 _VegetableSortBlock[j]= NULL; 00079 for(uint i=0;i<NL3D_VEGETABLE_BLOCK_NUMDIST;i++) 00080 { 00081 _VegetableIG[j][i]= NULL; 00082 } 00083 } 00084 } |
|
Definition at line 227 of file landscape_vegetable_block.cpp. References _Patch, _Ts, _Tt, _VegetableIG, _VegetableSortBlock, NL3D::CVegetableManager::createIg(), NL3D::CVegetableManager::deleteIg(), NL3D::CPatch::generateTileVegetable(), NL3D_TESSBLOCK_TILESIZE, nlassert, sint, and uint. Referenced by update().
00229 { 00230 // check 00231 nlassert(NL3D_TESSBLOCK_TILESIZE==4); 00232 nlassert(_VegetableIG[0][i]==NULL); 00233 nlassert(_VegetableIG[1][i]==NULL); 00234 nlassert(_VegetableIG[2][i]==NULL); 00235 nlassert(_VegetableIG[3][i]==NULL); 00236 00237 // Create vegetables instances per tile_material. 00238 sint tms,tmt; 00239 // for all tiles 00240 nlassert(NL3D_TESSBLOCK_TILESIZE==4); 00241 for(tmt= _Tt; tmt<_Tt+2; tmt++) 00242 { 00243 for(tms= _Ts; tms<_Ts+2; tms++) 00244 { 00245 uint tileId= tms-_Ts + (tmt-_Tt)*2; 00246 00247 // create the instance group in the good sortBlock 00248 CVegetableInstanceGroup *vegetIg= vegeManager->createIg(_VegetableSortBlock[tileId]); 00249 _VegetableIG[tileId][i]= vegetIg; 00250 00251 // generate 00252 _Patch->generateTileVegetable(vegetIg, i, tms, tmt, vbCreateCtx); 00253 00254 // If the ig is empty, delete him. This optimize rendering because no unusefull ig are 00255 // tested for rendering. This speed up some 1/10 of ms... 00256 if(vegetIg->isEmpty()) 00257 { 00258 vegeManager->deleteIg(vegetIg); 00259 _VegetableIG[tileId][i]= NULL; 00260 } 00261 00262 // NB: vegtable SortBlock is updated in CLandscapeVegetableBlock::update() after 00263 } 00264 } 00265 00266 } |
|
build the vegetable block, create sortBlocks, and append to list.
Definition at line 89 of file landscape_vegetable_block.cpp. References _Patch, _Ts, _Tt, _VegetableClipBlock, _VegetableSortBlock, NL3D::CTessList< T >::append(), NL3D::CVegetableManager::createSortBlock(), NL3D::CBezierPatch::eval(), NL3D::CPatch::getOrderS(), NL3D::CPatch::getOrderT(), NL3D_PATCH_TILE_RADIUS, NL3D_TESSBLOCK_TILESIZE, nlassert, s, sint, t, uint, and NL3D::CPatch::unpackIntoCache(). Referenced by NL3D::CPatch::createVegetableBlock().
00091 { 00092 nlassert(patch); 00093 _Center= center; 00094 _VegetableClipBlock= vegetableClipBlock; 00095 _Patch= patch; 00096 _Ts= ts; 00097 _Tt= tt; 00098 00099 // Create the Vegetable SortBlocks 00100 sint tms,tmt; 00101 // for all tiles 00102 nlassert(NL3D_TESSBLOCK_TILESIZE==4); 00103 for(tmt= _Tt; tmt<_Tt+2; tmt++) 00104 { 00105 for(tms= _Ts; tms<_Ts+2; tms++) 00106 { 00107 // compute approximate center of the tile. 00108 float s= (tms + 0.5f) / _Patch->getOrderS(); 00109 float t= (tmt + 0.5f) / _Patch->getOrderT(); 00110 CBezierPatch *bpatch= _Patch->unpackIntoCache(); 00111 CVector center= bpatch->eval(s, t); 00112 00113 // create the sortBlock. NB: very approximate SortBlock radius.... 00114 _VegetableSortBlock[(tmt-_Tt)*2 + (tms-_Ts)]= vegetManager->createSortBlock(_VegetableClipBlock, center, NL3D_PATCH_TILE_RADIUS); 00115 } 00116 } 00117 00118 // append to list. 00119 vblist.append(this); 00120 } |
|
release all IGs, reset the Vegetable block and remove from list. call before destruction.
Definition at line 124 of file landscape_vegetable_block.cpp. References _CurDistType, _VegetableIG, _VegetableSortBlock, NL3D::CVegetableManager::deleteIg(), NL3D::CVegetableManager::deleteSortBlock(), NL3D_TESSBLOCK_TILESIZE, NL3D_VEGETABLE_BLOCK_NUMDIST, NL3D::CTessList< T >::remove(), and uint.
00125 { 00126 // release all Igs, and all Sbs. 00127 for(uint j=0;j<NL3D_TESSBLOCK_TILESIZE;j++) 00128 { 00129 // release IGs first. 00130 for(uint i=0;i<NL3D_VEGETABLE_BLOCK_NUMDIST;i++) 00131 { 00132 if(_VegetableIG[j][i]) 00133 { 00134 vegeManager->deleteIg(_VegetableIG[j][i]); 00135 _VegetableIG[j][i]= NULL; 00136 } 00137 } 00138 00139 // release SB 00140 if(_VegetableSortBlock[j]) 00141 { 00142 vegeManager->deleteSortBlock(_VegetableSortBlock[j]); 00143 _VegetableSortBlock[j]= NULL; 00144 } 00145 } 00146 00147 // reset state. 00148 _CurDistType= NL3D_VEGETABLE_BLOCK_NUMDIST; 00149 00150 // remove from list. 00151 vblist.remove(this); 00152 } |
|
update state of the vegetableBlock. If distance type change, then create / delete any wanted Ig. Warning! IG creation Use OptFastFloor()! So call must be enclosed with a OptFastFloorBegin()/OptFastFloorEnd(). Definition at line 155 of file landscape_vegetable_block.cpp. References _CurDistType, _Patch, _Ts, _Tt, _VegetableIG, _VegetableSortBlock, createVegetableIGForDistType(), NL3D::CVegetableManager::deleteIg(), NL3D::CLandscapeVegetableBlockCreateContext::init(), NL3D_TESSBLOCK_TILESIZE, uint, and NL3D::CVegetableSortBlock::updateSortBlock(). Referenced by NL3D::CLandscape::refine().
00156 { 00157 float sqrDist= (viewCenter-_Center).sqrnorm(); 00158 00159 // compute new distance type. Incremental mode. 00160 uint newDistType= _CurDistType; 00161 while(sqrDist<CLVBSqrDistLUT::Array[newDistType]) 00162 { 00163 newDistType--; 00164 } 00165 while(newDistType<NL3D_VEGETABLE_BLOCK_NUMDIST && sqrDist>CLVBSqrDistLUT::Array[newDistType+1]) 00166 { 00167 newDistType++; 00168 } 00169 /* 00170 NB: to test but may be better than 00171 newDistType= floor()(delta.norm() / NL3D_VEGETABLE_BLOCK_ELTDIST); 00172 */ 00173 00174 00175 // Change of distance type?? 00176 if(newDistType!=_CurDistType) 00177 { 00178 // Erase or create IGs. 00179 if(newDistType>_CurDistType) 00180 { 00181 // For all tiles 00182 for(uint j=0;j<NL3D_TESSBLOCK_TILESIZE;j++) 00183 { 00184 // Erase no more needed Igs. 00185 for(uint i=_CurDistType; i<newDistType; i++) 00186 { 00187 if(_VegetableIG[j][i]) 00188 { 00189 vegeManager->deleteIg(_VegetableIG[j][i]); 00190 _VegetableIG[j][i]= NULL; 00191 } 00192 } 00193 00194 // update the sort block for this tile 00195 _VegetableSortBlock[j]->updateSortBlock(*vegeManager); 00196 } 00197 } 00198 else 00199 { 00200 // Create a context for creation. 00201 CLandscapeVegetableBlockCreateContext ctx; 00202 ctx.init(_Patch, _Ts, _Tt); 00203 00204 // create new Igs, for all tiles 00205 for(uint i=newDistType; i<_CurDistType; i++) 00206 { 00207 createVegetableIGForDistType(i, vegeManager, ctx); 00208 } 00209 00210 // For all tiles 00211 for(uint j=0;j<NL3D_TESSBLOCK_TILESIZE;j++) 00212 { 00213 // update the sort block for this tile 00214 _VegetableSortBlock[j]->updateSortBlock(*vegeManager); 00215 } 00216 } 00217 00218 // copy new dist type. 00219 _CurDistType= newDistType; 00220 } 00221 00222 00223 } |
|
The center of this object, to compute distance.
Definition at line 90 of file landscape_vegetable_block.h. |
|
The current distance type. 0 means all IG are created. NL3D_VEGETABLE_BLOCK_NUMDIST means none.
Definition at line 98 of file landscape_vegetable_block.h. Referenced by CLandscapeVegetableBlock(), release(), and update(). |
|
Which patch owns this block.
Definition at line 94 of file landscape_vegetable_block.h. Referenced by createVegetableIGForDistType(), init(), and update(). |
|
Coordinate of the lower-left tile. 2x2 tile vegetables are generated.
Definition at line 96 of file landscape_vegetable_block.h. Referenced by createVegetableIGForDistType(), init(), and update(). |
|
Coordinate of the lower-left tile. 2x2 tile vegetables are generated.
Definition at line 96 of file landscape_vegetable_block.h. Referenced by createVegetableIGForDistType(), init(), and update(). |
|
To which VegetableClipBlock we must add vegetables IGs.
Definition at line 92 of file landscape_vegetable_block.h. Referenced by CLandscapeVegetableBlock(), and init(). |
|
The instance groups generated by this vegetable block, one for each distance type. and one per each tilematerial Definition at line 107 of file landscape_vegetable_block.h. Referenced by CLandscapeVegetableBlock(), createVegetableIGForDistType(), release(), and update(). |
|
The sortBlocks generated by this vegetable block, one for each tilematerial.
Definition at line 102 of file landscape_vegetable_block.h. Referenced by CLandscapeVegetableBlock(), createVegetableIGForDistType(), init(), release(), and update(). |
|
|
Definition at line 43 of file tess_list.h. Referenced by NL3D::CTessNodeList::CTessNodeList(). |