[c][cpp] Apply skeleton.scaleX/scaleY to wind and gravity. See #2729.

Tested using the spine-sdl runtime and cloud-pot example for both spine-c and spine-cpp.

spine-c's PhysicsConstraint.c has the gravity inverted as it will need to be inverted if the runtime is y-down rather than y-up.
If the runtime is y-up, remove the negative sign and parentheses from self->gravity in line 143.
This commit is contained in:
Luke Ingram 2025-02-10 09:47:32 -04:00
parent 0b2f403562
commit eca4b9e4c1
2 changed files with 2 additions and 2 deletions

View File

@ -140,7 +140,7 @@ void spPhysicsConstraint_update(spPhysicsConstraint *self, spPhysics physics) {
}
if (a >= t) {
float d = POW(self->damping, 60 * t);
float m = self->massInverse * t, e = self->strength, w = self->wind * f, g = self->gravity * f * (spBone_isYDown() ? -1 : 1);
float m = self->massInverse * t, e = self->strength, w = self->wind * f * self->skeleton->scaleX, g = -(self->gravity) * f * self->skeleton->scaleY;
do {
if (x) {
self->xVelocity += (w - self->xOffset * e) * m;

View File

@ -352,7 +352,7 @@ void PhysicsConstraint::update(Physics physics) {
}
if (a >= t) {
float d = MathUtil::pow(_damping, 60 * t);
float m = _massInverse * t, e = _strength, w = _wind * f, g = _gravity * f * (Bone::yDown ? -1 : 1);
float m = _massInverse * t, e = _strength, w = _wind * f * _skeleton.getScaleX(), g = _gravity * f * _skeleton.getScaleY();
do {
if (x) {
_xVelocity += (w - _xOffset * e) * m;