From 05e37fc738492b034fc76edc4b8e3c69a4b4e0ca Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Mon, 22 Jan 2024 17:59:33 +0100 Subject: [PATCH] [csharp] Port of commit e177661. Improved physic constraint rotate(). --- spine-csharp/src/PhysicsConstraint.cs | 11 +++++------ spine-csharp/src/Skeleton.cs | 6 +++--- spine-csharp/src/package.json | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/spine-csharp/src/PhysicsConstraint.cs b/spine-csharp/src/PhysicsConstraint.cs index 7419b5a1a..646c79c87 100644 --- a/spine-csharp/src/PhysicsConstraint.cs +++ b/spine-csharp/src/PhysicsConstraint.cs @@ -122,14 +122,13 @@ namespace Spine { } /// - /// Rotates the physics constraint so next forces are applied as if the bone rotated an additional - /// amount in world space. + /// Rotates the physics constraint so next forces are applied as if the bone rotated around the + /// specified point in world space. /// - 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); - r = tx * cos - ty * sin; - ty = tx * sin + ty * cos; - tx = r; + float dx = cx - x, dy = cy - y; + Translate(dx * cos - dy * sin - dx, dx * sin + dy * cos - dy); } /// Applies the constraint to the constrained bones. diff --git a/spine-csharp/src/Skeleton.cs b/spine-csharp/src/Skeleton.cs index 3a84e6ca2..508e18e17 100644 --- a/spine-csharp/src/Skeleton.cs +++ b/spine-csharp/src/Skeleton.cs @@ -484,12 +484,12 @@ namespace Spine { } /// - /// Calls for each physics constraint. + /// Calls for each physics constraint. /// - public void PhysicsRotate (float degrees) { + public void PhysicsRotate (float x, float y, float degrees) { PhysicsConstraint[] physicsConstraints = this.physicsConstraints.Items; for (int i = 0, n = this.physicsConstraints.Count; i < n; i++) - physicsConstraints[i].Rotate(degrees); + physicsConstraints[i].Rotate(r, y, degrees); } /// Increments the skeleton's . diff --git a/spine-csharp/src/package.json b/spine-csharp/src/package.json index 37e4cba16..4d6a2d968 100644 --- a/spine-csharp/src/package.json +++ b/spine-csharp/src/package.json @@ -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.10", + "version": "4.2.11", "unity": "2018.3", "author": { "name": "Esoteric Software",