#include <landscape_face_vector_manager.h>
Nevrax France
Definition at line 44 of file landscape_face_vector_manager.h.
Public Member Functions | |
CLandscapeFaceVectorManager () | |
Constructor. | |
uint32 * | createFaceVector (uint numTri) |
void | deleteFaceVector (uint32 *fv) |
delete a faceVector. NB: no check. | |
void | purge () |
~CLandscapeFaceVectorManager () | |
Private Member Functions | |
uint | getBlockIdFromNumTri (uint numTris) |
Private Attributes | |
std::vector< uint32 * > | _Blocks |
|
Constructor.
Definition at line 45 of file landscape_face_vector_manager.cpp. References _Blocks, and NL3D_FACE_VECTOR_NUMBLOCK.
00046 { 00047 // Allow 2^32 triangles at max. each list i has at max 2^i triangles. 00048 _Blocks.resize(NL3D_FACE_VECTOR_NUMBLOCK, NULL); 00049 } |
|
Definition at line 52 of file landscape_face_vector_manager.cpp. References purge().
00053 { 00054 purge(); 00055 } |
|
return an Array of Tris with this Format: NumTris, index0, index1, index2.... NB: NumTris really means number of triangles, not number of indexes (which is 3*)! Definition at line 83 of file landscape_face_vector_manager.cpp. References _Blocks, getBlockIdFromNumTri(), uint, and uint32. Referenced by NL3D::CTessBlock::createFaceVectorFar0(), NL3D::CTessBlock::createFaceVectorFar1(), and NL3D::CTessBlock::createFaceVectorTile().
00084 { 00085 // get the BlockId from the number of tri in this fv 00086 uint blockId= getBlockIdFromNumTri(numTri); 00087 00088 // If no more free FaceVector, allocate. 00089 if(_Blocks[blockId]==NULL) 00090 { 00091 // Allocate a block of max tris. +1 is for the NumTris entry at index 0. 00092 uint numTriMax= 1<<blockId; 00093 // allocate max of (sizeof(uint32*), (numTriMax*3+1)*sizeof(uint32)); 00094 uint sizeInByteToAllocate= max(sizeof(uint32*), (numTriMax*3+1)*sizeof(uint32)); 00095 _Blocks[blockId]= new uint32[sizeInByteToAllocate/4]; 00096 // Init it as a free faceVector, with no Next. 00097 *(uint32**)_Blocks[blockId]= NULL; 00098 } 00099 00100 // Pop a FaceVector from the free list. 00101 uint32 *ret= _Blocks[blockId]; 00102 // Make the head list point to next 00103 _Blocks[blockId]= *(uint32**)ret; 00104 00105 // There is numTri triangles. 00106 *ret= numTri; 00107 00108 return ret; 00109 } |
|
delete a faceVector. NB: no check.
Definition at line 112 of file landscape_face_vector_manager.cpp. References _Blocks, getBlockIdFromNumTri(), uint, and uint32. Referenced by NL3D::CTessBlock::deleteFaceVectorFar0(), NL3D::CTessBlock::deleteFaceVectorFar1(), and NL3D::CTessBlock::deleteFaceVectorTile().
00113 { 00114 // get the BlockId from the number of tri in this fv (ie *fv) 00115 uint blockId= getBlockIdFromNumTri(*fv); 00116 00117 // Append this block to the free list. Write the ptr directly on fv. 00118 *(uint32**)fv= _Blocks[blockId]; 00119 _Blocks[blockId]= fv; 00120 } |
|
Definition at line 77 of file landscape_face_vector_manager.cpp. References NLMISC::getPowerOf2(), and uint. Referenced by createFaceVector(), and deleteFaceVector().
00078 { 00079 return getPowerOf2(numTris); 00080 } |
|
Definition at line 58 of file landscape_face_vector_manager.cpp. References _Blocks, NL3D_FACE_VECTOR_NUMBLOCK, uint, and uint32. Referenced by ~CLandscapeFaceVectorManager().
00059 { 00060 for(uint i=0; i<NL3D_FACE_VECTOR_NUMBLOCK; i++) 00061 { 00062 uint32 *ptr= _Blocks[i]; 00063 // For each node in list, delete. 00064 while(ptr) 00065 { 00066 // Get the ptr on next free list. 00067 uint32 *next= *(uint32**)ptr; 00068 delete [] ptr; 00069 ptr= next; 00070 } 00071 // list is empty. 00072 _Blocks[i]= NULL; 00073 } 00074 } |
|
Definition at line 65 of file landscape_face_vector_manager.h. Referenced by CLandscapeFaceVectorManager(), createFaceVector(), deleteFaceVector(), and purge(). |