Skip to content

Commit

Permalink
Fix custom object flipping (#6967)
Browse files Browse the repository at this point in the history
Do not show in changelog
  • Loading branch information
D8H authored Sep 17, 2024
1 parent 96d912a commit 1a3a27b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,15 +301,22 @@ export default class LegacyRenderedCustomObjectInstance
this._instance.getAngle()
);

this._pixiObject.scale.x = 1;
this._pixiObject.scale.y = 1;

// Opacity is not handled by 3D objects.
// TODO Transform 3D objects according to their flipping.
if (!this._isRenderedIn3D) {
// Do not hide completely an object so it can still be manipulated
const alphaForDisplay = Math.max(this._instance.getOpacity() / 255, 0.5);
this._pixiObject.alpha = alphaForDisplay;

if (this._instance.isFlippedX()) this._pixiObject.scale.x *= -1;
if (this._instance.isFlippedY()) this._pixiObject.scale.y *= -1;
this._pixiObject.scale.x =
Math.abs(this._pixiObject.scale.x) *
(this._instance.isFlippedX() ? -1 : 1);
this._pixiObject.scale.y =
Math.abs(this._pixiObject.scale.y) *
(this._instance.isFlippedY() ? -1 : 1);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@ export default class RenderedCustomObjectInstance extends Rendered3DInstance
this._pixiObject.rotation = RenderedInstance.toRad(
this._instance.getAngle()
);

this._pixiObject.scale.x = 1;
this._pixiObject.scale.y = 1;
}
Expand All @@ -399,8 +398,12 @@ export default class RenderedCustomObjectInstance extends Rendered3DInstance
const alphaForDisplay = Math.max(this._instance.getOpacity() / 255, 0.5);
this._pixiObject.alpha = alphaForDisplay;

if (this._instance.isFlippedX()) this._pixiObject.scale.x *= -1;
if (this._instance.isFlippedY()) this._pixiObject.scale.y *= -1;
this._pixiObject.scale.x =
Math.abs(this._pixiObject.scale.x) *
(this._instance.isFlippedX() ? -1 : 1);
this._pixiObject.scale.y =
Math.abs(this._pixiObject.scale.y) *
(this._instance.isFlippedY() ? -1 : 1);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,12 @@ export default class RenderedSpriteInstance extends RenderedInstance {
const alphaForDisplay = Math.max(this._instance.getOpacity() / 255, 0.5);
this._pixiObject.alpha = alphaForDisplay;

if (this._instance.isFlippedX()) this._pixiObject.scale.x *= -1;
if (this._instance.isFlippedY()) this._pixiObject.scale.y *= -1;
this._pixiObject.scale.x =
Math.abs(this._pixiObject.scale.x) *
(this._instance.isFlippedX() ? -1 : 1);
this._pixiObject.scale.y =
Math.abs(this._pixiObject.scale.y) *
(this._instance.isFlippedY() ? -1 : 1);
}

updateSprite(): boolean {
Expand Down Expand Up @@ -215,13 +219,13 @@ export default class RenderedSpriteInstance extends RenderedInstance {
getOriginX(): number {
if (!this._sprite || !this._pixiObject) return 0;

return this._sprite.getOrigin().getX() * this._pixiObject.scale.x;
return this._sprite.getOrigin().getX() * Math.abs(this._pixiObject.scale.x);
}

getOriginY(): number {
if (!this._sprite || !this._pixiObject) return 0;

return this._sprite.getOrigin().getY() * this._pixiObject.scale.y;
return this._sprite.getOrigin().getY() * Math.abs(this._pixiObject.scale.y);
}

getDefaultWidth(): number {
Expand Down

0 comments on commit 1a3a27b

Please sign in to comment.