mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Fix custom objects inner area expansion on Z axis (#7200)
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user