se_core::CollisionGrid Class Reference

#include <CollisionGrid.hpp>

List of all members.

Public Member Functions

 CollisionGrid (coor_tile_t width, coor_tile_t height, short depth)
virtual ~CollisionGrid ()
void setSize (int width, int height)
 Set a new size for the grid.
void setOffset (const Point3 &c)
int lineOffset (short level)
 How wide a the node array is at a given level.
coor_tile_t nodeSize (short level)
 Node size at a given level.
coor_tile_t halfNodeSize (short level)
 Half node size is typically used when searching for the level where a thing of a certain size belongs.
int calcLevel (coor_tile_t size)
int indexAtLevel (coor_tile_t x, coor_tile_t z, short level)
 Calculates the index in nodeLevels_[level][ index ] for a coordinate at a given level.
int indexAtLevelAndNode (coor_tile_t nodeX, coor_tile_t nodeZ, short level)
 Calculates the index in nodeLevels_[level][ index ] for a coordinate at a given level.
void insert (const Point3 &c, coor_t size, CollisionComponent &thing)
 Insert a thing in the collision grid.
bool remove (const Point3 &c, coor_t size, CollisionComponent &thing)
 Remove a thing from the collision grid.
void move (const Point3 &from, coor_t oldSize, const Point3 &to, coor_t newSize, CollisionComponent &thing)
 Move a thing in the collision grid.
short collisionCandidates (const Point3 &c, coor_t size, CollisionComponent *things[], short max)
 Return all things in grid that a thing with the given Coor and size may collide with in the things array.
bool find (CollisionComponent &thing)
void clear ()
 Delete all members from the collision grid.


Constructor & Destructor Documentation

se_core::CollisionGrid::CollisionGrid coor_tile_t  width,
coor_tile_t  height,
short  depth
 

Definition at line 32 of file CollisionGrid.cpp.

se_core::CollisionGrid::~CollisionGrid  )  [virtual]
 

Definition at line 77 of file CollisionGrid.cpp.


Member Function Documentation

int se_core::CollisionGrid::calcLevel coor_tile_t  size  )  [inline]
 

Definition at line 92 of file CollisionGrid.hpp.

void se_core::CollisionGrid::clear  ) 
 

Delete all members from the collision grid.

Definition at line 130 of file CollisionGrid.cpp.

Referenced by se_core::CollisionManager::releaseCollisionGrid().

short se_core::CollisionGrid::collisionCandidates const Point3 c,
coor_t  size,
CollisionComponent things[],
short  max
 

Return all things in grid that a thing with the given Coor and size may collide with in the things array.

The max must be (n^2) - 1.

Definition at line 194 of file CollisionGrid.cpp.

References Assert, coor_tile_t, DbgAssert, se_core::Tuple3::x_, and se_core::Tuple3::z_.

bool se_core::CollisionGrid::find CollisionComponent thing  ) 
 

Definition at line 249 of file CollisionGrid.cpp.

coor_tile_t se_core::CollisionGrid::halfNodeSize short  level  )  [inline]
 

Half node size is typically used when searching for the level where a thing of a certain size belongs.

Definition at line 88 of file CollisionGrid.hpp.

References coor_tile_t.

int se_core::CollisionGrid::indexAtLevel coor_tile_t  x,
coor_tile_t  z,
short  level
[inline]
 

Calculates the index in nodeLevels_[level][ index ] for a coordinate at a given level.

Definition at line 105 of file CollisionGrid.hpp.

References Assert, and coor_tile_t.

int se_core::CollisionGrid::indexAtLevelAndNode coor_tile_t  nodeX,
coor_tile_t  nodeZ,
short  level
[inline]
 

Calculates the index in nodeLevels_[level][ index ] for a coordinate at a given level.

Definition at line 116 of file CollisionGrid.hpp.

References Assert.

void se_core::CollisionGrid::insert const Point3 c,
coor_t  size,
CollisionComponent thing
 

Insert a thing in the collision grid.

Definition at line 98 of file CollisionGrid.cpp.

References se_core::Tuple3::add(), Assert, AssertFatal, coor_tile_t, se_core::Composite::name(), se_core::Component::owner(), se_core::Point3::xTile(), and se_core::Point3::zTile().

int se_core::CollisionGrid::lineOffset short  level  )  [inline]
 

How wide a the node array is at a given level.

Level 0 is an 1x1 array, level 1 is a 2x2 array, level 2 is a 4x4 array, etc. This respectively gives a line offset of 1, 2 and 4.

Definition at line 70 of file CollisionGrid.hpp.

void se_core::CollisionGrid::move const Point3 from,
coor_t  oldSize,
const Point3 to,
coor_t  newSize,
CollisionComponent thing
 

Move a thing in the collision grid.

Definition at line 161 of file CollisionGrid.cpp.

References se_core::Tuple3::add(), coor_tile_t, se_core::Point3::xTile(), and se_core::Point3::zTile().

Referenced by se_core::CollisionComponent::move().

coor_tile_t se_core::CollisionGrid::nodeSize short  level  )  [inline]
 

Node size at a given level.

The nodesize at level 0 is identical to the root node size. Elements should inserted at the highest level where the node size is still bigger than themselves.

Definition at line 80 of file CollisionGrid.hpp.

References coor_tile_t.

bool se_core::CollisionGrid::remove const Point3 c,
coor_t  size,
CollisionComponent thing
 

Remove a thing from the collision grid.

Definition at line 138 of file CollisionGrid.cpp.

References Assert, coor_tile_t, LogDetail, se_core::Point3::xTile(), and se_core::Point3::zTile().

void se_core::CollisionGrid::setOffset const Point3 c  ) 
 

Definition at line 91 of file CollisionGrid.cpp.

References se_core::Point3::xTile(), and se_core::Point3::zTile().

void se_core::CollisionGrid::setSize int  width,
int  height
 

Set a new size for the grid.

This affects the coordinates of each grid element, but does not affect the depth of the grid itself. Useful for using the same grid with several different sized areas. (Only one area at a time, of though!)

Definition at line 84 of file CollisionGrid.cpp.

References Assert.


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

Home Page | SagaEngine trunk (updated nightly) reference generated Sun Dec 2 20:06:27 2007 by Doxygen version 1.3.9.1.

SourceForge.net Logo