speed-up talk bubble positioning by 5x

pull/95/head
jmoenig 2021-04-17 16:38:05 +02:00
rodzic 5c5c0fd249
commit 72894b60b8
3 zmienionych plików z 13 dodań i 4 usunięć

Wyświetl plik

@ -1,12 +1,15 @@
# Snap! (BYOB) History
## in development:
* **Notable Changes:**
* speed-up talk bubble positioning by 5x
* **Notable Fixes:**
* work around a floating point precision glitch in "ray length"
### 2021-04-17
* new dev version
* threads: worked around a floating point precision glitch in "ray length"
* objects: speed-up talk bubble positioning by 5x
## 6.7.4
* **Notable Fixes:**

Wyświetl plik

@ -10,7 +10,7 @@
<script src="src/widgets.js?version=2021-01-05"></script>
<script src="src/blocks.js?version=2021-02-27"></script>
<script src="src/threads.js?version=2021-04-17"></script>
<script src="src/objects.js?version=2021-04-09"></script>
<script src="src/objects.js?version=2021-04-17"></script>
<script src="src/gui.js?version=2021-04-17"></script>
<script src="src/paint.js?version=2020-05-17"></script>
<script src="src/lists.js?version=2021-03-15"></script>

Wyświetl plik

@ -84,7 +84,7 @@ BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, BooleanSlotMorph,
localize, TableMorph, TableFrameMorph, normalizeCanvas, VectorPaintEditorMorph,
AlignmentMorph, Process, WorldMap, copyCanvas, useBlurredShadows*/
modules.objects = '2021-April-09';
modules.objects = '2021-April-17';
var SpriteMorph;
var StageMorph;
@ -5377,7 +5377,12 @@ SpriteMorph.prototype.positionTalkBubble = function () {
var stage = this.parentThatIsA(StageMorph),
stageScale = stage ? stage.scale : 1,
bubble = this.talkBubble(),
middle = this.center().y;
middle = this.center().y,
// step = new Point(-10, 10);
step = this.extent().divideBy(10)
.max(new Point(5, 5).scaleBy(stageScale))
.multiplyBy(new Point(-1, 1));
if (!bubble) {return null; }
bubble.show();
if (!bubble.isPointingRight) {
@ -5388,8 +5393,9 @@ SpriteMorph.prototype.positionTalkBubble = function () {
bubble.setLeft(this.right());
bubble.setBottom(this.top());
while (!this.isTouching(bubble) && bubble.bottom() < middle) {
bubble.moveBy(new Point(-1, 1).scaleBy(stageScale));
bubble.moveBy(step);
}
bubble.moveBy(step.mirror());
if (!stage) {return null; }
if (bubble.right() > stage.right()) {
bubble.isPointingRight = false;