Skip to content

[runtimes] PhysicsConstraint scale lag compensation is not SkeletonData.scale invariant #3149

Description

@badlogic

Issue

PhysicsConstraint scale lag compensation is not SkeletonData.scale invariant.

The issue appears to be related to import scale not affecting scaleLag in the PhysicsConstraint implementation.

Problem

In the current implementation (spine-libgdx):
https://github.com/EsotericSoftware/spine-runtimes/blob/4.3/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/PhysicsConstraint.java#L192

float r = l * bone.getWorldScaleX() - scaleLag * Math.max(0, 1 - aa / t);

The left part l * bone.getWorldScaleX() is a length which is scaled by import scale, while the right part - scaleLag * Math.max(0, 1 - aa / t) is not. This makes the physics behavior dependent on import scale and causes stability issues with smaller import scale.

Proposed Solution

Suggested fix (from GPT-5.6):

float scaleLagZ = scaleLag * Math.max(0, 1 - aa / t);
float r = l * (bone.WorldScaleX - scaleLagZ);

This makes the scale lag compensation scale-invariant.

Reproduction

Forum thread: https://esotericsoftware.com/forum/d/30439

Repro project (needs import scale of 0.004 to trigger the issue, stable with 0.01):
https://mail.google.com/mail/u/2/#inbox/FMfcgzQhVNZkdjGkHRplxRQQbwRblGKh

With the proposed fix, the issue is resolved for the repro project.

Note

Other lag compensations appear to be correct according to analysis. Only this particular branch does not use proper lag correction.

Related code (no lag correction applied):
https://github.com/EsotericSoftware/spine-runtimes/blob/4.3/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/PhysicsConstraint.java

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions