[csharp] Port of commit 2563c7c. Added physics methods to apply translation and rotation forces.

This commit is contained in:
Harald Csaszar 2024-01-18 18:39:54 +01:00
parent 2563c7cbce
commit b5d1aea3c5
3 changed files with 41 additions and 1 deletions

View File

@ -110,6 +110,28 @@ namespace Spine {
mix = data.mix;
}
/// <summary>
/// Translates the physics constraint so next <see cref="Update(Physics)"/> forces are applied as if the bone moved an additional
/// amount in world space.
/// </summary>
public void Translate (float x, float y) {
ux -= x;
uy -= y;
cx -= x;
cy -= y;
}
/// <summary>
/// Rotates the physics constraint so next <see cref="Update(Physics)"/> forces are applied as if the bone rotated an additional
/// amount in world space.
/// </summary>
public void Rotate (float degrees) {
float r = degrees * MathUtils.DegRad, cos = (float)Math.Cos(r), sin = (float)Math.Sin(r);
r = tx * cos - ty * sin;
ty = tx * sin + ty * cos;
tx = r;
}
/// <summary>Applies the constraint to the constrained bones.</summary>
public void Update (Physics physics) {
float mix = this.mix;

View File

@ -474,6 +474,24 @@ namespace Spine {
}
}
/// <summary>
/// Calls <see cref="PhysicsConstraint.Translate(float, float)"/> for each physics constraint.
/// </summary>
public void PhysicsTranslate (float x, float y) {
PhysicsConstraint[] physicsConstraints = this.physicsConstraints.Items;
for (int i = 0, n = this.physicsConstraints.Count; i < n; i++)
physicsConstraints[i].Translate(x, y);
}
/// <summary>
/// Calls <see cref="PhysicsConstraint.Rotate(float)"/> for each physics constraint.
/// </summary>
public void PhysicsRotate (float degrees) {
PhysicsConstraint[] physicsConstraints = this.physicsConstraints.Items;
for (int i = 0, n = this.physicsConstraints.Count; i < n; i++)
physicsConstraints[i].Rotate(degrees);
}
/// <summary>Increments the skeleton's <see cref="time"/>.</summary>
public void Update (float delta) {
time += delta;

View File

@ -2,7 +2,7 @@
"name": "com.esotericsoftware.spine.spine-csharp",
"displayName": "spine-csharp Runtime",
"description": "This plugin provides the spine-csharp core runtime.",
"version": "4.2.9",
"version": "4.2.10",
"unity": "2018.3",
"author": {
"name": "Esoteric Software",