mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
[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:
parent
0b2f403562
commit
eca4b9e4c1
@ -140,7 +140,7 @@ void spPhysicsConstraint_update(spPhysicsConstraint *self, spPhysics physics) {
|
|||||||
}
|
}
|
||||||
if (a >= t) {
|
if (a >= t) {
|
||||||
float d = POW(self->damping, 60 * 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 {
|
do {
|
||||||
if (x) {
|
if (x) {
|
||||||
self->xVelocity += (w - self->xOffset * e) * m;
|
self->xVelocity += (w - self->xOffset * e) * m;
|
||||||
|
|||||||
@ -352,7 +352,7 @@ void PhysicsConstraint::update(Physics physics) {
|
|||||||
}
|
}
|
||||||
if (a >= t) {
|
if (a >= t) {
|
||||||
float d = MathUtil::pow(_damping, 60 * 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 {
|
do {
|
||||||
if (x) {
|
if (x) {
|
||||||
_xVelocity += (w - _xOffset * e) * m;
|
_xVelocity += (w - _xOffset * e) * m;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user