[csharp] Port of commit e177661. Improved physic constraint rotate().

This commit is contained in:
Harald Csaszar 2024-01-22 17:59:33 +01:00
parent 900e92ba46
commit 05e37fc738
3 changed files with 9 additions and 10 deletions

View File

@ -122,14 +122,13 @@ namespace Spine {
} }
/// <summary> /// <summary>
/// Rotates the physics constraint so next <see cref="Update(Physics)"/> forces are applied as if the bone rotated an additional /// Rotates the physics constraint so next <see cref="Update(Physics)"/> forces are applied as if the bone rotated around the
/// amount in world space. /// specified point in world space.
/// </summary> /// </summary>
public void Rotate (float degrees) { public void Rotate (float x, float y, float degrees) {
float r = degrees * MathUtils.DegRad, cos = (float)Math.Cos(r), sin = (float)Math.Sin(r); float r = degrees * MathUtils.DegRad, cos = (float)Math.Cos(r), sin = (float)Math.Sin(r);
r = tx * cos - ty * sin; float dx = cx - x, dy = cy - y;
ty = tx * sin + ty * cos; Translate(dx * cos - dy * sin - dx, dx * sin + dy * cos - dy);
tx = r;
} }
/// <summary>Applies the constraint to the constrained bones.</summary> /// <summary>Applies the constraint to the constrained bones.</summary>

View File

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

View File

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