From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/a02708.html | 628 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 628 insertions(+) create mode 100644 docs/doxygen/nel/a02708.html (limited to 'docs/doxygen/nel/a02708.html') diff --git a/docs/doxygen/nel/a02708.html b/docs/doxygen/nel/a02708.html new file mode 100644 index 00000000..07fef19f --- /dev/null +++ b/docs/doxygen/nel/a02708.html @@ -0,0 +1,628 @@ + + +NeL: NL3D::CLandscapeCollisionGrid class Reference + + + +
+

NL3D::CLandscapeCollisionGrid Class Reference

#include <landscape_collision_grid.h> +

+


Detailed Description

+A grid of Tiles Id. Each CVisualCollisionEntity has such a grid. This looks like CQuadGrid, but with special features.
Author:
Lionel Berenguier

+Nevrax France

+
Date:
2001
+ +

+ +

+Definition at line 55 of file landscape_collision_grid.h. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Member Functions

void build (const std::vector< CPatchQuadBlock * > &quadBlocks, const CVector &delta)
 CLandscapeCollisionGrid (CVisualCollisionManager *owner)
 Constructor.

void clear ()
 clear the chainlist in the quadgrid.

CVisualTileDescNodeselect (const NLMISC::CVector &pos)
 select one entry in the chainQuad. pos is a position in World.

 ~CLandscapeCollisionGrid ()

Private Member Functions

void addQuadToGrid (uint16 paBlockId, uint16 quadId, sint minx, sint maxx, sint miny, sint maxy)

Private Attributes

bool _Cleared
 Array of list of CVisualTileDescNode.

CVector _Delta
CVisualTileDescNode_Grid [32 *32]
CVisualCollisionManager_Owner
uint _SizePower
+


Constructor & Destructor Documentation

+

+ + + + +
+ + + + + + + + + + +
NL3D::CLandscapeCollisionGrid::CLandscapeCollisionGrid CVisualCollisionManager owner  ) 
+
+ + + + + +
+   + + +

+Constructor. +

+ +

+Definition at line 40 of file landscape_collision_grid.cpp. +

+References _Cleared, _Grid, _SizePower, NLMISC::getPowerOf2(), NLMISC::isPowerOf2(), NL_COLGRID_SIZE, and nlassert. +

+

00041 {
+00042         _Owner= owner;
+00043         // reset list to NULL.
+00044         memset(_Grid, 0, NL_COLGRID_SIZE*NL_COLGRID_SIZE * sizeof(CVisualTileDescNode*));
+00045         _Cleared= true;
+00046 
+00047         // sizepower.
+00048         nlassert(isPowerOf2(NL_COLGRID_SIZE));
+00049         _SizePower= getPowerOf2(NL_COLGRID_SIZE);
+00050 }
+
+

+ + + + +
+ + + + + + + + + +
NL3D::CLandscapeCollisionGrid::~CLandscapeCollisionGrid  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 53 of file landscape_collision_grid.cpp. +

+References clear(). +

+

00054 {
+00055         clear();
+00056 }
+
+


Member Function Documentation

+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CLandscapeCollisionGrid::addQuadToGrid uint16  paBlockId,
uint16  quadId,
sint  minx,
sint  maxx,
sint  miny,
sint  maxy
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 213 of file landscape_collision_grid.cpp. +

+References _Grid, _SizePower, NL3D::CVisualCollisionManager::newVisualTileDescNode(), NL3D::CVisualTileDescNode::Next, NL_COLGRID_SIZE, nlassert, NL3D::CVisualTileDescNode::PatchQuadBlocId, NL3D::CVisualTileDescNode::QuadId, sint, uint16, x, and y. +

+Referenced by build(). +

+

00214 {
+00215         // coordinate should be positive.
+00216         nlassert(x0>=0 && x1>=x0);
+00217         nlassert(y0>=0 && y1>=y0);
+00218 
+00219         // first, transform coordinate (in meters) in quadgrid eltSize (ie 2 meters).
+00220         x0= (x0>>1);            // floor().
+00221         x1= (x1>>1) + 1;        // equivalent of ceil().
+00222         y0= (y0>>1);            // floor().
+00223         y1= (y1>>1) + 1;        // equivalent of ceil().
+00224 
+00225         // setup bounds in quadgrid coordinate.
+00226         if(x1-x0>=NL_COLGRID_SIZE)
+00227                 x0=0, x1= NL_COLGRID_SIZE;
+00228         else
+00229         {
+00230                 x0&= NL_COLGRID_SIZE-1;
+00231                 x1&= NL_COLGRID_SIZE-1;
+00232                 if(x1<=x0)
+00233                         x1+=NL_COLGRID_SIZE;
+00234         }
+00235         if(y1-y0>=NL_COLGRID_SIZE)
+00236                 y0=0, y1= NL_COLGRID_SIZE;
+00237         else
+00238         {
+00239                 y0&= NL_COLGRID_SIZE-1;
+00240                 y1&= NL_COLGRID_SIZE-1;
+00241                 if(y1<=y0)
+00242                         y1+=NL_COLGRID_SIZE;
+00243         }
+00244 
+00245         // fill all cases with element.
+00246         sint    x,y;
+00247         for(y= y0;y<y1;y++)
+00248         {
+00249                 sint    xe,ye;
+00250                 ye= y &(NL_COLGRID_SIZE-1);
+00251                 for(x= x0;x<x1;x++)
+00252                 {
+00253                         xe= x &(NL_COLGRID_SIZE-1);
+00254                         // which case we add the element.
+00255                         sint gridId= (ye<<_SizePower)+xe;
+00256 
+00257                         // allocate element.
+00258                         CVisualTileDescNode             *elt= _Owner->newVisualTileDescNode();
+00259 
+00260                         // fill elt.
+00261                         elt->PatchQuadBlocId= paBlockId;
+00262                         elt->QuadId= quadId;
+00263 
+00264                         // bind elt to the list.
+00265                         elt->Next= _Grid[gridId];
+00266                         _Grid[gridId]= elt;
+00267                 }
+00268         }
+00269 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CLandscapeCollisionGrid::build const std::vector< CPatchQuadBlock * > &  quadBlocks,
const CVector delta
+
+ + + + + +
+   + + +

+Build the quadgrid with a array of patchblock. delta is the vector to apply to tiles coordinate, before insertion in the quadgrid (for precision consideration). +

+Definition at line 147 of file landscape_collision_grid.cpp. +

+References _Cleared, _Delta, addQuadToGrid(), clear(), NL3D::fastFloor(), NL3D::fastFloorBegin(), NL3D::fastFloorEnd(), min, NL_PATCH_BLOCK_MAX_QUAD, NL_PATCH_BLOCK_MAX_VERTEX, NL3D::CPatchQuadBlock::PatchBlockId, NL3D::CPatchBlockIdent::S0, NL3D::CPatchBlockIdent::S1, sint, NL3D::CPatchBlockIdent::T0, NL3D::CPatchBlockIdent::T1, NL3D::CPatchQuadBlock::Vertices, NLMISC::CVector::x, NL3D::CVector2i::x, x, NLMISC::CVector::y, NL3D::CVector2i::y, and y. +

+Referenced by NL3D::CVisualCollisionEntity::doComputeLandscape(). +

+

00148 {
+00149         sint    x,y;
+00150         static CVector2i        floorVals[NL_PATCH_BLOCK_MAX_VERTEX*NL_PATCH_BLOCK_MAX_VERTEX];
+00151 
+00152         // first clear
+00153         clear();
+00154 
+00155         // init for fast floor.
+00156         fastFloorBegin();
+00157 
+00158         // then fill.
+00159         _Cleared= false;
+00160         _Delta= delta;
+00161         // parse all quad blocks.
+00162         for(sint i=0; i<(sint)quadBlocks.size();i++)
+00163         {
+00164                 CPatchQuadBlock         &qb= *quadBlocks[i];
+00165                 sint            lenS= qb.PatchBlockId.S1 - qb.PatchBlockId.S0;
+00166                 sint            lenT= qb.PatchBlockId.T1 - qb.PatchBlockId.T0;
+00167 
+00168                 // First, floor all vertices of interest.
+00169                 for(y=0; y<lenT+1; y++)
+00170                 {
+00171                         for(x=0; x<lenS+1; x++)
+00172                         {
+00173                                 sint    id= y*NL_PATCH_BLOCK_MAX_VERTEX + x;
+00174                                 // Add delta, and floor to sint.
+00175                                 floorVals[id].x= fastFloor(qb.Vertices[id].x + delta.x);
+00176                                 floorVals[id].y= fastFloor(qb.Vertices[id].y + delta.y);
+00177                         }
+00178                 }
+00179 
+00180                 // Then compute min max for all quads, and insert quad id in the quadGrid.
+00181                 for(y=0; y<lenT; y++)
+00182                 {
+00183                         for(x=0; x<lenS; x++)
+00184                         {
+00185                                 sint    minx, maxx, miny, maxy;
+00186                                 sint    id= y*NL_PATCH_BLOCK_MAX_VERTEX + x;
+00187                                 // Compute min max of the 4 vertices.
+00188                                 minx= floorVals[id].x; maxx= floorVals[id].x;
+00189                                 miny= floorVals[id].y; maxy= floorVals[id].y;
+00190                                 id++;
+00191                                 minx= min(minx, floorVals[id].x); maxx= max(maxx, floorVals[id].x);
+00192                                 miny= min(miny, floorVals[id].y); maxy= max(maxy, floorVals[id].y);
+00193                                 id+= NL_PATCH_BLOCK_MAX_VERTEX;
+00194                                 minx= min(minx, floorVals[id].x); maxx= max(maxx, floorVals[id].x);
+00195                                 miny= min(miny, floorVals[id].y); maxy= max(maxy, floorVals[id].y);
+00196                                 id--;
+00197                                 minx= min(minx, floorVals[id].x); maxx= max(maxx, floorVals[id].x);
+00198                                 miny= min(miny, floorVals[id].y); maxy= max(maxy, floorVals[id].y);
+00199 
+00200                                 // store minmax in the quad.
+00201                                 sint    quadId= y*NL_PATCH_BLOCK_MAX_QUAD + x;
+00202                                 addQuadToGrid(i, quadId, minx, maxx, miny, maxy);
+00203                         }
+00204                 }
+00205         }
+00206 
+00207         // init for fast floor.
+00208         fastFloorEnd();
+00209 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CLandscapeCollisionGrid::clear  ) 
+
+ + + + + +
+   + + +

+clear the chainlist in the quadgrid. +

+ +

+Definition at line 59 of file landscape_collision_grid.cpp. +

+References _Cleared, _Grid, NL3D::CVisualCollisionManager::deleteVisualTileDescNode(), NL3D::CVisualTileDescNode::Next, NL_COLGRID_SIZE, and sint. +

+Referenced by build(), ~CLandscapeCollisionGrid(), and NL3D::CVisualCollisionEntity::~CVisualCollisionEntity(). +

+

00060 {
+00061         // already cleared? do nothing.
+00062         if(_Cleared)
+00063                 return;
+00064 
+00065         // Parse all quads.
+00066         sint    i;
+00067         for(i=0;i<NL_COLGRID_SIZE*NL_COLGRID_SIZE;i++)
+00068         {
+00069                 CVisualTileDescNode                     *ptr, *next;
+00070                 ptr= _Grid[i];
+00071 
+00072                 // delete list of node.
+00073                 while(ptr)
+00074                 {
+00075                         next= ptr->Next;
+00076                         _Owner->deleteVisualTileDescNode(ptr);
+00077                         ptr= next;
+00078                 }
+00079 
+00080                 // reset root.
+00081                 _Grid[i]= NULL;
+00082         }
+00083 
+00084         _Cleared= true;
+00085 }
+
+

+ + + + +
+ + + + + + + + + + +
CVisualTileDescNode * NL3D::CLandscapeCollisionGrid::select const NLMISC::CVector pos  ) 
+
+ + + + + +
+   + + +

+select one entry in the chainQuad. pos is a position in World. +

+ +

+Definition at line 273 of file landscape_collision_grid.cpp. +

+References _Delta, _Grid, NL_COLGRID_SIZE, sint, NLMISC::CVector::x, x, NLMISC::CVector::y, and y. +

+Referenced by NL3D::CVisualCollisionEntity::getPatchTriangleUnderUs(). +

+

00274 {
+00275         // compute pos in the quadgrid.
+00276         CVector         localPos;
+00277         localPos= pos + _Delta;
+00278         // cases are 2x2 meters.
+00279         localPos/=2;
+00280 
+00281         // floor, bound in quadgrid coordinate.
+00282         sint    x,y;
+00283         x= (sint)floor(localPos.x);
+00284         y= (sint)floor(localPos.y);
+00285         x&= NL_COLGRID_SIZE-1;
+00286         y&= NL_COLGRID_SIZE-1;
+00287 
+00288         return _Grid[y*NL_COLGRID_SIZE+x];
+00289 }
+
+


Field Documentation

+

+ + + + +
+ + +
bool NL3D::CLandscapeCollisionGrid::_Cleared [private] +
+
+ + + + + +
+   + + +

+Array of list of CVisualTileDescNode. +

+ +

+Definition at line 82 of file landscape_collision_grid.h. +

+Referenced by build(), CLandscapeCollisionGrid(), and clear().

+

+ + + + +
+ + +
CVector NL3D::CLandscapeCollisionGrid::_Delta [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 85 of file landscape_collision_grid.h. +

+Referenced by build(), and select().

+

+ + + + +
+ + +
CVisualTileDescNode* NL3D::CLandscapeCollisionGrid::_Grid[ 32 * 32 ] [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 83 of file landscape_collision_grid.h. +

+Referenced by addQuadToGrid(), CLandscapeCollisionGrid(), clear(), and select().

+

+ + + + +
+ + +
CVisualCollisionManager* NL3D::CLandscapeCollisionGrid::_Owner [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 78 of file landscape_collision_grid.h.

+

+ + + + +
+ + +
uint NL3D::CLandscapeCollisionGrid::_SizePower [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 84 of file landscape_collision_grid.h. +

+Referenced by addQuadToGrid(), and CLandscapeCollisionGrid().

+


The documentation for this class was generated from the following files: +
Generated on Tue Mar 16 06:48:38 2004 for NeL by + +doxygen +1.3.6
+ + -- cgit v1.2.1