com.threerings.tudey.space
Class HashSpace

java.lang.Object
  extended by com.threerings.tudey.space.Space
      extended by com.threerings.tudey.space.HashSpace

public class HashSpace
extends Space

A space that uses a hybrid spatial hashing/quadtree scheme to store elements.


Constructor Summary
HashSpace(float granularity, int levels)
          Creates a new hash space.
 
Method Summary
 void boundsDidChange(SpaceElement element)
          Notes that the specified space element's bounds have changed.
 void boundsWillChange(SpaceElement element)
          Notes that the specified space element's bounds are about to change.
 void getElements(Rect bounds, Collection<SpaceElement> results)
          Retrieves all space elements whose bounds intersect the provided region.
 void getIntersecting(Shape shape, Collection<SpaceElement> results)
          Retrieves all space elements that intersect the provided shape.
 SpaceElement getIntersection(Ray2D ray, Vector2f location, Predicate<? super SpaceElement> filter)
          Checks for an intersection between the provided ray and the contents of the space.
 
Methods inherited from class com.threerings.tudey.space.Space
add, dispose, getIntersection, remove
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HashSpace

public HashSpace(float granularity,
                 int levels)
Creates a new hash space.

Parameters:
granularity - the size of the top-level cells.
levels - the (maximum) number of quadtree levels.
Method Detail

getIntersection

public SpaceElement getIntersection(Ray2D ray,
                                    Vector2f location,
                                    Predicate<? super SpaceElement> filter)
Description copied from class: Space
Checks for an intersection between the provided ray and the contents of the space.

Specified by:
getIntersection in class Space
location - a vector to populate with the location of the intersection, if any.
filter - a predicate to use in filtering the results of the test.
Returns:
a reference to the first element intersected by the ray, or null for none.

getIntersecting

public void getIntersecting(Shape shape,
                            Collection<SpaceElement> results)
Description copied from class: Space
Retrieves all space elements that intersect the provided shape.

Specified by:
getIntersecting in class Space
results - a collection to hold the results of the search.

getElements

public void getElements(Rect bounds,
                        Collection<SpaceElement> results)
Description copied from class: Space
Retrieves all space elements whose bounds intersect the provided region.

Specified by:
getElements in class Space
results - a list to hold the results of the search.

boundsWillChange

public void boundsWillChange(SpaceElement element)
Description copied from class: Space
Notes that the specified space element's bounds are about to change. Will be followed by a call to Space.boundsDidChange(SpaceElement) when the change has been effected.

Overrides:
boundsWillChange in class Space

boundsDidChange

public void boundsDidChange(SpaceElement element)
Description copied from class: Space
Notes that the specified space element's bounds have changed.

Overrides:
boundsDidChange in class Space


Copyright © 2011. All Rights Reserved.