net.java.dev.joode.space
Class SimpleSpace

java.lang.Object
  extended by net.java.dev.joode.geom.Geom
      extended by net.java.dev.joode.space.Space
          extended by net.java.dev.joode.space.SimpleSpace
All Implemented Interfaces:
java.io.Serializable, SimState

public class SimpleSpace
extends Space

A very elemental Space, it does not perform any sorting of the Geoms. It's very useful, if you don't have loads of Geoms, because it keeps the constant factor at a minimum. Simple space tests every pair of memeber geoms for a collision once. So it is of order n squared, where n is the number of geoms within the space At present the bounding box of the space is + and - infinity, though this should change to represents the geoms inside the space so that simple spaces can be nested effeciently

Author:
Arne Müller
See Also:
Serialized Form

Field Summary
 
Fields inherited from class net.java.dev.joode.geom.Geom
aabb, AABB_MAX_X, AABB_MAX_Y, AABB_MAX_Z, AABB_MIN_X, AABB_MIN_Y, AABB_MIN_Z, body, category_bits, collide_bits, dBoxClass, dCapsuleClass, dCircle, dConvex, dCylinderClass, dFirstSpaceClass, dFirstUserClass, dGeomNumClasses, dGeomTransformClass, dHashSpaceClass, dLastSpaceClass, dLastUserClass, dMaxUserClasses, dOctTreeSpaceClass, dPlaneClass, dQuadTreeSpaceClass, dRayClass, dRectangle, dSimpleSpaceClass, dSphereClass, dTriMeshClass, GEOM_AABB_BAD, GEOM_DIRTY, GEOM_ENABLED, GEOM_PLACEABLE, gflags, lpos, parent_space, pos, R, RAY_BACKFACECULL, RAY_CLOSEST_HIT, RAY_FIRSTCONTACT, tmpq, type
 
Constructor Summary
SimpleSpace(Space parent)
          Creates a new SimpleSpace
 
Method Summary
 void add(Geom g)
          adds a Geom to this Space.
 void cleanGeoms()
          turn all dirty geoms into clean geoms by computing their AABBs and any other space data structures that are required.
 SimpleSpace cloneState(ClonedReferences util)
           deep clones the state object, any references to other SimState objects should be cloned and assigned to the clone via the ClonedReferences util object.
 void collide(java.lang.Object data, NearCallback callback)
          tests for collisions of the Geoms in this Space with each other.
 void collide2(java.lang.Object data, Geom geom, NearCallback callback)
          tests for collisions of a Geom with the Geoms in this Space
protected  java.util.Iterator<Geom> getGeoms()
          returns an Iterator through all GeomS in this Space
 void getGeoms(java.util.List<Geom> geoms)
          adds all the geoms in this space to the passed in list
 int getNumGeoms()
          returns the Number of Geoms in this Space
 boolean isEmpty()
          tests, if this is Space is empty
 void remove(Geom g)
          removes the Geom from this Space.
 
Methods inherited from class net.java.dev.joode.space.Space
addBodyGeoms, addGeomListener, canCollide, clonePartialSpace, collideAABBs, computeAABB, dGeomMoved, dSpaceCollide2, notifyGeomAdded, notifyGeomRemoved, query, removeBodyGeoms, removeGeomListener, testAABBs
 
Methods inherited from class net.java.dev.joode.geom.Geom
AABBTest, clonePartialGeom, destroy, getAABB, getUserData, isEnabled, recomputeAABB, setBody, setPosition, setQuaternion, setQuaternion, setRotation, setUserData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleSpace

public SimpleSpace(Space parent)
Creates a new SimpleSpace

Parameters:
parent - the parent space going to continue this space - use null for root-Spaces
Method Detail

getGeoms

protected java.util.Iterator<Geom> getGeoms()
Description copied from class: Space
returns an Iterator through all GeomS in this Space

Specified by:
getGeoms in class Space
Returns:
the Iterator

getNumGeoms

public int getNumGeoms()
Description copied from class: Space
returns the Number of Geoms in this Space

Specified by:
getNumGeoms in class Space
Returns:
the Number of Geoms in this Space

getGeoms

public void getGeoms(java.util.List<Geom> geoms)
Description copied from class: Space
adds all the geoms in this space to the passed in list

Specified by:
getGeoms in class Space

remove

public void remove(Geom g)
Description copied from class: Space
removes the Geom from this Space.

Specified by:
remove in class Space
Parameters:
g - the Geom to remove

isEmpty

public boolean isEmpty()
Description copied from class: Space
tests, if this is Space is empty

Specified by:
isEmpty in class Space
Returns:
true, if empty

add

public void add(Geom g)
Description copied from class: Space
adds a Geom to this Space. Important: the Geom is not allowed to be already inside a different Space.

Specified by:
add in class Space
Parameters:
g - the Geom to add

cleanGeoms

public void cleanGeoms()
Description copied from class: Space
turn all dirty geoms into clean geoms by computing their AABBs and any other space data structures that are required. this should clear the GEOM_DIRTY and GEOM_AABB_BAD flags of all geoms.

Specified by:
cleanGeoms in class Space

collide

public void collide(java.lang.Object data,
                    NearCallback callback)
Description copied from class: Space
tests for collisions of the Geoms in this Space with each other.

Specified by:
collide in class Space
Parameters:
data - the World of collision
callback - the callback for the collision

collide2

public void collide2(java.lang.Object data,
                     Geom geom,
                     NearCallback callback)
Description copied from class: Space
tests for collisions of a Geom with the Geoms in this Space

Specified by:
collide2 in class Space
Parameters:
data - the World of collision
geom - the Geom to collide with this Space.
callback - the callback for the collision

cloneState

public SimpleSpace cloneState(ClonedReferences util)
Description copied from interface: SimState

deep clones the state object, any references to other SimState objects should be cloned and assigned to the clone via the ClonedReferences util object. The util object ensures that multiple clones of the same object are not performed during a clone operation.

Parameters:
util - instanciate a new one if top level cloning