CollisionWorldSpatialHash Class Reference

#include <rimCollisionWorldSpatialHash.h>

Inheritance diagram for CollisionWorldSpatialHash:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 CollisionWorldSpatialHash ()
 Create a new empty spatial hash collision world.
virtual void testForCollisions (Real dt)
 Test for collisions between all objects in the spatial hash collision world.
virtual void testForCollisions (Real dt, CollisionResultSet &resultSet)
 Test for collisions between all objects in the spatial hash collision world.
virtual bool addRigidObject (RigidObject *newRigidObject)
 Add a rigid object to the spatial hash collision world.
virtual bool removeRigidObject (RigidObject *newRigidObject)
 Remove a rigid object from the spatial hash collision world.
virtual bool containsRigidObject (RigidObject *newRigidObject) const
 Get whether or not a rigid object is contained in the spatial hash collision world.
virtual void clearRigidObjects ()
 Clear all rigid objects from the spatial hash collision world.
virtual int getNumberOfRigidObjects () const
 Get the number of rigid objects in the spatial hash collision world.
virtual bool addParticle (Particle *newParticle)
 Add a particle to this spatial hash collision world.
virtual bool removeParticle (Particle *newParticle)
 Remove a particle from this spatial hash collision world.
virtual bool containsParticle (Particle *newParticle) const
 Return whether or not a particle is contained in this spatial hash collision world.
virtual void clearParticles ()
 Clear all particles from the spatial hash collision world.
virtual int getNumberOfParticles () const
 Get the number of particles in this spatial hash collision world.
float getLoadFactor () const
void setLoadFactor (float newLoadFactor)

Private Member Functions

void clearHashTable ()
void resizeHashTable ()
void rehashObjects ()
void insertObject (SpatialHashObject *object)
void removeObject (SpatialHashObject *object)
void testForCollisions (SpatialHashObject *object)

Static Private Member Functions

static Hash getCellHashCode (int x, int y, int z, int gridLevelIndex)
static Hash nextPrime (Hash n)
 Find the first prime larger than the parameter in the class's static array of primes.

Private Attributes

Hash numBuckets
SpatialHashBucketbuckets
int numHashedCells
ArrayList< SpatialHashLevelgridLevels
float loadFactor
int tick
HashMap< RigidObject *,
SpatialHashObject * > 
rigidObjectMap
 The rigid objects that are being tested for collisions in the spatial hash collision world.
ArrayList< Particle * > particles
 The particles that are being tested for collisions in the spatial hash collision world.

Static Private Attributes

static const Hash DEFAULT_NUMBER_OF_BUCKETS = 193
static const int NUMBER_OF_PRIMES = 28
 A constant defining the number of prime constants that this class contains.
static const Hash PRIMES [NUMBER_OF_PRIMES]
 An array of optimal hash table primes (those far away from powers of 2).
static const float DEFAULT_LOAD_FACTOR = 0.5f


Constructor & Destructor Documentation

RIM_PHYSICS_NAMESPACE_START CollisionWorldSpatialHash::CollisionWorldSpatialHash (  ) 

Create a new empty spatial hash collision world.


Member Function Documentation

void CollisionWorldSpatialHash::testForCollisions ( Real  dt  )  [virtual]

Test for collisions between all objects in the spatial hash collision world.

Implements CollisionWorld.

void CollisionWorldSpatialHash::testForCollisions ( Real  dt,
CollisionResultSet resultSet 
) [virtual]

Test for collisions between all objects in the spatial hash collision world.

Implements CollisionWorld.

bool CollisionWorldSpatialHash::addRigidObject ( RigidObject newRigidObject  )  [virtual]

Add a rigid object to the spatial hash collision world.

Implements PhysicsSystem.

bool CollisionWorldSpatialHash::removeRigidObject ( RigidObject newRigidObject  )  [virtual]

Remove a rigid object from the spatial hash collision world.

Implements PhysicsSystem.

bool CollisionWorldSpatialHash::containsRigidObject ( RigidObject newRigidObject  )  const [virtual]

Get whether or not a rigid object is contained in the spatial hash collision world.

Implements PhysicsSystem.

void CollisionWorldSpatialHash::clearRigidObjects (  )  [virtual]

Clear all rigid objects from the spatial hash collision world.

Implements PhysicsSystem.

int CollisionWorldSpatialHash::getNumberOfRigidObjects (  )  const [virtual]

Get the number of rigid objects in the spatial hash collision world.

Implements PhysicsSystem.

bool CollisionWorldSpatialHash::addParticle ( Particle newParticle  )  [virtual]

Add a particle to this spatial hash collision world.

Implements PhysicsSystem.

bool CollisionWorldSpatialHash::removeParticle ( Particle newParticle  )  [virtual]

Remove a particle from this spatial hash collision world.

Implements PhysicsSystem.

bool CollisionWorldSpatialHash::containsParticle ( Particle newParticle  )  const [virtual]

Return whether or not a particle is contained in this spatial hash collision world.

Implements PhysicsSystem.

void CollisionWorldSpatialHash::clearParticles (  )  [virtual]

Clear all particles from the spatial hash collision world.

Implements PhysicsSystem.

int CollisionWorldSpatialHash::getNumberOfParticles (  )  const [virtual]

Get the number of particles in this spatial hash collision world.

Implements PhysicsSystem.

float CollisionWorldSpatialHash::getLoadFactor (  )  const [inline]

void CollisionWorldSpatialHash::setLoadFactor ( float  newLoadFactor  )  [inline]

static Hash CollisionWorldSpatialHash::getCellHashCode ( int  x,
int  y,
int  z,
int  gridLevelIndex 
) [inline, static, private]

void CollisionWorldSpatialHash::clearHashTable (  )  [private]

void CollisionWorldSpatialHash::resizeHashTable (  )  [private]

void CollisionWorldSpatialHash::rehashObjects (  )  [private]

void CollisionWorldSpatialHash::insertObject ( SpatialHashObject object  )  [private]

void CollisionWorldSpatialHash::removeObject ( SpatialHashObject object  )  [private]

void CollisionWorldSpatialHash::testForCollisions ( SpatialHashObject object  )  [private]

static Hash CollisionWorldSpatialHash::nextPrime ( Hash  n  )  [inline, static, private]

Find the first prime larger than the parameter in the class's static array of primes.


Member Data Documentation

Hash CollisionWorldSpatialHash::numBuckets [private]

SpatialHashBucket* CollisionWorldSpatialHash::buckets [private]

int CollisionWorldSpatialHash::numHashedCells [private]

ArrayList<SpatialHashLevel> CollisionWorldSpatialHash::gridLevels [private]

float CollisionWorldSpatialHash::loadFactor [private]

int CollisionWorldSpatialHash::tick [private]

HashMap<RigidObject*,SpatialHashObject*> CollisionWorldSpatialHash::rigidObjectMap [private]

The rigid objects that are being tested for collisions in the spatial hash collision world.

ArrayList<Particle*> CollisionWorldSpatialHash::particles [private]

The particles that are being tested for collisions in the spatial hash collision world.

const Hash CollisionWorldSpatialHash::DEFAULT_NUMBER_OF_BUCKETS = 193 [static, private]

const int CollisionWorldSpatialHash::NUMBER_OF_PRIMES = 28 [static, private]

A constant defining the number of prime constants that this class contains.

const Hash CollisionWorldSpatialHash::PRIMES [static, private]

Initial value:

{
        11,                             
        23,                             
        53,                             
        97,                             
        193,                    
        389,                    
        769,                    
        1543,                   
        3079,                   
        6151,                   
        12289,                  
        24593,                  
        49157,                  
        98317,                  
        196613,                 
        393241,                 
        786433,                 
        1572869,                
        3145739,                
        6291469,                
        12582917,               
        25165843,               
        50331653,               
        100663319,              
        201326611,              
        402653189,              
}
An array of optimal hash table primes (those far away from powers of 2).

const float CollisionWorldSpatialHash::DEFAULT_LOAD_FACTOR = 0.5f [static, private]


The documentation for this class was generated from the following files:
Generated on Tue Aug 26 00:03:19 2008 for Rim Physics by  doxygen 1.5.4