Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   Related Pages  

CGrid< SECTOR, SECS_X, SECS_Y > Class Template Reference

List of all members.

Detailed Description

template<typename SECTOR, int SECS_X = 32, int SECS_Y = 32>
class CGrid< SECTOR, SECS_X, SECS_Y >

Grid - a 2D world partition.

A grid divides world space into fixed grid of rectangular sectors. World is divided on XY plane, so each sector represents a whole vertical "column" of the world.

Needed sector interface:

Parameters:
SECTOR  Sector class.
SECS_X  Number of sectors along world X axis. Should be a power of 2.
SECS_Y  Number of sectors along world Y axis. Should be a power of 2.


Public Types

typedef SECTOR TSector
 Sector type (from template argument).


Public Methods

 CGrid (SECTOR const &t=SECTOR())
 Constructor.

 ~CGrid ()
 Destructor.

int getSecsX () const
 Returns number of sectors along X axis.

int getSecsY () const
 Returns number of sectors along Y axis.

int getSecsCount () const
 Returns total number of sectors.

float getStepX () const
 Returns sector size along X axis.

float getStepY () const
 Returns sector size along Y axis.

float getInvStepX () const
 Returns inverse sector size along X axis.

float getInvStepY () const
 Returns inverse sector size along Y axis.

const SECTOR & getSectorByPosition (float x, float y) const
 Returns read-only sector by world space position XY.

SECTOR & getSectorByPosition (float x, float y)
 Returns sector by world space position XY.

const SECTOR & getSectorByIndex (int ix, int iy) const
 Returns read-only sector by it's XY index.

SECTOR & getSectorByIndex (int ix, int iy)
 Returns sector by it's XY index.

const SECTOR & getSectorByIndex (int i) const
 Returns read-only sector by it's absolute index.

SECTOR & getSectorByIndex (int i)
 Returns sector by it's absolute index.

int position2Index (float x, float y) const
 Returns sector's absolute index from world XY position.

void position2Index (float x, float y, int &ix, int &iy) const
 Returns sector's XY index from world XY position.


Constructor & Destructor Documentation

template<typename SECTOR, int SECS_X = 32, int SECS_Y = 32>
CGrid< SECTOR, SECS_X, SECS_Y >::CGrid SECTOR const &    t = SECTOR() [inline]
 

Constructor.

Parameters:
t  Sector object used to initialize all the sectors.


Generated on Thu Dec 5 17:27:58 2002 for LT Game Jam Session by doxygen1.2.17