com.threerings.tudey.space
Class Space

java.lang.Object
  extended by com.threerings.tudey.space.Space
Direct Known Subclasses:
HashSpace, SimpleSpace

public abstract class Space
extends Object

Base class for spaces.


Constructor Summary
Space()
           
 
Method Summary
 void add(SpaceElement element)
          Adds an element to this space.
 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 dispose()
          Flags this space as having been disposed.
abstract  void getElements(Rect bounds, Collection<SpaceElement> results)
          Retrieves all space elements whose bounds intersect the provided region.
abstract  void getIntersecting(Shape shape, Collection<SpaceElement> results)
          Retrieves all space elements that intersect the provided shape.
 SpaceElement getIntersection(Ray2D ray, Vector2f location)
          Checks for an intersection between the provided ray and the contents of the space.
abstract  SpaceElement getIntersection(Ray2D ray, Vector2f location, Predicate<? super SpaceElement> filter)
          Checks for an intersection between the provided ray and the contents of the space.
 void remove(SpaceElement element)
          Removes an element from the space.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Space

public Space()
Method Detail

add

public void add(SpaceElement element)
Adds an element to this space.


remove

public void remove(SpaceElement element)
Removes an element from the space.


getIntersection

public SpaceElement getIntersection(Ray2D ray,
                                    Vector2f location)
Checks for an intersection between the provided ray and the contents of the space.

Parameters:
location - a vector to populate with the location of the intersection, if any.
Returns:
a reference to the first element intersected by the ray, or null for none.

getIntersection

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

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

getIntersecting

public abstract void getIntersecting(Shape shape,
                                     Collection<SpaceElement> results)
Retrieves all space elements that intersect the provided shape.

Parameters:
results - a collection to hold the results of the search.

getElements

public abstract void getElements(Rect bounds,
                                 Collection<SpaceElement> results)
Retrieves all space elements whose bounds intersect the provided region.

Parameters:
results - a list to hold the results of the search.

boundsWillChange

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


boundsDidChange

public void boundsDidChange(SpaceElement element)
Notes that the specified space element's bounds have changed.


dispose

public void dispose()
Flags this space as having been disposed.



Copyright © 2011. All Rights Reserved.