Allow for "loose" path location which gets the sprite as close as possible

by normal means and then walks them in a straight line from there (when
the straight line part will invariably be off-screen, this is OK).


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2937 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2004-01-12 05:53:59 +00:00
parent 7568ae1223
commit 1688a19704
@@ -1,5 +1,5 @@
//
// $Id: MisoScenePanel.java,v 1.56 2004/01/11 12:22:05 mdb Exp $
// $Id: MisoScenePanel.java,v 1.57 2004/01/12 05:53:59 mdb Exp $
package com.threerings.miso.client;
@@ -254,8 +254,14 @@ public class MisoScenePanel extends VirtualMediaPanel
/**
* Computes a path for the specified sprite to the specified tile
* coordinates.
*
* @param loose if true, an approximate path will be returned if a
* complete path cannot be located. This path will navigate the sprite
* "legally" as far as possible and then walk the sprite in a straight
* line to its final destination. This is generally only useful if the
* the path goes "off screen".
*/
public Path getPath (Sprite sprite, int x, int y)
public Path getPath (Sprite sprite, int x, int y, boolean loose)
{
// sanity check
if (sprite == null) {
@@ -274,7 +280,7 @@ public class MisoScenePanel extends VirtualMediaPanel
// get a reasonable tile path through the scene
long start = System.currentTimeMillis();
List points = AStarPathUtil.getPath(
this, sprite, longestPath, src.x, src.y, dest.x, dest.y);
this, sprite, longestPath, src.x, src.y, dest.x, dest.y, loose);
long duration = System.currentTimeMillis() - start;
// sanity check the number of nodes searched so that we can keep