|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.tudey.server.util.Pathfinder
public class Pathfinder
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).
| Field Summary | |
|---|---|
protected IntMap<List<Integer>> |
_actorFlagLists
Maps encoded coordinates to lists of separate sets of actor flags. |
protected CoordIntMap |
_actorFlags
The collision flags corresponding to the scene entries and the actors. |
protected List<SpaceElement> |
_elements
Holds elements during intersection testing. |
protected CoordIntMap |
_entryFlags
The collision flags corresponding to the scene entries. |
protected Polygon |
_quad
Used to store tile shapes for intersecting testing. |
protected Rectangle |
_region
Region object to reuse. |
protected TudeySceneManager |
_scenemgr
The owning scene manager. |
protected Shape |
_sweptShape
Swept shape to reuse. |
protected Transform2D |
_transform
Transform to reuse. |
protected Vector2f |
_translation
Translation vector to reuse. |
protected List<Vector2f> |
_waypoints
Holds waypoints during shortcut processing. |
protected Shape |
_worldShape
World shape to reuse. |
protected static int |
SUBDIVISION
The subdivision of the actor collision map. |
| 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. |
protected void |
addFlags(ActorLogic logic)
Adds the flags for the specified actor. |
protected void |
addFlags(Shape shape,
int flags,
boolean entry)
Adds the specified flags to the flag map(s). |
protected void |
addFlags(TudeySceneModel.Entry entry)
Adds the specified entry's flags to the flag maps. |
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. |
protected Vector2f[] |
getPath(boolean collideActor,
ActorLogic logic,
float longest,
float ax,
float ay,
float bx,
float by,
boolean partial,
boolean shortcut)
Computes a path for the specified actor. |
protected void |
removeFlags(ActorLogic logic)
Removes the flags for the specified actor. |
protected void |
removeFlags(Shape shape,
int flags,
boolean entry,
SpaceElement skip)
Removes the flags for the specified shape. |
protected void |
removeFlags(TudeySceneModel.Entry entry)
Removes the flags for the specified entry. |
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. |
protected boolean |
sweptShapeCollides(boolean collideActor,
ActorLogic logic,
Vector2f start,
Vector2f end)
Determines whether the swept shape of the specified actor collides with anything. |
protected void |
updateEntryFlags(int x,
int y,
SpaceElement skip)
Updates the entry flags at the specified location ( _quad should be set to the cell
boundaries). |
protected void |
updateQuad(float lx,
float ly,
float ux,
float uy)
Updates the coordinates of the quad. |
protected void |
updateQuad(int x,
int y)
Updates the coordinates of the quad to encompass the specified grid cell. |
protected void |
updateQuadSubdivision(int x,
int y,
int xs,
int ys)
Updates the coordinates of the quad to encompass the subdivided section of the specified grid cell. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected TudeySceneManager _scenemgr
protected CoordIntMap _entryFlags
protected CoordIntMap _actorFlags
protected IntMap<List<Integer>> _actorFlagLists
protected Polygon _quad
protected List<SpaceElement> _elements
protected List<Vector2f> _waypoints
protected Rectangle _region
protected Transform2D _transform
protected Shape _worldShape
protected Vector2f _translation
protected Shape _sweptShape
protected static final int SUBDIVISION
| Constructor Detail |
|---|
public Pathfinder(TudeySceneManager scenemgr)
| Method Detail |
|---|
public void shutdown()
public Vector2f[] getEntryPath(ActorLogic actor,
float longest,
float bx,
float by,
boolean partial,
boolean shortcut)
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.
public Vector2f[] getEntryPath(ActorLogic actor,
float longest,
float ax,
float ay,
float bx,
float by,
boolean partial,
boolean shortcut)
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.
public Vector2f[] getPath(ActorLogic actor,
float longest,
float bx,
float by,
boolean partial,
boolean shortcut)
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.
public Vector2f[] getPath(ActorLogic actor,
float longest,
float ax,
float ay,
float bx,
float by,
boolean partial,
boolean shortcut)
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.
public void entryAdded(TudeySceneModel.Entry entry)
TudeySceneModel.Observer
entryAdded in interface TudeySceneModel.Observer
public void entryUpdated(TudeySceneModel.Entry oentry,
TudeySceneModel.Entry nentry)
TudeySceneModel.Observer
entryUpdated in interface TudeySceneModel.Observerpublic void entryRemoved(TudeySceneModel.Entry oentry)
TudeySceneModel.Observer
entryRemoved in interface TudeySceneModel.Observerpublic void actorAdded(ActorLogic logic)
TudeySceneManager.ActorObserver
actorAdded in interface TudeySceneManager.ActorObserverpublic void actorRemoved(ActorLogic logic)
TudeySceneManager.ActorObserver
actorRemoved in interface TudeySceneManager.ActorObserverpublic void shapeWillChange(Logic logic)
Logic.ShapeObserver
shapeWillChange in interface Logic.ShapeObserverpublic void shapeDidChange(Logic logic)
Logic.ShapeObserver
shapeDidChange in interface Logic.ShapeObserver
public void collisionFlagsChanged(ActorLogic logic,
int oflags)
ActorLogic.CollisionFlagObserver
collisionFlagsChanged in interface ActorLogic.CollisionFlagObserver
protected Vector2f[] getPath(boolean collideActor,
ActorLogic logic,
float longest,
float ax,
float ay,
float bx,
float by,
boolean partial,
boolean shortcut)
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 compute shortcuts in the path.
protected boolean sweptShapeCollides(boolean collideActor,
ActorLogic logic,
Vector2f start,
Vector2f end)
protected void addFlags(TudeySceneModel.Entry entry)
protected void removeFlags(TudeySceneModel.Entry entry)
protected void addFlags(ActorLogic logic)
protected void removeFlags(ActorLogic logic)
protected void addFlags(Shape shape,
int flags,
boolean entry)
protected void removeFlags(Shape shape,
int flags,
boolean entry,
SpaceElement skip)
protected void updateQuad(int x,
int y)
protected void updateQuadSubdivision(int x,
int y,
int xs,
int ys)
protected void updateQuad(float lx,
float ly,
float ux,
float uy)
protected void updateEntryFlags(int x,
int y,
SpaceElement skip)
_quad should be set to the cell
boundaries).
skip - an element to skip, or null for none.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||