com.threerings.tudey.server.util
Class Pathfinder

java.lang.Object
  extended by com.threerings.tudey.server.util.Pathfinder
All Implemented Interfaces:
TudeySceneModel.Observer, ActorLogic.CollisionFlagObserver, Logic.ShapeObserver, TudeySceneManager.ActorObserver

public class Pathfinder
extends Object
implements TudeySceneModel.Observer, TudeySceneManager.ActorObserver, Logic.ShapeObserver, ActorLogic.CollisionFlagObserver

A helper class for pathfinding. Currently the pathfinding strategy is to divide the world up into unit cells and track the collision flags of all scene entries and actors whose shapes intersect those cells. An alternate method that may be worth exploring would be to have the traversal predicate perform a full intersection query (it seems likely that this would be more expensive than maintaining the collision map for all actors, but it's not entirely clear).


Constructor Summary
Pathfinder(TudeySceneManager scenemgr)
          Creates a new pathfinder.
 
Method Summary
 void actorAdded(ActorLogic logic)
          Notes that an actor has been added.
 void actorRemoved(ActorLogic logic)
          Notes that an actor has been removed.
 void collisionFlagsChanged(ActorLogic logic, int oflags)
          Notes that the actor's collision flags have changed.
 void entryAdded(TudeySceneModel.Entry entry)
          Notes that an entry has been added to the scene.
 void entryRemoved(TudeySceneModel.Entry oentry)
          Notes that an entry has been removed from the scene.
 void entryUpdated(TudeySceneModel.Entry oentry, TudeySceneModel.Entry nentry)
          Notes that an entry has been updated within the scene.
 Vector2f[] getEntryPath(ActorLogic actor, float longest, float bx, float by, boolean partial, boolean shortcut)
          Computes a path for the specified actor from its current location, considering only the scene entries (not the actors).
 Vector2f[] getEntryPath(ActorLogic actor, float longest, float ax, float ay, float bx, float by, boolean partial, boolean shortcut)
          Computes a path for the specified actor, considering only the scene entries (not the actors).
 Vector2f[] getPath(ActorLogic actor, float longest, float bx, float by, boolean partial, boolean shortcut)
          Computes a path for the specified actor from its current location.
 Vector2f[] getPath(ActorLogic actor, float longest, float ax, float ay, float bx, float by, boolean partial, boolean shortcut)
          Computes a path for the specified actor.
 void shapeDidChange(Logic logic)
          Notes that the logic's shape has changed.
 void shapeWillChange(Logic logic)
          Notes that the logic's shape is about to change.
 void shutdown()
          Shuts down the pathfinder.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Pathfinder

public Pathfinder(TudeySceneManager scenemgr)
Creates a new pathfinder.

Method Detail

shutdown

public void shutdown()
Shuts down the pathfinder.


getEntryPath

public Vector2f[] getEntryPath(ActorLogic actor,
                               float longest,
                               float bx,
                               float by,
                               boolean partial,
                               boolean shortcut)
Computes a path for the specified actor from its current location, considering only the scene entries (not the actors).

Parameters:
longest - the maximum path length.
partial - if true, return a partial path even if the destination is unreachable.
shortcut - if true, use swept shapes to find path shortcuts.
Returns:
the computed path, or null if unreachable.

getEntryPath

public Vector2f[] getEntryPath(ActorLogic actor,
                               float longest,
                               float ax,
                               float ay,
                               float bx,
                               float by,
                               boolean partial,
                               boolean shortcut)
Computes a path for the specified actor, considering only the scene entries (not the actors).

Parameters:
longest - the maximum path length.
partial - if true, return a partial path even if the destination is unreachable.
shortcut - if true, use swept shapes to find path shortcuts.
Returns:
the computed path, or null if unreachable.

getPath

public Vector2f[] getPath(ActorLogic actor,
                          float longest,
                          float bx,
                          float by,
                          boolean partial,
                          boolean shortcut)
Computes a path for the specified actor from its current location.

Parameters:
longest - the maximum path length.
partial - if true, return a partial path even if the destination is unreachable.
shortcut - if true, use swept shapes to find path shortcuts.
Returns:
the computed path, or null if unreachable.

getPath

public Vector2f[] getPath(ActorLogic actor,
                          float longest,
                          float ax,
                          float ay,
                          float bx,
                          float by,
                          boolean partial,
                          boolean shortcut)
Computes a path for the specified actor.

Parameters:
longest - the maximum path length.
partial - if true, return a partial path even if the destination is unreachable.
shortcut - if true, use swept shapes to find path shortcuts.
Returns:
the computed path, or null if unreachable.

entryAdded

public void entryAdded(TudeySceneModel.Entry entry)
Description copied from interface: TudeySceneModel.Observer
Notes that an entry has been added to the scene.

Specified by:
entryAdded in interface TudeySceneModel.Observer

entryUpdated

public void entryUpdated(TudeySceneModel.Entry oentry,
                         TudeySceneModel.Entry nentry)
Description copied from interface: TudeySceneModel.Observer
Notes that an entry has been updated within the scene.

Specified by:
entryUpdated in interface TudeySceneModel.Observer

entryRemoved

public void entryRemoved(TudeySceneModel.Entry oentry)
Description copied from interface: TudeySceneModel.Observer
Notes that an entry has been removed from the scene.

Specified by:
entryRemoved in interface TudeySceneModel.Observer

actorAdded

public void actorAdded(ActorLogic logic)
Description copied from interface: TudeySceneManager.ActorObserver
Notes that an actor has been added.

Specified by:
actorAdded in interface TudeySceneManager.ActorObserver

actorRemoved

public void actorRemoved(ActorLogic logic)
Description copied from interface: TudeySceneManager.ActorObserver
Notes that an actor has been removed.

Specified by:
actorRemoved in interface TudeySceneManager.ActorObserver

shapeWillChange

public void shapeWillChange(Logic logic)
Description copied from interface: Logic.ShapeObserver
Notes that the logic's shape is about to change.

Specified by:
shapeWillChange in interface Logic.ShapeObserver

shapeDidChange

public void shapeDidChange(Logic logic)
Description copied from interface: Logic.ShapeObserver
Notes that the logic's shape has changed.

Specified by:
shapeDidChange in interface Logic.ShapeObserver

collisionFlagsChanged

public void collisionFlagsChanged(ActorLogic logic,
                                  int oflags)
Description copied from interface: ActorLogic.CollisionFlagObserver
Notes that the actor's collision flags have changed.

Specified by:
collisionFlagsChanged in interface ActorLogic.CollisionFlagObserver


Copyright © 2011. All Rights Reserved.