kopia lustrzana https://github.com/backface/turtlestitch
Cache stage>>penTrailsMorph to optimize collision detection
also fixed a collision detection errror when objects are sub-pixel sizedpull/89/head
rodzic
f6b36ed2f2
commit
c98fdacd4f
|
@ -1,5 +1,10 @@
|
|||
# Snap<em>!</em> (BYOB) History
|
||||
|
||||
## in development
|
||||
### 2018-11-27
|
||||
* Objects: Cache stage>>penTrailsMorph to optimize collision detection
|
||||
* Objects: Fixed a collision detection errror when objects are sub-pixel sized
|
||||
|
||||
## v4.2.2.8
|
||||
### 2018-11-21
|
||||
* Tools library: Fixed LABEL block to again allow printing both text and numbers
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Snap! Build Your Own Blocks 4.2.2.8</title>
|
||||
<title>Snap! Build Your Own Blocks 4.2.2.9 - dev -</title>
|
||||
<link rel="shortcut icon" href="src/favicon.ico">
|
||||
<script type="text/javascript" src="src/morphic.js?version=2018-10-02"></script>
|
||||
<script type="text/javascript" src="src/widgets.js?version=2018-10-02"></script>
|
||||
<script type="text/javascript" src="src/blocks.js?version=2018-11-13"></script>
|
||||
<script type="text/javascript" src="src/threads.js?version=2018-10-26"></script>
|
||||
<script type="text/javascript" src="src/objects.js?version=2018-11-12"></script>
|
||||
<script type="text/javascript" src="src/gui.js?version=2018-11-21"></script>
|
||||
<script type="text/javascript" src="src/objects.js?version=2018-11-27"></script>
|
||||
<script type="text/javascript" src="src/gui.js?version=2018-11-27"></script>
|
||||
<script type="text/javascript" src="src/paint.js?version=2018-10-02"></script>
|
||||
<script type="text/javascript" src="src/lists.js?version=2018-10-02"></script>
|
||||
<script type="text/javascript" src="src/byob.js?version=2018-11-12"></script>
|
||||
|
|
|
@ -75,7 +75,7 @@ isRetinaSupported, SliderMorph, Animation, BoxMorph, MediaRecorder*/
|
|||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.gui = '2018-November-21';
|
||||
modules.gui = '2018-November-27';
|
||||
|
||||
// Declarations
|
||||
|
||||
|
@ -3539,7 +3539,7 @@ IDE_Morph.prototype.aboutSnap = function () {
|
|||
module, btn1, btn2, btn3, btn4, licenseBtn, translatorsBtn,
|
||||
world = this.world();
|
||||
|
||||
aboutTxt = 'Snap! 4.2.2.8\nBuild Your Own Blocks\n\n'
|
||||
aboutTxt = 'Snap! 4.2.2.9 - dev -\nBuild Your Own Blocks\n\n'
|
||||
+ 'Copyright \u24B8 2018 Jens M\u00F6nig and '
|
||||
+ 'Brian Harvey\n'
|
||||
+ 'jens@moenig.org, bh@cs.berkeley.edu\n\n'
|
||||
|
|
|
@ -83,7 +83,7 @@ BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, localize,
|
|||
TableMorph, TableFrameMorph, normalizeCanvas, BooleanSlotMorph, HandleMorph,
|
||||
AlignmentMorph, Process, XML_Element, VectorPaintEditorMorph*/
|
||||
|
||||
modules.objects = '2018-November-12';
|
||||
modules.objects = '2018-November-27';
|
||||
|
||||
var SpriteMorph;
|
||||
var StageMorph;
|
||||
|
@ -3608,7 +3608,9 @@ SpriteMorph.prototype.overlappingImage = function (otherSprite) {
|
|||
oImg = newCanvas(oRect.extent(), true),
|
||||
ctx = oImg.getContext('2d');
|
||||
|
||||
if (oRect.width() < 1 || oRect.height() < 1) {
|
||||
if (oRect.width() < 1 || oRect.height() < 1 ||
|
||||
!this.image.width || !this.image.height
|
||||
|| !otherSprite.image.width || !otherSprite.image.height) {
|
||||
return newCanvas(new Point(1, 1), true);
|
||||
}
|
||||
ctx.drawImage(
|
||||
|
@ -3654,6 +3656,7 @@ SpriteMorph.prototype.doStamp = function () {
|
|||
if (isWarped) {
|
||||
this.startWarp();
|
||||
}
|
||||
stage.cachedPenTrailsMorph = null;
|
||||
};
|
||||
|
||||
SpriteMorph.prototype.clear = function () {
|
||||
|
@ -4272,6 +4275,7 @@ SpriteMorph.prototype.drawLine = function (start, dest) {
|
|||
if (this.isWarped === false) {
|
||||
this.world().broken.push(damaged);
|
||||
}
|
||||
this.parent.cachedPenTrailsMorph = null;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -4279,6 +4283,7 @@ SpriteMorph.prototype.floodFill = function () {
|
|||
if (!this.parent.bounds.containsPoint(this.rotationCenter())) {
|
||||
return;
|
||||
}
|
||||
this.parent.cachedPenTrailsMorph = null;
|
||||
if (this.color.a > 1) {
|
||||
// fix a legacy bug in Morphic color detection
|
||||
this.color.a = this.color.a / 255;
|
||||
|
@ -6386,6 +6391,8 @@ StageMorph.prototype.init = function (globals) {
|
|||
'brightness': 0
|
||||
};
|
||||
|
||||
this.cachedPenTrailsMorph = null; // optimization, do not persist
|
||||
|
||||
StageMorph.uber.init.call(this);
|
||||
|
||||
this.acceptsDrops = false;
|
||||
|
@ -6404,6 +6411,7 @@ StageMorph.prototype.setScale = function (number) {
|
|||
myself = this;
|
||||
|
||||
if (delta === 1) {return; }
|
||||
this.cachedPenTrailsMorph = null;
|
||||
Morph.prototype.trackChanges = false;
|
||||
this.scale = number;
|
||||
this.setExtent(this.dimensions.multiplyBy(number));
|
||||
|
@ -6526,6 +6534,7 @@ StageMorph.prototype.drawOn = function (aCanvas, aRect) {
|
|||
};
|
||||
|
||||
StageMorph.prototype.clearPenTrails = function () {
|
||||
this.cachedPenTrailsMorph = null;
|
||||
this.trailsCanvas = newCanvas(this.dimensions);
|
||||
this.changed();
|
||||
};
|
||||
|
@ -6539,10 +6548,18 @@ StageMorph.prototype.penTrails = function () {
|
|||
|
||||
StageMorph.prototype.penTrailsMorph = function () {
|
||||
// for collision detection purposes
|
||||
var morph = new Morph(),
|
||||
trails = this.penTrails(),
|
||||
ctx;
|
||||
var morph, trails, ctx;
|
||||
|
||||
if (this.cachedPenTrailsMorph) {
|
||||
return this.cachedPenTrailsMorph;
|
||||
}
|
||||
morph = new Morph();
|
||||
trails = this.penTrails();
|
||||
morph.bounds = this.bounds.copy();
|
||||
if (this.image.width === trails.width) {
|
||||
morph.image = trails;
|
||||
return morph;
|
||||
}
|
||||
morph.image = newCanvas(this.extent());
|
||||
ctx = morph.image.getContext('2d');
|
||||
ctx.drawImage(
|
||||
|
@ -6556,6 +6573,7 @@ StageMorph.prototype.penTrailsMorph = function () {
|
|||
this.image.width,
|
||||
this.image.height
|
||||
);
|
||||
this.cachedPenTrailsMorph = morph;
|
||||
return morph;
|
||||
};
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue