From 17b6ae839b5c15c942440f38fc07bfcc45bc0811 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Wed, 3 Dec 2014 12:48:31 +0100 Subject: Improve edge-collision detection of default sprite “arrow” shape MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- history.txt | 5 +++++ objects.js | 9 ++++++--- threads.js | 14 ++++++++++---- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/history.txt b/history.txt index 986bcc4..b8af0f0 100755 --- a/history.txt +++ b/history.txt @@ -2372,3 +2372,8 @@ ______ 141202 ------ * New Kannada translation. Yay!! Thanks, Vinayakumar R!! + +141203 +------ +* Morphic: Cache actual bounding box of the Pen arrow shape +* Threads, Objects: Improve edge-collision detection of default sprite “arrow” shape diff --git a/objects.js b/objects.js index f0fe942..4ad376c 100644 --- a/objects.js +++ b/objects.js @@ -125,7 +125,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2014-December-01'; +modules.objects = '2014-December-03'; var SpriteMorph; var StageMorph; @@ -3238,8 +3238,11 @@ SpriteMorph.prototype.setCenter = function (aPoint, justMe) { SpriteMorph.prototype.nestingBounds = function () { // same as fullBounds(), except that it uses "parts" instead of children - var result; - result = this.bounds; + // and special cases the costume-less "arrow" shape's bounding box + var result = this.bounds; + if (!this.costume && this.penBounds) { + result = this.penBounds.translateBy(this.position()); + } this.parts.forEach(function (part) { if (part.isVisible) { result = result.merge(part.nestingBounds()); diff --git a/threads.js b/threads.js index 59dd23a..9f9a221 100644 --- a/threads.js +++ b/threads.js @@ -83,7 +83,7 @@ ArgLabelMorph, localize, XML_Element, hex_sha512*/ // Global stuff //////////////////////////////////////////////////////// -modules.threads = '2014-November-26'; +modules.threads = '2014-December-03'; var ThreadManager; var Process; @@ -2368,6 +2368,7 @@ Process.prototype.objectTouchingObject = function (thisObj, name) { var myself = this, those, stage, + box, mouse; if (this.inputOption(name) === 'mouse-pointer') { @@ -2379,9 +2380,14 @@ Process.prototype.objectTouchingObject = function (thisObj, name) { } else { stage = thisObj.parentThatIsA(StageMorph); if (stage) { - if (this.inputOption(name) === 'edge' && - !stage.bounds.containsRectangle(thisObj.bounds)) { - return true; + if (this.inputOption(name) === 'edge') { + box = thisObj.bounds; + if (!thisObj.costume && thisObj.penBounds) { + box = thisObj.penBounds.translateBy(thisObj.position()); + } + if (!stage.bounds.containsRectangle(box)) { + return true; + } } if (this.inputOption(name) === 'pen trails' && thisObj.isTouching(stage.penTrailsMorph())) { -- cgit v1.3.1