Whitespace
git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@918 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -27,16 +27,13 @@ package com.threerings.cast;
|
|||||||
public interface ActionCache
|
public interface ActionCache
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Fetches from the cache a composited set of images for a particular
|
* Fetches from the cache a composited set of images for a particular character for a
|
||||||
* character for a particular action.
|
* particular action.
|
||||||
*/
|
*/
|
||||||
public ActionFrames getActionFrames (
|
public ActionFrames getActionFrames (CharacterDescriptor descrip, String action);
|
||||||
CharacterDescriptor descrip, String action);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests that the specified set of action frames for the specified
|
* Requests that the specified set of action frames for the specified character be cached.
|
||||||
* character be cached.
|
|
||||||
*/
|
*/
|
||||||
public void cacheActionFrames (
|
public void cacheActionFrames (CharacterDescriptor descrip, String action, ActionFrames frames);
|
||||||
CharacterDescriptor descrip, String action, ActionFrames frames);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,27 +43,24 @@ import com.threerings.media.util.Pathable;
|
|||||||
import static com.threerings.media.Log.log;
|
import static com.threerings.media.Log.log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extends the base media panel with the notion of a virtual coordinate
|
* Extends the base media panel with the notion of a virtual coordinate system. All entities in
|
||||||
* system. All entities in the virtual media panel have virtual
|
* the virtual media panel have virtual coordinates and the virtual media panel displays a window
|
||||||
* coordinates and the virtual media panel displays a window into that
|
* into that virtual view. The panel can be made to scroll by adjusting the view offset slightly
|
||||||
* virtual view. The panel can be made to scroll by adjusting the view
|
* at the start of each tick and it will efficiently copy the unmodified view data and generate
|
||||||
* offset slightly at the start of each tick and it will efficiently copy
|
* repaint requests for the exposed regions.
|
||||||
* the unmodified view data and generate repaint requests for the exposed
|
|
||||||
* regions.
|
|
||||||
*/
|
*/
|
||||||
public class VirtualMediaPanel extends MediaPanel
|
public class VirtualMediaPanel extends MediaPanel
|
||||||
{
|
{
|
||||||
/** The code for the pathable following mode wherein we keep the view
|
/** The code for the pathable following mode wherein we keep the view centered on the
|
||||||
* centered on the pathable's location. */
|
* pathable's location. */
|
||||||
public static final byte CENTER_ON_PATHABLE = 0;
|
public static final byte CENTER_ON_PATHABLE = 0;
|
||||||
|
|
||||||
/** The code for the pathable following mode wherein we ensure that
|
/** The code for the pathable following mode wherein we ensure that the marked pathable is
|
||||||
* the marked pathable is always kept within the visible bounds of the
|
* always kept within the visible bounds of the view. */
|
||||||
* view. */
|
|
||||||
public static final byte ENCLOSE_PATHABLE = 1;
|
public static final byte ENCLOSE_PATHABLE = 1;
|
||||||
|
|
||||||
/** The code for the pathable following mode wherein we set the upper-left
|
/** The code for the pathable following mode wherein we set the upper-left corner of the view
|
||||||
* corner of the view to the coordinates of the pathable. */
|
* to the coordinates of the pathable. */
|
||||||
public static final byte TRACK_PATHABLE = 2;
|
public static final byte TRACK_PATHABLE = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -122,9 +119,10 @@ public class VirtualMediaPanel extends MediaPanel
|
|||||||
{
|
{
|
||||||
_trackers.remove(tracker);
|
_trackers.remove(tracker);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instructs the view to follow the supplied pathable; ensuring that
|
* Instructs the view to follow the supplied pathable; ensuring that the view's coordinates
|
||||||
* the view's coordinates are adjusted according to the follow mode.
|
* are adjusted according to the follow mode.
|
||||||
*
|
*
|
||||||
* @param pable the pathable to follow.
|
* @param pable the pathable to follow.
|
||||||
* @param followMode the strategy for keeping the pathable in view.
|
* @param followMode the strategy for keeping the pathable in view.
|
||||||
@@ -137,8 +135,8 @@ public class VirtualMediaPanel extends MediaPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears out the pathable that was being enclosed or followed due to
|
* Clears out the pathable that was being enclosed or followed due to a previous call to
|
||||||
* a previous call to {@link #setFollowsPathable}.
|
* {@link #setFollowsPathable}.
|
||||||
*/
|
*/
|
||||||
public void clearPathable ()
|
public void clearPathable ()
|
||||||
{
|
{
|
||||||
@@ -147,9 +145,8 @@ public class VirtualMediaPanel extends MediaPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We overload this to translate mouse events into the proper
|
* We overload this to translate mouse events into the proper coordinates before they are
|
||||||
* coordinates before they are dispatched to any of the mouse
|
* dispatched to any of the mouse listeners.
|
||||||
* listeners.
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void processMouseEvent (MouseEvent event)
|
protected void processMouseEvent (MouseEvent event)
|
||||||
@@ -159,9 +156,8 @@ public class VirtualMediaPanel extends MediaPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We overload this to translate mouse events into the proper
|
* We overload this to translate mouse events into the proper coordinates before they are
|
||||||
* coordinates before they are dispatched to any of the mouse
|
* dispatched to any of the mouse listeners.
|
||||||
* listeners.
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void processMouseMotionEvent (MouseEvent event)
|
protected void processMouseMotionEvent (MouseEvent event)
|
||||||
@@ -171,9 +167,8 @@ public class VirtualMediaPanel extends MediaPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We overload this to translate mouse events into the proper
|
* We overload this to translate mouse events into the proper coordinates before they are
|
||||||
* coordinates before they are dispatched to any of the mouse
|
* dispatched to any of the mouse listeners.
|
||||||
* listeners.
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void processMouseWheelEvent (MouseWheelEvent event)
|
protected void processMouseWheelEvent (MouseWheelEvent event)
|
||||||
@@ -223,9 +218,8 @@ public class VirtualMediaPanel extends MediaPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines the absolute screen coordinates at which this panel is
|
* Determines the absolute screen coordinates at which this panel is located and stores them
|
||||||
* located and stores them for reference later when rendering. This
|
* for reference later when rendering. This is necessary in order to work around the Windows
|
||||||
* is necessary in order to work around the Windows
|
|
||||||
* <code>copyArea()</code> bug.
|
* <code>copyArea()</code> bug.
|
||||||
*/
|
*/
|
||||||
protected void findRootBounds ()
|
protected void findRootBounds ()
|
||||||
@@ -245,8 +239,7 @@ public class VirtualMediaPanel extends MediaPanel
|
|||||||
{
|
{
|
||||||
int width = getWidth(), height = getHeight();
|
int width = getWidth(), height = getHeight();
|
||||||
|
|
||||||
// adjusts our view location to track any pathable we might be
|
// adjusts our view location to track any pathable we might be tracking
|
||||||
// tracking
|
|
||||||
trackPathable();
|
trackPathable();
|
||||||
|
|
||||||
// if we have a new target location, we'll need to generate dirty
|
// if we have a new target location, we'll need to generate dirty
|
||||||
@@ -282,9 +275,8 @@ public class VirtualMediaPanel extends MediaPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// now go ahead and update our location so that changes in
|
// now go ahead and update our location so that changes in between here and the call
|
||||||
// between here and the call to paint() for this tick don't
|
// to paint() for this tick don't booch everything
|
||||||
// booch everything
|
|
||||||
_vbounds.x = _nx; _vbounds.y = _ny;
|
_vbounds.x = _nx; _vbounds.y = _ny;
|
||||||
|
|
||||||
addObscurerDirtyRegions(false);
|
addObscurerDirtyRegions(false);
|
||||||
@@ -295,9 +287,8 @@ public class VirtualMediaPanel extends MediaPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called during our tick when we have adjusted the view location. The
|
* Called during our tick when we have adjusted the view location. The {@link #_vbounds} will
|
||||||
* {@link #_vbounds} will already have been updated to reflect our new
|
* already have been updated to reflect our new view coordinates.
|
||||||
* view coordinates.
|
|
||||||
*
|
*
|
||||||
* @param dx the delta scrolled in the x direction (in pixels).
|
* @param dx the delta scrolled in the x direction (in pixels).
|
||||||
* @param dy the delta scrolled in the y direction (in pixels).
|
* @param dy the delta scrolled in the y direction (in pixels).
|
||||||
@@ -314,9 +305,8 @@ public class VirtualMediaPanel extends MediaPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements the standard pathable tracking support. Derived classes
|
* Implements the standard pathable tracking support. Derived classes may wish to override
|
||||||
* may wish to override this if they desire custom tracking
|
* this if they desire custom tracking functionality.
|
||||||
* functionality.
|
|
||||||
*/
|
*/
|
||||||
protected void trackPathable ()
|
protected void trackPathable ()
|
||||||
{
|
{
|
||||||
@@ -375,14 +365,13 @@ public class VirtualMediaPanel extends MediaPanel
|
|||||||
int cx = (_dx > 0) ? _dx : 0;
|
int cx = (_dx > 0) ? _dx : 0;
|
||||||
int cy = (_dy > 0) ? _dy : 0;
|
int cy = (_dy > 0) ? _dy : 0;
|
||||||
|
|
||||||
// set the clip to the bounds of the component (we can't
|
// set the clip to the bounds of the component (we can't assume the clip is anything
|
||||||
// assume the clip is anything sensible upon entry to paint()
|
// sensible upon entry to paint() because the frame manager expects us to set our own
|
||||||
// because the frame manager expects us to set our own clip)
|
// clip)
|
||||||
gfx.setClip(0, 0, width, height);
|
gfx.setClip(0, 0, width, height);
|
||||||
|
|
||||||
// on windows, attempting to call copyArea() on a translated
|
// on windows, attempting to call copyArea() on a translated graphics context results
|
||||||
// graphics context results in boochness; so we have to
|
// in boochness; so we have to untranslate the graphics context, do our copyArea() and
|
||||||
// untranslate the graphics context, do our copyArea() and
|
|
||||||
// then translate it back
|
// then translate it back
|
||||||
if (RunAnywhere.isWindows()) {
|
if (RunAnywhere.isWindows()) {
|
||||||
gfx.translate(-_abounds.x, -_abounds.y);
|
gfx.translate(-_abounds.x, -_abounds.y);
|
||||||
@@ -396,8 +385,8 @@ public class VirtualMediaPanel extends MediaPanel
|
|||||||
width - Math.abs(_dx),
|
width - Math.abs(_dx),
|
||||||
height - Math.abs(_dy), -_dx, -_dy);
|
height - Math.abs(_dy), -_dx, -_dy);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// HACK when it throws an exception trying to do the
|
// HACK when it throws an exception trying to do the copy area, just repaint
|
||||||
// copy area, just repaint everything
|
// everything
|
||||||
dirty = new Rectangle[] { new Rectangle(_vbounds) };
|
dirty = new Rectangle[] { new Rectangle(_vbounds) };
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ public class TransformedMirage
|
|||||||
implements Mirage
|
implements Mirage
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Constructor for backwards compatability that automatically repositions the
|
* Constructor for backwards compatibility that automatically repositions the transformed
|
||||||
* transformed mirage so its new upper-left corner is still at the origin.
|
* mirage so its new upper-left corner is still at the origin.
|
||||||
*/
|
*/
|
||||||
public TransformedMirage (Mirage base, AffineTransform transform)
|
public TransformedMirage (Mirage base, AffineTransform transform)
|
||||||
{
|
{
|
||||||
@@ -119,8 +119,7 @@ public class TransformedMirage
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute the bounds of the base Mirage after it has been
|
* Compute the bounds of the base Mirage after it has been transformed.
|
||||||
* transformed.
|
|
||||||
*/
|
*/
|
||||||
protected void computeTransformedBounds ()
|
protected void computeTransformedBounds ()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -37,22 +37,19 @@ import com.threerings.media.tile.ObjectTile;
|
|||||||
import static com.threerings.media.Log.log;
|
import static com.threerings.media.Log.log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The dirty item list keeps track of dirty sprites and object tiles
|
* The dirty item list keeps track of dirty sprites and object tiles in a scene.
|
||||||
* in a scene.
|
|
||||||
*/
|
*/
|
||||||
public class DirtyItemList
|
public class DirtyItemList
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Creates a dirt item list that will handle dirty items for the
|
* Creates a dirt item list that will handle dirty items for the specified view.
|
||||||
* specified view.
|
|
||||||
*/
|
*/
|
||||||
public DirtyItemList ()
|
public DirtyItemList ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Appends the dirty sprite at the given coordinates to the dirty item
|
* Appends the dirty sprite at the given coordinates to the dirty item list.
|
||||||
* list.
|
|
||||||
*
|
*
|
||||||
* @param sprite the dirty sprite itself.
|
* @param sprite the dirty sprite itself.
|
||||||
* @param tx the sprite's x tile position.
|
* @param tx the sprite's x tile position.
|
||||||
@@ -66,8 +63,7 @@ public class DirtyItemList
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Appends the dirty object tile at the given coordinates to the dirty
|
* Appends the dirty object tile at the given coordinates to the dirty item list.
|
||||||
* item list.
|
|
||||||
*
|
*
|
||||||
* @param scobj the scene object that is dirty.
|
* @param scobj the scene object that is dirty.
|
||||||
*/
|
*/
|
||||||
@@ -87,8 +83,8 @@ public class DirtyItemList
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of the {@link DirtyItem} objects in the list
|
* Returns an array of the {@link DirtyItem} objects in the list sorted in proper rendering
|
||||||
* sorted in proper rendering order.
|
* order.
|
||||||
*/
|
*/
|
||||||
public void sort ()
|
public void sort ()
|
||||||
{
|
{
|
||||||
@@ -121,8 +117,7 @@ public class DirtyItemList
|
|||||||
log.info("Sorted by rear-depth", "items", toString(_ditems));
|
log.info("Sorted by rear-depth", "items", toString(_ditems));
|
||||||
}
|
}
|
||||||
|
|
||||||
// now insertion sort the items from back to front into the
|
// now insertion sort the items from back to front into the render-sorted array
|
||||||
// render-sorted array
|
|
||||||
_items.clear();
|
_items.clear();
|
||||||
POS_LOOP:
|
POS_LOOP:
|
||||||
for (int ii = 0; ii < size; ii++) {
|
for (int ii = 0; ii < size; ii++) {
|
||||||
@@ -136,8 +131,7 @@ public class DirtyItemList
|
|||||||
continue POS_LOOP;
|
continue POS_LOOP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// we don't render in front of anyone, so we go at the
|
// we don't render in front of anyone, so we go at the front of the list
|
||||||
// front of the list
|
|
||||||
_items.add(0, item);
|
_items.add(0, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,9 +154,8 @@ public class DirtyItemList
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Paints all the dirty items in this list using the supplied graphics
|
* Paints all the dirty items in this list using the supplied graphics context. The items are
|
||||||
* context. The items are removed from the dirty list after being
|
* removed from the dirty list after being painted and the dirty list ends up empty.
|
||||||
* painted and the dirty list ends up empty.
|
|
||||||
*/
|
*/
|
||||||
public void paintAndClear (Graphics2D gfx)
|
public void paintAndClear (Graphics2D gfx)
|
||||||
{
|
{
|
||||||
@@ -197,8 +190,8 @@ public class DirtyItemList
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtains a new dirty item instance, reusing an old one if possible
|
* Obtains a new dirty item instance, reusing an old one if possible or creating a new one
|
||||||
* or creating a new one otherwise.
|
* otherwise.
|
||||||
*/
|
*/
|
||||||
protected DirtyItem getDirtyItem ()
|
protected DirtyItem getDirtyItem ()
|
||||||
{
|
{
|
||||||
@@ -210,9 +203,8 @@ public class DirtyItemList
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an abbreviated string representation of the given dirty
|
* Returns an abbreviated string representation of the given dirty item describing only its
|
||||||
* item describing only its origin coordinates and render priority.
|
* origin coordinates and render priority. Intended for debugging purposes.
|
||||||
* Intended for debugging purposes.
|
|
||||||
*/
|
*/
|
||||||
protected static String toString (DirtyItem a)
|
protected static String toString (DirtyItem a)
|
||||||
{
|
{
|
||||||
@@ -222,8 +214,8 @@ public class DirtyItemList
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an abbreviated string representation of the two given dirty
|
* Returns an abbreviated string representation of the two given dirty items. See
|
||||||
* items. See {@link #toString(DirtyItem)}.
|
* {@link #toString(DirtyItem)}.
|
||||||
*/
|
*/
|
||||||
protected static String toString (DirtyItem a, DirtyItem b)
|
protected static String toString (DirtyItem a, DirtyItem b)
|
||||||
{
|
{
|
||||||
@@ -234,8 +226,8 @@ public class DirtyItemList
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an abbreviated string representation of the given dirty
|
* Returns an abbreviated string representation of the given dirty items. See
|
||||||
* items. See {@link #toString(DirtyItem)}.
|
* {@link #toString(DirtyItem)}.
|
||||||
*/
|
*/
|
||||||
protected static String toString (SortableArrayList<DirtyItem> items)
|
protected static String toString (SortableArrayList<DirtyItem> items)
|
||||||
{
|
{
|
||||||
@@ -259,9 +251,9 @@ public class DirtyItemList
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class to hold the items inserted in the dirty list along with
|
* A class to hold the items inserted in the dirty list along with all of the information
|
||||||
* all of the information necessary to render their dirty regions
|
* necessary to render their dirty regions to the target graphics context when the time comes
|
||||||
* to the target graphics context when the time comes to do so.
|
* to do so.
|
||||||
*/
|
*/
|
||||||
public class DirtyItem
|
public class DirtyItem
|
||||||
{
|
{
|
||||||
@@ -280,15 +272,13 @@ public class DirtyItemList
|
|||||||
/**
|
/**
|
||||||
* Initializes a dirty item.
|
* Initializes a dirty item.
|
||||||
*/
|
*/
|
||||||
public void init (Object obj, int x, int y)
|
public void init (Object obj, int x, int y) {
|
||||||
{
|
|
||||||
this.obj = obj;
|
this.obj = obj;
|
||||||
this.ox = x;
|
this.ox = x;
|
||||||
this.oy = y;
|
this.oy = y;
|
||||||
|
|
||||||
// calculate the item's leftmost and rightmost tiles; note
|
// calculate the item's leftmost and rightmost tiles; note that normal (Non-MultiTile)
|
||||||
// that normal (Non-MultiTile) sprites occupy only a single tile, so leftmost and
|
// sprites occupy only a single tile, so leftmost and rightmost tiles are equivalent
|
||||||
// rightmost tiles are equivalent
|
|
||||||
lx = rx = ox;
|
lx = rx = ox;
|
||||||
ly = ry = oy;
|
ly = ry = oy;
|
||||||
if (obj instanceof SceneObject) {
|
if (obj instanceof SceneObject) {
|
||||||
@@ -303,12 +293,10 @@ public class DirtyItemList
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Paints the dirty item to the given graphics context. Only
|
* Paints the dirty item to the given graphics context. Only the portion of the item that
|
||||||
* the portion of the item that falls within the given dirty
|
* falls within the given dirty rectangle is actually drawn.
|
||||||
* rectangle is actually drawn.
|
|
||||||
*/
|
*/
|
||||||
public void paint (Graphics2D gfx)
|
public void paint (Graphics2D gfx) {
|
||||||
{
|
|
||||||
if (obj instanceof Sprite) {
|
if (obj instanceof Sprite) {
|
||||||
((Sprite)obj).paint(gfx);
|
((Sprite)obj).paint(gfx);
|
||||||
} else {
|
} else {
|
||||||
@@ -319,18 +307,15 @@ public class DirtyItemList
|
|||||||
/**
|
/**
|
||||||
* Returns the "depth" of our rear-most tile.
|
* Returns the "depth" of our rear-most tile.
|
||||||
*/
|
*/
|
||||||
public int getRearDepth ()
|
public int getRearDepth () {
|
||||||
{
|
|
||||||
return ry + lx;
|
return ry + lx;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the render priority for this dirty item. It will be
|
* Returns the render priority for this dirty item. It will be zero unless this is a
|
||||||
* zero unless this is a display object which may have a custom
|
* display object which may have a custom render priority.
|
||||||
* render priority.
|
|
||||||
*/
|
*/
|
||||||
public int getRenderPriority ()
|
public int getRenderPriority () {
|
||||||
{
|
|
||||||
if (obj instanceof SceneObject) {
|
if (obj instanceof SceneObject) {
|
||||||
return ((SceneObject)obj).getPriority();
|
return ((SceneObject)obj).getPriority();
|
||||||
} else {
|
} else {
|
||||||
@@ -339,18 +324,15 @@ public class DirtyItemList
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Releases all references held by this dirty item so that it
|
* Releases all references held by this dirty item so that it doesn't inadvertently hold
|
||||||
* doesn't inadvertently hold on to any objects while waiting to
|
* on to any objects while waiting to be reused.
|
||||||
* be reused.
|
|
||||||
*/
|
*/
|
||||||
public void clear ()
|
public void clear () {
|
||||||
{
|
|
||||||
obj = null;
|
obj = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals (Object other)
|
public boolean equals (Object other) {
|
||||||
{
|
|
||||||
// we're never equal to something that's not our kind
|
// we're never equal to something that's not our kind
|
||||||
if (!(other instanceof DirtyItem)) {
|
if (!(other instanceof DirtyItem)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -362,14 +344,12 @@ public class DirtyItemList
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode ()
|
public int hashCode () {
|
||||||
{
|
|
||||||
return obj.hashCode();
|
return obj.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString ()
|
public String toString () {
|
||||||
{
|
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
buf.append("[obj=").append(obj);
|
buf.append("[obj=").append(obj);
|
||||||
buf.append(", ox=").append(ox);
|
buf.append(", ox=").append(ox);
|
||||||
@@ -383,24 +363,21 @@ public class DirtyItemList
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A comparator class for use in sorting dirty items in ascending
|
* A comparator class for use in sorting dirty items in ascending origin x- or y-axis
|
||||||
* origin x- or y-axis coordinate order.
|
* coordinate order.
|
||||||
*/
|
*/
|
||||||
protected static class OriginComparator implements Comparator<DirtyItem>
|
protected static class OriginComparator implements Comparator<DirtyItem>
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Constructs an origin comparator that sorts dirty items in
|
* Constructs an origin comparator that sorts dirty items in ascending order based on
|
||||||
* ascending order based on their origin coordinate on the given
|
* their origin coordinate on the given axis.
|
||||||
* axis.
|
*/
|
||||||
*/
|
public OriginComparator (int axis) {
|
||||||
public OriginComparator (int axis)
|
|
||||||
{
|
|
||||||
_axis = axis;
|
_axis = axis;
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public int compare (DirtyItem da, DirtyItem db)
|
public int compare (DirtyItem da, DirtyItem db) {
|
||||||
{
|
|
||||||
// if they don't overlap, sort them normally
|
// if they don't overlap, sort them normally
|
||||||
if (_axis == X_AXIS) {
|
if (_axis == X_AXIS) {
|
||||||
if (da.ox != db.ox) {
|
if (da.ox != db.ox) {
|
||||||
@@ -422,16 +399,14 @@ public class DirtyItemList
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A comparator class for use in sorting the dirty sprites and
|
* A comparator class for use in sorting the dirty sprites and objects in a scene in ascending
|
||||||
* objects in a scene in ascending x- and y-coordinate order
|
* x- and y-coordinate order suitable for rendering in the isometric view with proper visual
|
||||||
* suitable for rendering in the isometric view with proper visual
|
|
||||||
* results.
|
* results.
|
||||||
*/
|
*/
|
||||||
protected class RenderComparator implements Comparator<DirtyItem>
|
protected class RenderComparator implements Comparator<DirtyItem>
|
||||||
{
|
{
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public int compare (DirtyItem da, DirtyItem db)
|
public int compare (DirtyItem da, DirtyItem db) {
|
||||||
{
|
|
||||||
// if the two objects are scene objects and they overlap, we
|
// if the two objects are scene objects and they overlap, we
|
||||||
// compare them solely based on their human assigned priority
|
// compare them solely based on their human assigned priority
|
||||||
if ((da.obj instanceof SceneObject) &&
|
if ((da.obj instanceof SceneObject) &&
|
||||||
@@ -479,11 +454,10 @@ public class DirtyItemList
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether two dirty items have a partitioning object
|
* Returns whether two dirty items have a partitioning object between them on the given
|
||||||
* between them on the given axis.
|
* axis.
|
||||||
*/
|
*/
|
||||||
protected int comparePartitioned (int axis, DirtyItem da, DirtyItem db)
|
protected int comparePartitioned (int axis, DirtyItem da, DirtyItem db) {
|
||||||
{
|
|
||||||
// prepare for the partitioning check
|
// prepare for the partitioning check
|
||||||
SortableArrayList<DirtyItem> sitems;
|
SortableArrayList<DirtyItem> sitems;
|
||||||
Comparator<DirtyItem> comp;
|
Comparator<DirtyItem> comp;
|
||||||
@@ -529,8 +503,7 @@ public class DirtyItemList
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the bounding item indices and the number of
|
// get the bounding item indices and the number of potentially-partitioning dirty items
|
||||||
// potentially-partitioning dirty items
|
|
||||||
int aidx = sitems.binarySearch(da, comp);
|
int aidx = sitems.binarySearch(da, comp);
|
||||||
int bidx = sitems.binarySearch(db, comp);
|
int bidx = sitems.binarySearch(db, comp);
|
||||||
int size = bidx - aidx - 1;
|
int size = bidx - aidx - 1;
|
||||||
@@ -576,11 +549,9 @@ public class DirtyItemList
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compares the two dirty items assuming there are no partitioning
|
* Compares the two dirty items assuming there are no partitioning objects between them.
|
||||||
* objects between them.
|
|
||||||
*/
|
*/
|
||||||
protected int compareNonPartitioned (DirtyItem da, DirtyItem db)
|
protected int compareNonPartitioned (DirtyItem da, DirtyItem db) {
|
||||||
{
|
|
||||||
if (da.ox == db.ox &&
|
if (da.ox == db.ox &&
|
||||||
da.oy == db.oy) {
|
da.oy == db.oy) {
|
||||||
if (da.equals(db)) {
|
if (da.equals(db)) {
|
||||||
@@ -674,16 +645,13 @@ public class DirtyItemList
|
|||||||
protected static final int X_AXIS = 0;
|
protected static final int X_AXIS = 0;
|
||||||
protected static final int Y_AXIS = 1;
|
protected static final int Y_AXIS = 1;
|
||||||
|
|
||||||
/** The comparator used to sort dirty items in ascending origin
|
/** The comparator used to sort dirty items in ascending origin x-coordinate order. */
|
||||||
* x-coordinate order. */
|
|
||||||
protected static final Comparator<DirtyItem> ORIGIN_X_COMP = new OriginComparator(X_AXIS);
|
protected static final Comparator<DirtyItem> ORIGIN_X_COMP = new OriginComparator(X_AXIS);
|
||||||
|
|
||||||
/** The comparator used to sort dirty items in ascending origin
|
/** The comparator used to sort dirty items in ascending origin y-coordinate order. */
|
||||||
* y-coordinate order. */
|
|
||||||
protected static final Comparator<DirtyItem> ORIGIN_Y_COMP = new OriginComparator(Y_AXIS);
|
protected static final Comparator<DirtyItem> ORIGIN_Y_COMP = new OriginComparator(Y_AXIS);
|
||||||
|
|
||||||
/** The comparator used to sort dirty items in ascending "rear-depth"
|
/** The comparator used to sort dirty items in ascending "rear-depth" order. */
|
||||||
* order. */
|
|
||||||
protected static final Comparator<DirtyItem> REAR_DEPTH_COMP = new Comparator<DirtyItem>() {
|
protected static final Comparator<DirtyItem> REAR_DEPTH_COMP = new Comparator<DirtyItem>() {
|
||||||
public int compare (DirtyItem o1, DirtyItem o2) {
|
public int compare (DirtyItem o1, DirtyItem o2) {
|
||||||
int depthDiff = (o1.getRearDepth() - o2.getRearDepth());
|
int depthDiff = (o1.getRearDepth() - o2.getRearDepth());
|
||||||
|
|||||||
Reference in New Issue
Block a user