perf: only use entity position once
This commit is contained in:
parent
548e206bc9
commit
d6d18dbd24
|
@ -129,9 +129,8 @@ export class Pictured extends decorate(Trait) {
|
|||
return [0, 0, 0, 0];
|
||||
}
|
||||
const viewPosition = this.offsetFor(key);
|
||||
const position = Vector.add(this.entity.position, viewPosition);
|
||||
const size = this.sizeFor(key);
|
||||
const rectangle = Rectangle.compose(position, size);
|
||||
const rectangle = Rectangle.compose(viewPosition, size);
|
||||
const expanded = Rectangle.expand(
|
||||
rectangle,
|
||||
Vector.sub(Vector.mul(size, this.entity.rawVisibleScale), size),
|
||||
|
|
|
@ -205,7 +205,11 @@ export class Visible extends decorate(Trait) {
|
|||
visibleAabb,
|
||||
);
|
||||
}
|
||||
this.visibleAabb = unifiedBoundingBox;
|
||||
const visibleAabb = Rectangle.translated(
|
||||
unifiedBoundingBox,
|
||||
this.entity.position
|
||||
);
|
||||
this.visibleAabb = visibleAabb;
|
||||
this.scheduledBoundingBoxUpdate = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -164,9 +164,8 @@ class AnimatedBase extends Trait {
|
|||
return [0, 0, 0, 0];
|
||||
}
|
||||
const viewPosition = this.offsetFor(key);
|
||||
const position = Vector.add(this.entity.position, viewPosition);
|
||||
const size = animation.frameSize;
|
||||
const rectangle = Rectangle.compose(position, size);
|
||||
const rectangle = Rectangle.compose(viewPosition, size);
|
||||
const expanded = Rectangle.expand(
|
||||
rectangle,
|
||||
Vector.sub(Vector.mul(size, this.entity.rawVisibleScale), size),
|
||||
|
|
Loading…
Reference in New Issue
Block a user