net.java.dev.joode.space.octtree
Class OctTreeNode

java.lang.Object
  extended by net.java.dev.joode.space.octtree.OctTreeNode
All Implemented Interfaces:
java.io.Serializable, SimState
Direct Known Subclasses:
OctTree

public class OctTreeNode
extends java.lang.Object
implements SimState

A inner or leaf node of the Tree. If it, as a leaf-node, gets too much Geoms it automatically splits up and becomes an inner node. If the child nodes contain to less elements it will also collapse back to a leaf node.

Author:
Arne Müller
See Also:
Serialized Form

Nested Class Summary
static class OctTreeNode.SplitType
          the direction of the split of the TreeNode.
 
Field Summary
protected  float[] aabb
          the boundingbox of the OctTreeNode
protected  java.util.Set<Geom> geoms
          contains the geoms that would fit either in both sub-trees or if not splitted up, all
protected  OctTreeNode left
          the child TreeNodes
protected  int numGeoms
          the number of Geoms in this node
protected  OctTreeNode right
          the child TreeNodes
protected  float splitPos
          the position of the split
protected  boolean splitted
          is this node split up?
protected  OctTreeNode.SplitType type
          the split direction
 
Constructor Summary
OctTreeNode(OctTreeNode.SplitType t, float[] aabb)
          Creates a new OctTreeNode with a specified SplitType and boundingbox
 
Method Summary
 void add(Geom g)
          adds a Geom to this TreeNode
 SimState 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 in this tree
 void collide2(java.lang.Object data, Geom geom, NearCallback callback)
          tests for collisions of geom with elements in this tree
 float[] getAABB()
          returns the AABB of this node
 void getGeoms(java.util.Set<Geom> geoms)
           
 int getNumGeoms()
          the Number of Geoms in this treenode
 java.util.Iterator<Geom> iterator()
          an iterator over the elments in this tree node
 boolean remove(Geom g)
          removes a Geom
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

type

protected OctTreeNode.SplitType type
the split direction


right

protected OctTreeNode right
the child TreeNodes


left

protected OctTreeNode left
the child TreeNodes


aabb

protected float[] aabb
the boundingbox of the OctTreeNode


geoms

protected java.util.Set<Geom> geoms
contains the geoms that would fit either in both sub-trees or if not splitted up, all


splitted

protected boolean splitted
is this node split up?


numGeoms

protected int numGeoms
the number of Geoms in this node


splitPos

protected float splitPos
the position of the split

Constructor Detail

OctTreeNode

public OctTreeNode(OctTreeNode.SplitType t,
                   float[] aabb)
Creates a new OctTreeNode with a specified SplitType and boundingbox

Parameters:
t - the SplitType
aabb - the BoundingBox
Method Detail

getNumGeoms

public int getNumGeoms()
the Number of Geoms in this treenode

Returns:
the number of Geoms

getGeoms

public void getGeoms(java.util.Set<Geom> geoms)

add

public void add(Geom g)
adds a Geom to this TreeNode

Parameters:
g - the Geom to add

remove

public boolean remove(Geom g)
removes a Geom

Parameters:
g - the Geom to remove
Returns:
true, if sucessful

iterator

public java.util.Iterator<Geom> iterator()
an iterator over the elments in this tree node

Returns:
the iterator

collide

public void collide(java.lang.Object data,
                    NearCallback callback)
tests for collisions in this tree

Parameters:
data -
callback -

collide2

public void collide2(java.lang.Object data,
                     Geom geom,
                     NearCallback callback)
tests for collisions of geom with elements in this tree

Parameters:
data -
geom -
callback -

getAABB

public float[] getAABB()
returns the AABB of this node

Returns:
the AABB

cloneState

public SimState 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.

Specified by:
cloneState in interface SimState
Parameters:
util - instanciate a new one if top level cloning