[unity] Made UpdateWorldTransform mode configurable at all ISkeletonAnimation components. Fixed SkeletonRootMotionBase physics update mode.

This commit is contained in:
Harald Csaszar 2023-11-29 18:09:18 +01:00
parent fd0c20a2c7
commit 2a31b4d9b1
7 changed files with 56 additions and 17 deletions

View File

@ -213,7 +213,7 @@ namespace Spine.Unity {
Vector2 parentBoneScale;
GetScaleAffectingRootMotion(out parentBoneScale);
ClearEffectiveBoneOffsets(parentBoneScale);
skeletonComponent.Skeleton.UpdateWorldTransform(Skeleton.Physics.Update);
skeletonComponent.Skeleton.UpdateWorldTransform(Skeleton.Physics.Pose);
}
ClearRigidbodyTempMovement();

View File

@ -83,10 +83,15 @@ namespace Spine.Unity {
/// </summary>
public event UpdateBonesDelegate UpdateLocal { add { _UpdateLocal += value; } remove { _UpdateLocal -= value; } }
/// <summary>
/// <summary><para>
/// Occurs after the Skeleton's bone world space values are resolved (including all constraints).
/// Using this callback will cause the world space values to be solved an extra time.
/// Use this callback if want to use bone world space values, and also set bone local values.</summary>
/// Use this callback if want to use bone world space values, and also set bone local values.
/// </para><para>
/// When used in combination with PhysicsConstraints at your skeleton, you might want to consider adjusting
/// <see cref="MainPhysicsUpdate"/> and <see cref="AdditionalPhysicsUpdate"/> to save updates by setting one to
/// <see cref="Skeleton.Physics.Pose"/>.
/// </para></summary>
public event UpdateBonesDelegate UpdateWorld { add { _UpdateWorld += value; } remove { _UpdateWorld -= value; } }
/// <summary>
@ -104,6 +109,15 @@ namespace Spine.Unity {
/// Instance SkeletonAnimation.timeScale will still be applied.</summary>
[SerializeField] protected bool unscaledTime;
public bool UnscaledTime { get { return unscaledTime; } set { unscaledTime = value; } }
protected Skeleton.Physics mainPhysicsUpdate = Skeleton.Physics.Update;
protected Skeleton.Physics additionalPhysicsUpdate = Skeleton.Physics.Update;
/// <summary>Physics update mode used in the main call to skeleton.UpdateWorldTransform().</summary>
public Skeleton.Physics MainPhysicsUpdate { get { return mainPhysicsUpdate; } set { mainPhysicsUpdate = value; } }
/// <summary>Physics update mode used at optional additional calls to skeleton.UpdateWorldTransform(),
/// such as after the <see cref="UpdateWorld"/> callback if a method is subscribed at the UpdateWorld delegate.
/// </summary>
public Skeleton.Physics AdditionalPhysicsUpdate { get { return additionalPhysicsUpdate; } set { additionalPhysicsUpdate = value; } }
#endregion
#region Serialized state and Beginner API
@ -264,11 +278,11 @@ namespace Spine.Unity {
if (_UpdateLocal != null)
_UpdateLocal(this);
UpdateWorldTransform();
UpdateWorldTransform(mainPhysicsUpdate);
if (_UpdateWorld != null) {
_UpdateWorld(this);
UpdateWorldTransform();
UpdateWorldTransform(additionalPhysicsUpdate);
}
if (_UpdateComplete != null) {

View File

@ -403,19 +403,19 @@ namespace Spine.Unity {
if (UpdateLocal != null)
UpdateLocal(this);
UpdateWorldTransform();
UpdateWorldTransform(mainPhysicsUpdate);
if (UpdateWorld != null) {
UpdateWorld(this);
UpdateWorldTransform();
UpdateWorldTransform(additionalPhysicsUpdate);
}
if (UpdateComplete != null)
UpdateComplete(this);
}
protected void UpdateWorldTransform () {
skeleton.UpdateWorldTransform(Skeleton.Physics.Update);
protected void UpdateWorldTransform (Skeleton.Physics physics) {
skeleton.UpdateWorldTransform(physics);
}
public void LateUpdate () {
@ -644,6 +644,15 @@ namespace Spine.Unity {
[SerializeField] protected bool unscaledTime;
public bool UnscaledTime { get { return unscaledTime; } set { unscaledTime = value; } }
protected Skeleton.Physics mainPhysicsUpdate = Skeleton.Physics.Update;
protected Skeleton.Physics additionalPhysicsUpdate = Skeleton.Physics.Update;
/// <summary>Physics update mode used in the main call to skeleton.UpdateWorldTransform().</summary>
public Skeleton.Physics MainPhysicsUpdate { get { return mainPhysicsUpdate; } set { mainPhysicsUpdate = value; } }
/// <summary>Physics update mode used at optional additional calls to skeleton.UpdateWorldTransform(),
/// such as after the <see cref="UpdateWorld"/> callback if a method is subscribed at the UpdateWorld delegate.
/// </summary>
public Skeleton.Physics AdditionalPhysicsUpdate { get { return additionalPhysicsUpdate; } set { additionalPhysicsUpdate = value; } }
/// <summary> Occurs after the vertex data populated every frame, before the vertices are pushed into the mesh.</summary>
public event Spine.Unity.MeshGeneratorDelegate OnPostProcessVertices;

View File

@ -63,10 +63,15 @@ namespace Spine.Unity {
/// Use this callback when you want to set bone local values.</summary>
public event UpdateBonesDelegate UpdateLocal { add { _UpdateLocal += value; } remove { _UpdateLocal -= value; } }
/// <summary>
/// <summary><para>
/// Occurs after the Skeleton's bone world space values are resolved (including all constraints).
/// Using this callback will cause the world space values to be solved an extra time.
/// Use this callback if want to use bone world space values, and also set bone local values.</summary>
/// Use this callback if want to use bone world space values, and also set bone local values.
/// </para><para>
/// When used in combination with PhysicsConstraints at your skeleton, you might want to consider adjusting
/// <see cref="MainPhysicsUpdate"/> and <see cref="AdditionalPhysicsUpdate"/> to save updates by setting one to
/// <see cref="Skeleton.Physics.Pose"/>.
/// </para></summary>
public event UpdateBonesDelegate UpdateWorld { add { _UpdateWorld += value; } remove { _UpdateWorld -= value; } }
/// <summary>
@ -77,6 +82,15 @@ namespace Spine.Unity {
[SerializeField] protected UpdateTiming updateTiming = UpdateTiming.InUpdate;
public UpdateTiming UpdateTiming { get { return updateTiming; } set { updateTiming = value; } }
protected Skeleton.Physics mainPhysicsUpdate = Skeleton.Physics.Update;
protected Skeleton.Physics additionalPhysicsUpdate = Skeleton.Physics.Update;
/// <summary>Physics update mode used in the main call to skeleton.UpdateWorldTransform().</summary>
public Skeleton.Physics MainPhysicsUpdate { get { return mainPhysicsUpdate; } set { mainPhysicsUpdate = value; } }
/// <summary>Physics update mode used at optional additional calls to skeleton.UpdateWorldTransform(),
/// such as after the <see cref="UpdateWorld"/> callback if a method is subscribed at the UpdateWorld delegate.
/// </summary>
public Skeleton.Physics AdditionalPhysicsUpdate { get { return additionalPhysicsUpdate; } set { additionalPhysicsUpdate = value; } }
#endregion
public override void Initialize (bool overwrite, bool quiet = false) {
@ -156,11 +170,11 @@ namespace Spine.Unity {
if (_UpdateLocal != null)
_UpdateLocal(this);
UpdateWorldTransform();
UpdateWorldTransform(mainPhysicsUpdate);
if (_UpdateWorld != null) {
_UpdateWorld(this);
UpdateWorldTransform();
UpdateWorldTransform(additionalPhysicsUpdate);
}
if (_UpdateComplete != null)

View File

@ -423,7 +423,7 @@ namespace Spine.Unity {
// Generate mesh once, required to update mesh bounds for visibility
UpdateMode updateModeSaved = updateMode;
updateMode = UpdateMode.FullUpdate;
UpdateWorldTransform();
UpdateWorldTransform(Skeleton.Physics.Update);
LateUpdate();
updateMode = updateModeSaved;
@ -439,8 +439,8 @@ namespace Spine.Unity {
#endif
}
protected virtual void UpdateWorldTransform () {
skeleton.UpdateWorldTransform(Skeleton.Physics.Update);
protected virtual void UpdateWorldTransform (Skeleton.Physics physics) {
skeleton.UpdateWorldTransform(physics);
}
/// <summary>

View File

@ -63,6 +63,8 @@ namespace Spine.Unity {
event UpdateBonesDelegate UpdateComplete;
Skeleton Skeleton { get; }
UpdateTiming UpdateTiming { get; set; }
Skeleton.Physics MainPhysicsUpdate { get; set; }
Skeleton.Physics AdditionalPhysicsUpdate { get; set; }
}
/// <summary>Holds a reference to a SkeletonDataAsset.</summary>

View File

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