[csharp] Changed interface hierarchy of Posed to hide internal methods from the API.

This commit is contained in:
Harald Csaszar 2025-06-25 16:13:44 +02:00
parent 6b978fcdf4
commit d2f0ace521
4 changed files with 18 additions and 16 deletions

View File

@ -30,8 +30,7 @@
using System;
namespace Spine {
public interface IPosed {
internal interface IPosedInternal {
// replaces "object.pose == object.applied" of reference implementation.
bool PoseEqualsApplied { get; }
// replaces "object.applied = object.pose" of reference implementation.
@ -40,10 +39,13 @@ namespace Spine {
void UseConstrained ();
// replaces "object.applied.Set(object.pose)" of reference implementation.
void ResetConstrained ();
}
public interface IPosed {
void SetupPose ();
}
public class Posed<D, P, A> : IPosed
public class Posed<D, P, A> : IPosed, IPosedInternal
where D : PosedData<P>
where P : IPose<P>
where A : P {
@ -65,19 +67,19 @@ namespace Spine {
pose.Set(data.setup);
}
public bool PoseEqualsApplied {
bool IPosedInternal.PoseEqualsApplied {
get { return (object)pose == (object)applied; }
}
public void UsePose () {
void IPosedInternal.UsePose () {
applied = pose;
}
public void UseConstrained () {
void IPosedInternal.UseConstrained () {
applied = constrained;
}
public void ResetConstrained () {
void IPosedInternal.ResetConstrained () {
applied.Set(pose);
}

View File

@ -46,7 +46,7 @@ namespace Spine {
internal ExposedList<IConstraint> constraints;
internal ExposedList<PhysicsConstraint> physics;
internal ExposedList<object> updateCache = new ExposedList<object>();
internal ExposedList<IPosed> resetCache = new ExposedList<IPosed>(16);
internal ExposedList<IPosedInternal> resetCache = new ExposedList<IPosedInternal>(16);
internal Skin skin;
// Color is a struct, set to protected to prevent
// Color color = slot.color; color.a = 0.5;
@ -156,7 +156,7 @@ namespace Spine {
Slot[] slots = this.slots.Items;
for (int i = 0, n = this.slots.Count; i < n; i++) {
slots[i].UsePose();
((IPosedInternal)slots[i]).UsePose();
}
int boneCount = this.bones.Count;
@ -165,7 +165,7 @@ namespace Spine {
Bone bone = bones[i];
bone.sorted = bone.data.skinRequired;
bone.active = !bone.sorted;
bone.UsePose();
((IPosedInternal)bone).UsePose();
}
if (skin != null) {
BoneData[] skinBones = skin.bones.Items;
@ -183,7 +183,7 @@ namespace Spine {
{ // scope added to prevent compile error of n already being declared in enclosing scope
int n = this.constraints.Count;
for (int i = 0; i < n; i++) {
constraints[i].UsePose();
((IPosedInternal)constraints[i]).UsePose();
}
for (int i = 0; i < n; i++) {
IConstraint constraint = constraints[i];
@ -204,7 +204,7 @@ namespace Spine {
}
}
internal void Constrained (IPosed obj) {
internal void Constrained (IPosedInternal obj) {
if (obj.PoseEqualsApplied) { // if (obj.pose == obj.applied) {
obj.UseConstrained();
resetCache.Add(obj);
@ -239,7 +239,7 @@ namespace Spine {
public void UpdateWorldTransform (Physics physics) {
update++;
IPosed[] resetCache = this.resetCache.Items;
IPosedInternal[] resetCache = this.resetCache.Items;
for (int i = 0, n = this.resetCache.Count; i < n; i++) {
resetCache[i].ResetConstrained();
}

View File

@ -102,10 +102,10 @@ namespace Spine {
for (int ii = 0; ii < physicsCount; ii++)
skeleton.Constrained(physics[ii]);
} else
skeleton.Constrained(constraints[timeline.constraintIndex]);
skeleton.Constrained((IPosedInternal)constraints[timeline.constraintIndex]);
} else if (t as IConstraintTimeline != null) {
IConstraintTimeline timeline = (IConstraintTimeline)t;
skeleton.Constrained(constraints[timeline.ConstraintIndex]);
skeleton.Constrained((IPosedInternal)constraints[timeline.ConstraintIndex]);
}
}
}

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.3.3",
"version": "4.3.4",
"unity": "2018.3",
"author": {
"name": "Esoteric Software",