From 12c9f8673508bc6424be885777ebe1807860163d Mon Sep 17 00:00:00 2001 From: Mike Thomas Date: Thu, 8 Dec 2005 21:59:12 +0000 Subject: [PATCH] Add additional type of orientation to ArcPath - NONE - which keeps us from reorienting sprites following the path. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3780 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../com/threerings/media/util/ArcPath.java | 56 +++++++++++-------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/src/java/com/threerings/media/util/ArcPath.java b/src/java/com/threerings/media/util/ArcPath.java index bfd563408..6d07d5960 100644 --- a/src/java/com/threerings/media/util/ArcPath.java +++ b/src/java/com/threerings/media/util/ArcPath.java @@ -45,6 +45,11 @@ public class ArcPath extends TimedPath * follow this path. */ public static final int FINE = 1; + /** An orientation indicating that the pathable should not be oriented + * as it moves along the path. + */ + public static final int NONE = 2; + /** * Creates an arc path that will animate a pathable from the specified * starting position along an ellipse defined by the supplied @@ -130,36 +135,39 @@ public class ArcPath extends TimedPath // determine where we should be along the path computePosition(_center, _xradius, _yradius, angle, _tpos); - // compute the pathable's new orientation - double theta = angle + ((_delta > 0) ? Math.PI/2 : -Math.PI/2); - int orient; - switch (_orient) { - default: - case NORMAL: - orient = DirectionUtil.getDirection(theta); - // adjust it appropriately - orient = DirectionUtil.rotateCW(orient, 2*_orientOffset); - break; - - case FINE: - orient = DirectionUtil.getFineDirection(theta); - // adjust it appropriately - orient = DirectionUtil.rotateCW(orient, _orientOffset); - break; - } + // Skip this if we are not reorienting as we follow the path. + if (_orient != NONE) { + // compute the pathable's new orientation + double theta = angle + ((_delta > 0) ? Math.PI/2 : -Math.PI/2); + int orient; + switch (_orient) { + default: + case NORMAL: + orient = DirectionUtil.getDirection(theta); + // adjust it appropriately + orient = DirectionUtil.rotateCW(orient, 2*_orientOffset); + break; + + case FINE: + orient = DirectionUtil.getFineDirection(theta); + // adjust it appropriately + orient = DirectionUtil.rotateCW(orient, _orientOffset); + break; + } + // update the pathable's orientation if it changed + if (pable.getOrientation() != orient) { + pable.setOrientation(orient); + modified = true; + } + } + // update the pathable's location if it moved if (pable.getX() != _tpos.x || pable.getY() != _tpos.y) { pable.setLocation(_tpos.x, _tpos.y); modified = true; } - - // update the pathable's orientation if it changed - if (pable.getOrientation() != orient) { - pable.setOrientation(orient); - modified = true; - } - + // if we completed our path, let the sprite know if (angle == _sangle + _delta) { pable.pathCompleted(timestamp);