# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

NL3D::CTessFacePriorityList Class Reference

This class manage a Priority list of elements, inserted with a "distance". More...

#include <tess_face_priority_list.h>

List of all members.

Public Methods

 CTessFacePriorityList ()
 Constructor. More...

 ~CTessFacePriorityList ()
void init (float distStep, uint numEntries, float distMaxMod, uint numQuadrant)
 Clear and Init the priority list. More...

void clear ()
 Clear the priority list. More...

uint selectQuadrant (const NLMISC::CVector &direction)
 prior to insert an element with a direction notion, select which quadrant according to the direction Camera -> center of interest. More...

const NLMISC::CVectorgetQuadrantDirection (uint quadrantId) const
 get the quadrant dir associated to the Id. More...

void insert (uint quadrantId, float distance, CTessFace *value)
 Insert an element at a given distance, and in a given quadrant. More...

void shift (const NLMISC::CVector &direction, CTessFacePListNode &pulledElements)
 Shift the Priority list in a given direction. More...

void shiftAll (CTessFacePListNode &pulledElements)
 Same as shift(), but shift all the array. More...


Private Attributes

float _Remainder
float _OODistStep
uint _NEntries
uint _MaskEntries
uint _EntryModStart
uint _NumQuadrant
uint _MaskQuadrant
uint _QuarterQuadrantStart [4]
uint _QuarterQuadrantEnd [4]
The rolling tables
std::vector< CRollingTable_RollingTables


Detailed Description

This class manage a Priority list of elements, inserted with a "distance".

The priority list can be shifted, so elements with new distance <=0 are pulled from the priority list.

NB: it works quite well if you have (as example) a distStep of 1, and you shift only with value of 0.01 etc.., because it manages a "Remainder system", which do the good stuff. How does it works? in essence, it is a Rolling table, with 1+ shift back when necessary (maybe not at each shift()).

Additionally, it includes a "2D quadrant" notion. If you use this class to know when the "camera" enters a specific area, then Quadrants help you because the notion of direction is kept. Only the XY plane is used here.

Instead, if you use this class to know when the "camera" leaves a specific area, then the quadrant notion is not interesting since the camera can leave the area in any direction...

Author:
Lionel Berenguier , Nevrax France
Date:
2001

Definition at line 112 of file tess_face_priority_list.h.


Constructor & Destructor Documentation

NL3D::CTessFacePriorityList::CTessFacePriorityList  
 

Constructor.

Definition at line 134 of file tess_face_priority_list.cpp.

References _EntryModStart, _MaskEntries, _NEntries, _NumQuadrant, and _OODistStep.

NL3D::CTessFacePriorityList::~CTessFacePriorityList  
 

Definition at line 144 of file tess_face_priority_list.cpp.

References clear.


Member Function Documentation

void NL3D::CTessFacePriorityList::clear  
 

Clear the priority list.

All elements are removed. NB: for convenience, the remainder is reset.

Definition at line 201 of file tess_face_priority_list.cpp.

References _RollingTables.

Referenced by init, and ~CTessFacePriorityList.

const NLMISC::CVector& NL3D::CTessFacePriorityList::getQuadrantDirection uint    quadrantId const [inline]
 

get the quadrant dir associated to the Id.

Undefined if 0.

Definition at line 145 of file tess_face_priority_list.h.

References _RollingTables.

void NL3D::CTessFacePriorityList::init float    distStep,
uint    numEntries,
float    distMaxMod,
uint    numQuadrant
 

Clear and Init the priority list.

It reserve (numQuadrants+1) Rolling table of numEntries entries.

Parameters:
numEntries  gives the number of entries and MUST be powerOf2. distMax= numEntries*distStep
m distMaxMod is important for performance and MUST be < 1. eg: distMaxMod= 0.8.
It is a trick to avoid the "Too Far Priority problem". Imagine you have a setup such distMax= 1000, and you insert(1100, an element). If we clamp to the max, it may be a bad thing, because ALL elements inserted after 1000 will be poped in one shift(), after 1000 shift(1) for example. To avoid this, if distMaxMod==0.8, then insert(1050) will really insert at 850, so elements will be poped not as the same time (for the extra cost of some elements get poped too early...).
Parameters:
numQuadrant  set 0 if don't want to support quadrant notion. else set >=4 and a power of 2 (else nlassert)

Definition at line 150 of file tess_face_priority_list.cpp.

References _EntryModStart, _MaskEntries, _MaskQuadrant, _NEntries, _NumQuadrant, _OODistStep, _QuarterQuadrantEnd, _QuarterQuadrantStart, _RollingTables, NLMISC::clamp, clear, NLMISC::isPowerOf2, nlassert, and NLMISC::Pi.

void NL3D::CTessFacePriorityList::insert uint    quadrantId,
float    distance,
CTessFace   value
 

Insert an element at a given distance, and in a given quadrant.

Insert at the closest step. eg insert(1.2, elt) will insert elt at entry 1 (assuming distStep==1 here). Special case: if distance<=0, it is ensured that at each shift(), the element will be pulled. NB: manage correctly the entry where it is inserted, according to the Remainder system.

USE OptFastFloor if distance>0 => MUST be enclosed in OptFastFloorBegin/OptFastFloorEnd()

Parameters:
quadrantId  set 0 if you want to insert in the "direction less" rolling table. else set the value returned by selectQuadrant()
distance  if quadrantId==0, distance should be the norm()-SphereSize, else it shoudl be direction*quadrantDirection-SphereSize.

Definition at line 273 of file tess_face_priority_list.cpp.

References _EntryModStart, _MaskEntries, _NEntries, _OODistStep, _RollingTables, nlassert, NL3D::OptFastFloor, and value.

uint NL3D::CTessFacePriorityList::selectQuadrant const NLMISC::CVector   direction
 

prior to insert an element with a direction notion, select which quadrant according to the direction Camera -> center of interest.

Returns:
0 if no quadrant available, else the quadrant id

Definition at line 209 of file tess_face_priority_list.cpp.

References _MaskQuadrant, _NumQuadrant, _QuarterQuadrantEnd, _QuarterQuadrantStart, and _RollingTables.

void NL3D::CTessFacePriorityList::shift const NLMISC::CVector   direction,
CTessFacePListNode   pulledElements
 

Shift the Priority list in a given direction.

NB: for each rolling table, even if shiftDistance==0, all elements in the entry 0 are pulled out.

m pulledElements is the root of the list which will contains elements pulled from the list.

Definition at line 314 of file tess_face_priority_list.cpp.

References _NEntries, _OODistStep, _RollingTables, and nlassert.

void NL3D::CTessFacePriorityList::shiftAll CTessFacePListNode   pulledElements
 

Same as shift(), but shift all the array.

Definition at line 368 of file tess_face_priority_list.cpp.

References _NEntries, _RollingTables, and nlassert.


Member Data Documentation

uint NL3D::CTessFacePriorityList::_EntryModStart [private]
 

Definition at line 187 of file tess_face_priority_list.h.

Referenced by CTessFacePriorityList, init, and insert.

uint NL3D::CTessFacePriorityList::_MaskEntries [private]
 

Definition at line 186 of file tess_face_priority_list.h.

Referenced by CTessFacePriorityList, init, and insert.

uint NL3D::CTessFacePriorityList::_MaskQuadrant [private]
 

Definition at line 190 of file tess_face_priority_list.h.

Referenced by init, and selectQuadrant.

uint NL3D::CTessFacePriorityList::_NEntries [private]
 

Definition at line 185 of file tess_face_priority_list.h.

Referenced by CTessFacePriorityList, init, insert, shift, and shiftAll.

uint NL3D::CTessFacePriorityList::_NumQuadrant [private]
 

Definition at line 188 of file tess_face_priority_list.h.

Referenced by CTessFacePriorityList, init, and selectQuadrant.

float NL3D::CTessFacePriorityList::_OODistStep [private]
 

Definition at line 184 of file tess_face_priority_list.h.

Referenced by CTessFacePriorityList, init, insert, and shift.

uint NL3D::CTessFacePriorityList::_QuarterQuadrantEnd[4] [private]
 

Definition at line 192 of file tess_face_priority_list.h.

Referenced by init, and selectQuadrant.

uint NL3D::CTessFacePriorityList::_QuarterQuadrantStart[4] [private]
 

Definition at line 191 of file tess_face_priority_list.h.

Referenced by init, and selectQuadrant.

float NL3D::CTessFacePriorityList::_Remainder [private]
 

Definition at line 183 of file tess_face_priority_list.h.

std::vector<CRollingTable> NL3D::CTessFacePriorityList::_RollingTables [private]
 

Definition at line 243 of file tess_face_priority_list.h.

Referenced by clear, getQuadrantDirection, init, insert, selectQuadrant, shift, and shiftAll.


The documentation for this class was generated from the following files: