From 6ff80f8a92f11f779b13a3ab6f9780f26ea1d3a2 Mon Sep 17 00:00:00 2001 From: Walter Korman Date: Thu, 25 Oct 2001 03:01:13 +0000 Subject: [PATCH] Don't merge dirty rectangles when moving a sprite if the rectangles don't overlap. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@555 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../com/threerings/media/sprite/Sprite.java | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/java/com/threerings/media/sprite/Sprite.java b/src/java/com/threerings/media/sprite/Sprite.java index 69b37080b..d60e38d44 100644 --- a/src/java/com/threerings/media/sprite/Sprite.java +++ b/src/java/com/threerings/media/sprite/Sprite.java @@ -1,5 +1,5 @@ // -// $Id: Sprite.java,v 1.28 2001/10/25 01:39:38 shaper Exp $ +// $Id: Sprite.java,v 1.29 2001/10/25 03:01:13 shaper Exp $ package com.threerings.media.sprite; @@ -123,15 +123,26 @@ public class Sprite { // create a starting dirty rectangle with our current position Rectangle dirty = new Rectangle(_bounds); + // move ourselves _x = x; _y = y; - // we need to update our draw position which is based on the size - // of our current frame + + // we need to update our draw position which is based on the + // size of our current frame updateRenderOrigin(); - // grow the dirty rectangle to reflect our new location - dirty.add(_bounds); - // and invalidate the whole shebang + + if (dirty.intersects(_bounds)) { + // grow the dirty rectangle to reflect our new location + dirty.add(_bounds); + } else { + // dirty the new rectangle separately from the old to + // avoid potentially creating a large dirty rectangle if + // the sprite warps from place to place + invalidate(new Rectangle(_bounds)); + } + + // invalidate the potentially-grown starting dirty rectangle invalidate(dirty); }