Skip to content

Commit

Permalink
Fix custom objects inner area expansion on Z axis (#7200)
Browse files Browse the repository at this point in the history
  • Loading branch information
D8H authored Nov 27, 2024
1 parent d0f3abc commit aa12248
Showing 1 changed file with 50 additions and 3 deletions.
53 changes: 50 additions & 3 deletions Extensions/3D/CustomRuntimeObject3D.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit aa12248

Please sign in to comment.