Fix custom objects inner area expansion on Z axis (#7200)

This commit is contained in:
D8H
2024-11-27 14:54:45 +01:00
committed by GitHub
parent d0f3abc38d
commit aa12248d86

View File

@@ -112,10 +112,25 @@ namespace gdjs {
* @return The Z position of the rendered object.
*/
getDrawableZ(): float {
if (this._isUntransformedHitBoxesDirty) {
this._updateUntransformedHitBoxes();
let minZ = 0;
if (this._innerArea) {
minZ = this._innerArea.min[2];
} else {
if (this._isUntransformedHitBoxesDirty) {
this._updateUntransformedHitBoxes();
}
minZ = this._minZ;
}
const absScaleZ = this.getScaleZ();
if (!this._flippedZ) {
return this._z + minZ * absScaleZ;
} else {
return (
this._z +
(-minZ - this.getUnscaledDepth() + 2 * this.getUnscaledCenterZ()) *
absScaleZ
);
}
return this._z + this._minZ;
}
/**
@@ -238,10 +253,39 @@ namespace gdjs {
this.setAngle(gdjs.toDegrees(mesh.rotation.z));
}
/**
* @return the internal top bound of the object according to its children.
*/
getInnerAreaMinZ(): number {
if (this._innerArea) {
return this._innerArea.min[2];
}
if (this._isUntransformedHitBoxesDirty) {
this._updateUntransformedHitBoxes();
}
return this._minZ;
}
/**
* @return the internal bottom bound of the object according to its children.
*/
getInnerAreaMaxZ(): number {
if (this._innerArea) {
return this._innerArea.max[2];
}
if (this._isUntransformedHitBoxesDirty) {
this._updateUntransformedHitBoxes();
}
return this._maxZ;
}
/**
* @return the internal width of the object according to its children.
*/
getUnscaledDepth(): float {
if (this._innerArea) {
return this._innerArea.max[2] - this._innerArea.min[2];
}
if (this._isUntransformedHitBoxesDirty) {
this._updateUntransformedHitBoxes();
}
@@ -280,6 +324,9 @@ namespace gdjs {
if (this.hasCustomRotationCenter()) {
return this._customCenterZ;
}
if (this._innerArea) {
return (this._innerArea.min[2] + this._innerArea.max[2]) / 2;
}
if (this._isUntransformedHitBoxesDirty) {
this._updateUntransformedHitBoxes();
}