[monogame] Adjusted monogame code to spine-csharp 4.3 changes.

This commit is contained in:
Harald Csaszar 2025-06-30 18:14:35 +02:00
parent 37ae2ac476
commit 45eb76fed2
4 changed files with 108 additions and 180 deletions

View File

@ -95,7 +95,7 @@ namespace Spine {
state.Apply(skeleton); state.Apply(skeleton);
// Update the transformations of bones and other parts of the skeleton // Update the transformations of bones and other parts of the skeleton
skeleton.UpdateWorldTransform(Skeleton.Physics.Update); skeleton.UpdateWorldTransform(Physics.Update);
// Clear the screen and setup the projection matrix of the skeleton renderer // Clear the screen and setup the projection matrix of the skeleton renderer
game.GraphicsDevice.Clear(Color.Black); game.GraphicsDevice.Clear(Color.Black);
@ -148,7 +148,7 @@ namespace Spine {
skeleton.Update(deltaTime); skeleton.Update(deltaTime);
state.Apply(skeleton); state.Apply(skeleton);
skeleton.UpdateWorldTransform(Skeleton.Physics.Update); skeleton.UpdateWorldTransform(Physics.Update);
// Clear the screen and setup the projection matrix of the custom effect through the // Clear the screen and setup the projection matrix of the custom effect through the
// "Projection" parameter. // "Projection" parameter.
@ -193,7 +193,7 @@ namespace Spine {
// Set the "walk" animation on track one and let it loop forever // Set the "walk" animation on track one and let it loop forever
state.SetAnimation(0, "walk", true); state.SetAnimation(0, "walk", true);
// Queue another animation after 2 seconds to let Spineboy jump // Queue another animation after 2 seconds to let Spineboy jump
state.AddAnimation(0, "jump", false, 2); state.AddAnimation(0, "jump", false, 2);
@ -206,7 +206,7 @@ namespace Spine {
skeleton.Update(deltaTime); skeleton.Update(deltaTime);
state.Apply(skeleton); state.Apply(skeleton);
skeleton.UpdateWorldTransform(Skeleton.Physics.Update); skeleton.UpdateWorldTransform(Physics.Update);
game.GraphicsDevice.Clear(Color.Black); game.GraphicsDevice.Clear(Color.Black);
((BasicEffect)skeletonRenderer.Effect).Projection = Matrix.CreateOrthographicOffCenter(0, game.GraphicsDevice.Viewport.Width, game.GraphicsDevice.Viewport.Height, 0, 1, 0); ((BasicEffect)skeletonRenderer.Effect).Projection = Matrix.CreateOrthographicOffCenter(0, game.GraphicsDevice.Viewport.Width, game.GraphicsDevice.Viewport.Height, 0, 1, 0);
@ -267,7 +267,7 @@ namespace Spine {
skeleton.Update(deltaTime); skeleton.Update(deltaTime);
state.Apply(skeleton); state.Apply(skeleton);
skeleton.UpdateWorldTransform(Skeleton.Physics.Update); skeleton.UpdateWorldTransform(Physics.Update);
game.GraphicsDevice.Clear(Color.Black); game.GraphicsDevice.Clear(Color.Black);
((BasicEffect)skeletonRenderer.Effect).Projection = Matrix.CreateOrthographicOffCenter(0, game.GraphicsDevice.Viewport.Width, game.GraphicsDevice.Viewport.Height, 0, 1, 0); ((BasicEffect)skeletonRenderer.Effect).Projection = Matrix.CreateOrthographicOffCenter(0, game.GraphicsDevice.Viewport.Width, game.GraphicsDevice.Viewport.Height, 0, 1, 0);
@ -323,7 +323,7 @@ namespace Spine {
// lastPosition = currentPosition; // lastPosition = currentPosition;
state.Apply(skeleton); state.Apply(skeleton);
skeleton.UpdateWorldTransform(Skeleton.Physics.Update); skeleton.UpdateWorldTransform(Physics.Update);
game.GraphicsDevice.Clear(Color.Black); game.GraphicsDevice.Clear(Color.Black);
((BasicEffect)skeletonRenderer.Effect).Projection = Matrix.CreateOrthographicOffCenter(0, game.GraphicsDevice.Viewport.Width, game.GraphicsDevice.Viewport.Height, 0, 1, 0); ((BasicEffect)skeletonRenderer.Effect).Projection = Matrix.CreateOrthographicOffCenter(0, game.GraphicsDevice.Viewport.Width, game.GraphicsDevice.Viewport.Height, 0, 1, 0);
@ -380,7 +380,7 @@ namespace Spine {
// lastPosition = currentPosition; // lastPosition = currentPosition;
state.Apply(skeleton); state.Apply(skeleton);
skeleton.UpdateWorldTransform(Skeleton.Physics.Update); skeleton.UpdateWorldTransform(Physics.Update);
game.GraphicsDevice.Clear(Color.Black); game.GraphicsDevice.Clear(Color.Black);
((BasicEffect)skeletonRenderer.Effect).Projection = Matrix.CreateOrthographicOffCenter(0, game.GraphicsDevice.Viewport.Width, game.GraphicsDevice.Viewport.Height, 0, 1, 0); ((BasicEffect)skeletonRenderer.Effect).Projection = Matrix.CreateOrthographicOffCenter(0, game.GraphicsDevice.Viewport.Width, game.GraphicsDevice.Viewport.Height, 0, 1, 0);

View File

@ -18,147 +18,74 @@
<Folder Include="src\" /> <Folder Include="src\" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="..\..\spine-csharp\src\Animation.cs"> <!-- Core files -->
<Link>spine-csharp\Animation.cs</Link> <Compile Include="..\..\spine-csharp\src\Animation.cs"><Link>spine-csharp\Animation.cs</Link></Compile>
</Compile> <Compile Include="..\..\spine-csharp\src\AnimationState.cs"><Link>spine-csharp\AnimationState.cs</Link></Compile>
<Compile Include="..\..\spine-csharp\src\AnimationState.cs"> <Compile Include="..\..\spine-csharp\src\AnimationStateData.cs"><Link>spine-csharp\AnimationStateData.cs</Link></Compile>
<Link>spine-csharp\AnimationState.cs</Link> <Compile Include="..\..\spine-csharp\src\Atlas.cs"><Link>spine-csharp\Atlas.cs</Link></Compile>
</Compile> <Compile Include="..\..\spine-csharp\src\BlendMode.cs"><Link>spine-csharp\BlendMode.cs</Link></Compile>
<Compile Include="..\..\spine-csharp\src\AnimationStateData.cs"> <Compile Include="..\..\spine-csharp\src\Bone.cs"><Link>spine-csharp\Bone.cs</Link></Compile>
<Link>spine-csharp\AnimationStateData.cs</Link> <Compile Include="..\..\spine-csharp\src\BoneData.cs"><Link>spine-csharp\BoneData.cs</Link></Compile>
</Compile> <Compile Include="..\..\spine-csharp\src\BoneLocal.cs"><Link>spine-csharp\BoneLocal.cs</Link></Compile>
<Compile Include="..\..\spine-csharp\src\Atlas.cs"> <Compile Include="..\..\spine-csharp\src\BonePose.cs"><Link>spine-csharp\BonePose.cs</Link></Compile>
<Link>spine-csharp\Atlas.cs</Link> <Compile Include="..\..\spine-csharp\src\ColorMono.cs"><Link>spine-csharp\ColorMono.cs</Link></Compile>
</Compile> <Compile Include="..\..\spine-csharp\src\ColorUnity.cs"><Link>spine-csharp\ColorUnity.cs</Link></Compile>
<Compile Include="..\..\spine-csharp\src\BlendMode.cs"> <Compile Include="..\..\spine-csharp\src\Constraint.cs"><Link>spine-csharp\Constraint.cs</Link></Compile>
<Link>spine-csharp\BlendMode.cs</Link> <Compile Include="..\..\spine-csharp\src\ConstraintData.cs"><Link>spine-csharp\ConstraintData.cs</Link></Compile>
</Compile> <Compile Include="..\..\spine-csharp\src\Event.cs"><Link>spine-csharp\Event.cs</Link></Compile>
<Compile Include="..\..\spine-csharp\src\Bone.cs"> <Compile Include="..\..\spine-csharp\src\EventData.cs"><Link>spine-csharp\EventData.cs</Link></Compile>
<Link>spine-csharp\Bone.cs</Link> <Compile Include="..\..\spine-csharp\src\ExposedList.cs"><Link>spine-csharp\ExposedList.cs</Link></Compile>
</Compile> <Compile Include="..\..\spine-csharp\src\IkConstraint.cs"><Link>spine-csharp\IkConstraint.cs</Link></Compile>
<Compile Include="..\..\spine-csharp\src\BoneData.cs"> <Compile Include="..\..\spine-csharp\src\IkConstraintData.cs"><Link>spine-csharp\IkConstraintData.cs</Link></Compile>
<Link>spine-csharp\BoneData.cs</Link> <Compile Include="..\..\spine-csharp\src\IkConstraintPose.cs"><Link>spine-csharp\IkConstraintPose.cs</Link></Compile>
</Compile> <Compile Include="..\..\spine-csharp\src\IPose.cs"><Link>spine-csharp\IPose.cs</Link></Compile>
<Compile Include="..\..\spine-csharp\src\ConstraintData.cs"> <Compile Include="..\..\spine-csharp\src\IUpdate.cs"><Link>spine-csharp\IUpdate.cs</Link></Compile>
<Link>spine-csharp\ConstraintData.cs</Link> <Compile Include="..\..\spine-csharp\src\Json.cs"><Link>spine-csharp\Json.cs</Link></Compile>
</Compile> <Compile Include="..\..\spine-csharp\src\MathUtils.cs"><Link>spine-csharp\MathUtils.cs</Link></Compile>
<Compile Include="..\..\spine-csharp\src\Event.cs"> <Compile Include="..\..\spine-csharp\src\PathConstraint.cs"><Link>spine-csharp\PathConstraint.cs</Link></Compile>
<Link>spine-csharp\Event.cs</Link> <Compile Include="..\..\spine-csharp\src\PathConstraintData.cs"><Link>spine-csharp\PathConstraintData.cs</Link></Compile>
</Compile> <Compile Include="..\..\spine-csharp\src\PathConstraintPose.cs"><Link>spine-csharp\PathConstraintPose.cs</Link></Compile>
<Compile Include="..\..\spine-csharp\src\EventData.cs"> <Compile Include="..\..\spine-csharp\src\Physics.cs"><Link>spine-csharp\Physics.cs</Link></Compile>
<Link>spine-csharp\EventData.cs</Link> <Compile Include="..\..\spine-csharp\src\PhysicsConstraint.cs"><Link>spine-csharp\PhysicsConstraint.cs</Link></Compile>
</Compile> <Compile Include="..\..\spine-csharp\src\PhysicsConstraintData.cs"><Link>spine-csharp\PhysicsConstraintData.cs</Link></Compile>
<Compile Include="..\..\spine-csharp\src\ExposedList.cs"> <Compile Include="..\..\spine-csharp\src\PhysicsConstraintPose.cs"><Link>spine-csharp\PhysicsConstraintPose.cs</Link></Compile>
<Link>spine-csharp\ExposedList.cs</Link> <Compile Include="..\..\spine-csharp\src\Posed.cs"><Link>spine-csharp\Posed.cs</Link></Compile>
</Compile> <Compile Include="..\..\spine-csharp\src\PosedActive.cs"><Link>spine-csharp\PosedActive.cs</Link></Compile>
<Compile Include="..\..\spine-csharp\src\IkConstraint.cs"> <Compile Include="..\..\spine-csharp\src\PosedData.cs"><Link>spine-csharp\PosedData.cs</Link></Compile>
<Link>spine-csharp\IkConstraint.cs</Link> <Compile Include="..\..\spine-csharp\src\Skeleton.cs"><Link>spine-csharp\Skeleton.cs</Link></Compile>
</Compile> <Compile Include="..\..\spine-csharp\src\SkeletonBinary.cs"><Link>spine-csharp\SkeletonBinary.cs</Link></Compile>
<Compile Include="..\..\spine-csharp\src\IkConstraintData.cs"> <Compile Include="..\..\spine-csharp\src\SkeletonBounds.cs"><Link>spine-csharp\SkeletonBounds.cs</Link></Compile>
<Link>spine-csharp\IkConstraintData.cs</Link> <Compile Include="..\..\spine-csharp\src\SkeletonClipping.cs"><Link>spine-csharp\SkeletonClipping.cs</Link></Compile>
</Compile> <Compile Include="..\..\spine-csharp\src\SkeletonData.cs"><Link>spine-csharp\SkeletonData.cs</Link></Compile>
<Compile Include="..\..\spine-csharp\src\PhysicsConstraint.cs"> <Compile Include="..\..\spine-csharp\src\SkeletonJson.cs"><Link>spine-csharp\SkeletonJson.cs</Link></Compile>
<Link>spine-csharp\PhysicsConstraint.cs</Link> <Compile Include="..\..\spine-csharp\src\SkeletonLoader.cs"><Link>spine-csharp\SkeletonLoader.cs</Link></Compile>
</Compile> <Compile Include="..\..\spine-csharp\src\Skin.cs"><Link>spine-csharp\Skin.cs</Link></Compile>
<Compile Include="..\..\spine-csharp\src\PhysicsConstraintData.cs"> <Compile Include="..\..\spine-csharp\src\Slider.cs"><Link>spine-csharp\Slider.cs</Link></Compile>
<Link>spine-csharp\PhysicsConstraintData.cs</Link> <Compile Include="..\..\spine-csharp\src\SliderData.cs"><Link>spine-csharp\SliderData.cs</Link></Compile>
</Compile> <Compile Include="..\..\spine-csharp\src\SliderPose.cs"><Link>spine-csharp\SliderPose.cs</Link></Compile>
<Compile Include="..\..\spine-csharp\src\IUpdatable.cs"> <Compile Include="..\..\spine-csharp\src\Slot.cs"><Link>spine-csharp\Slot.cs</Link></Compile>
<Link>spine-csharp\IUpdatable.cs</Link> <Compile Include="..\..\spine-csharp\src\SlotData.cs"><Link>spine-csharp\SlotData.cs</Link></Compile>
</Compile> <Compile Include="..\..\spine-csharp\src\SlotPose.cs"><Link>spine-csharp\SlotPose.cs</Link></Compile>
<Compile Include="..\..\spine-csharp\src\Json.cs"> <Compile Include="..\..\spine-csharp\src\TextureRegion.cs"><Link>spine-csharp\TextureRegion.cs</Link></Compile>
<Link>spine-csharp\Json.cs</Link> <Compile Include="..\..\spine-csharp\src\TransformConstraint.cs"><Link>spine-csharp\TransformConstraint.cs</Link></Compile>
</Compile> <Compile Include="..\..\spine-csharp\src\TransformConstraintData.cs"><Link>spine-csharp\TransformConstraintData.cs</Link></Compile>
<Compile Include="..\..\spine-csharp\src\MathUtils.cs"> <Compile Include="..\..\spine-csharp\src\TransformConstraintPose.cs"><Link>spine-csharp\TransformConstraintPose.cs</Link></Compile>
<Link>spine-csharp\MathUtils.cs</Link> <Compile Include="..\..\spine-csharp\src\Triangulator.cs"><Link>spine-csharp\Triangulator.cs</Link></Compile>
</Compile>
<Compile Include="..\..\spine-csharp\src\PathConstraint.cs"> <!-- Attachments folder -->
<Link>spine-csharp\PathConstraint.cs</Link> <Compile Include="..\..\spine-csharp\src\Attachments\AtlasAttachmentLoader.cs"><Link>spine-csharp\Attachments\AtlasAttachmentLoader.cs</Link></Compile>
</Compile> <Compile Include="..\..\spine-csharp\src\Attachments\Attachment.cs"><Link>spine-csharp\Attachments\Attachment.cs</Link></Compile>
<Compile Include="..\..\spine-csharp\src\PathConstraintData.cs"> <Compile Include="..\..\spine-csharp\src\Attachments\AttachmentLoader.cs"><Link>spine-csharp\Attachments\AttachmentLoader.cs</Link></Compile>
<Link>spine-csharp\PathConstraintData.cs</Link> <Compile Include="..\..\spine-csharp\src\Attachments\AttachmentType.cs"><Link>spine-csharp\Attachments\AttachmentType.cs</Link></Compile>
</Compile> <Compile Include="..\..\spine-csharp\src\Attachments\BoundingBoxAttachment.cs"><Link>spine-csharp\Attachments\BoundingBoxAttachment.cs</Link></Compile>
<Compile Include="..\..\spine-csharp\src\Skeleton.cs"> <Compile Include="..\..\spine-csharp\src\Attachments\ClippingAttachment.cs"><Link>spine-csharp\Attachments\ClippingAttachment.cs</Link></Compile>
<Link>spine-csharp\Skeleton.cs</Link> <Compile Include="..\..\spine-csharp\src\Attachments\IHasTextureRegion.cs"><Link>spine-csharp\Attachments\IHasTextureRegion.cs</Link></Compile>
</Compile> <Compile Include="..\..\spine-csharp\src\Attachments\MeshAttachment.cs"><Link>spine-csharp\Attachments\MeshAttachment.cs</Link></Compile>
<Compile Include="..\..\spine-csharp\src\SkeletonBinary.cs"> <Compile Include="..\..\spine-csharp\src\Attachments\PathAttachment.cs"><Link>spine-csharp\Attachments\PathAttachment.cs</Link></Compile>
<Link>spine-csharp\SkeletonBinary.cs</Link> <Compile Include="..\..\spine-csharp\src\Attachments\PointAttachment.cs"><Link>spine-csharp\Attachments\PointAttachment.cs</Link></Compile>
</Compile> <Compile Include="..\..\spine-csharp\src\Attachments\RegionAttachment.cs"><Link>spine-csharp\Attachments\RegionAttachment.cs</Link></Compile>
<Compile Include="..\..\spine-csharp\src\SkeletonBounds.cs"> <Compile Include="..\..\spine-csharp\src\Attachments\Sequence.cs"><Link>spine-csharp\Attachments\Sequence.cs</Link></Compile>
<Link>spine-csharp\SkeletonBounds.cs</Link> <Compile Include="..\..\spine-csharp\src\Attachments\VertexAttachment.cs"><Link>spine-csharp\Attachments\VertexAttachment.cs</Link></Compile>
</Compile>
<Compile Include="..\..\spine-csharp\src\SkeletonClipping.cs">
<Link>spine-csharp\SkeletonClipping.cs</Link>
</Compile>
<Compile Include="..\..\spine-csharp\src\SkeletonData.cs">
<Link>spine-csharp\SkeletonData.cs</Link>
</Compile>
<Compile Include="..\..\spine-csharp\src\SkeletonJson.cs">
<Link>spine-csharp\SkeletonJson.cs</Link>
</Compile>
<Compile Include="..\..\spine-csharp\src\SkeletonLoader.cs">
<Link>spine-csharp\SkeletonLoader.cs</Link>
</Compile>
<Compile Include="..\..\spine-csharp\src\Skin.cs">
<Link>spine-csharp\Skin.cs</Link>
</Compile>
<Compile Include="..\..\spine-csharp\src\Slot.cs">
<Link>spine-csharp\Slot.cs</Link>
</Compile>
<Compile Include="..\..\spine-csharp\src\SlotData.cs">
<Link>spine-csharp\SlotData.cs</Link>
</Compile>
<Compile Include="..\..\spine-csharp\src\TextureRegion.cs">
<Link>spine-csharp\TextureRegion.cs</Link>
</Compile>
<Compile Include="..\..\spine-csharp\src\TransformConstraint.cs">
<Link>spine-csharp\TransformConstraint.cs</Link>
</Compile>
<Compile Include="..\..\spine-csharp\src\TransformConstraintData.cs">
<Link>spine-csharp\TransformConstraintData.cs</Link>
</Compile>
<Compile Include="..\..\spine-csharp\src\Triangulator.cs">
<Link>spine-csharp\Triangulator.cs</Link>
</Compile>
<Compile Include="..\..\spine-csharp\src\Attachments\AtlasAttachmentLoader.cs">
<Link>spine-csharp\Attachments\AtlasAttachmentLoader.cs</Link>
</Compile>
<Compile Include="..\..\spine-csharp\src\Attachments\Attachment.cs">
<Link>spine-csharp\Attachments\Attachment.cs</Link>
</Compile>
<Compile Include="..\..\spine-csharp\src\Attachments\AttachmentLoader.cs">
<Link>spine-csharp\Attachments\AttachmentLoader.cs</Link>
</Compile>
<Compile Include="..\..\spine-csharp\src\Attachments\AttachmentType.cs">
<Link>spine-csharp\Attachments\AttachmentType.cs</Link>
</Compile>
<Compile Include="..\..\spine-csharp\src\Attachments\BoundingBoxAttachment.cs">
<Link>spine-csharp\Attachments\BoundingBoxAttachment.cs</Link>
</Compile>
<Compile Include="..\..\spine-csharp\src\Attachments\ClippingAttachment.cs">
<Link>spine-csharp\Attachments\ClippingAttachment.cs</Link>
</Compile>
<Compile Include="..\..\spine-csharp\src\Attachments\IHasTextureRegion.cs">
<Link>spine-csharp\Attachments\IHasTextureRegion.cs</Link>
</Compile>
<Compile Include="..\..\spine-csharp\src\Attachments\MeshAttachment.cs">
<Link>spine-csharp\Attachments\MeshAttachment.cs</Link>
</Compile>
<Compile Include="..\..\spine-csharp\src\Attachments\PathAttachment.cs">
<Link>spine-csharp\Attachments\PathAttachment.cs</Link>
</Compile>
<Compile Include="..\..\spine-csharp\src\Attachments\PointAttachment.cs">
<Link>spine-csharp\Attachments\PointAttachment.cs</Link>
</Compile>
<Compile Include="..\..\spine-csharp\src\Attachments\RegionAttachment.cs">
<Link>spine-csharp\Attachments\RegionAttachment.cs</Link>
</Compile>
<Compile Include="..\..\spine-csharp\src\Attachments\Sequence.cs">
<Link>spine-csharp\Attachments\Sequence.cs</Link>
</Compile>
<Compile Include="..\..\spine-csharp\src\Attachments\VertexAttachment.cs">
<Link>spine-csharp\Attachments\VertexAttachment.cs</Link>
</Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\..\spine-csharp\src\Animation.cs.meta"> <None Include="..\..\spine-csharp\src\Animation.cs.meta">
@ -203,9 +130,6 @@
<None Include="..\..\spine-csharp\src\IkConstraintData.cs.meta"> <None Include="..\..\spine-csharp\src\IkConstraintData.cs.meta">
<Link>spine-csharp\IkConstraintData.cs.meta</Link> <Link>spine-csharp\IkConstraintData.cs.meta</Link>
</None> </None>
<None Include="..\..\spine-csharp\src\IUpdatable.cs.meta">
<Link>spine-csharp\IUpdatable.cs.meta</Link>
</None>
<None Include="..\..\spine-csharp\src\Json.cs.meta"> <None Include="..\..\spine-csharp\src\Json.cs.meta">
<Link>spine-csharp\Json.cs.meta</Link> <Link>spine-csharp\Json.cs.meta</Link>
</None> </None>

View File

@ -107,9 +107,10 @@ namespace Spine {
for (int i = 0, n = bones.Count; i < n; i++) { for (int i = 0, n = bones.Count; i < n; i++) {
var bone = bones.Items[i]; var bone = bones.Items[i];
if (bone.Parent == null) continue; if (bone.Parent == null) continue;
var x = bone.Data.Length * bone.A + bone.WorldX; BonePose bonePose = bone.AppliedPose;
var y = bone.Data.Length * bone.C + bone.WorldY; var x = bone.Data.Length * bonePose.A + bonePose.WorldX;
renderer.Line(bone.WorldX, bone.WorldY, x, y, z); var y = bone.Data.Length * bonePose.C + bonePose.WorldY;
renderer.Line(bonePose.WorldX, bonePose.WorldY, x, y, z);
} }
if (DrawSkeletonXY) renderer.X(skeletonX, skeletonY, 4, z); if (DrawSkeletonXY) renderer.X(skeletonX, skeletonY, 4, z);
} }
@ -119,7 +120,7 @@ namespace Spine {
var slots = skeleton.Slots; var slots = skeleton.Slots;
for (int i = 0, n = slots.Count; i < n; i++) { for (int i = 0, n = slots.Count; i < n; i++) {
var slot = slots.Items[i]; var slot = slots.Items[i];
var attachment = slot.Attachment; var attachment = slot.AppliedPose.Attachment;
if (attachment is RegionAttachment) { if (attachment is RegionAttachment) {
var regionAttachment = (RegionAttachment)attachment; var regionAttachment = (RegionAttachment)attachment;
var vertices = this.vertices; var vertices = this.vertices;
@ -136,11 +137,11 @@ namespace Spine {
var slots = skeleton.Slots; var slots = skeleton.Slots;
for (int i = 0, n = slots.Count; i < n; i++) { for (int i = 0, n = slots.Count; i < n; i++) {
var slot = slots.Items[i]; var slot = slots.Items[i];
var attachment = slot.Attachment; var attachment = slot.AppliedPose.Attachment;
if (!(attachment is MeshAttachment)) continue; if (!(attachment is MeshAttachment)) continue;
var mesh = (MeshAttachment)attachment; var mesh = (MeshAttachment)attachment;
var world = vertices = vertices.Length < mesh.WorldVerticesLength ? new float[mesh.WorldVerticesLength] : vertices; var world = vertices = vertices.Length < mesh.WorldVerticesLength ? new float[mesh.WorldVerticesLength] : vertices;
mesh.ComputeWorldVertices(slot, 0, mesh.WorldVerticesLength, world, 0, 2); mesh.ComputeWorldVertices(skeleton, slot, 0, mesh.WorldVerticesLength, world, 0, 2);
int[] triangles = mesh.Triangles; int[] triangles = mesh.Triangles;
var hullLength = mesh.HullLength; var hullLength = mesh.HullLength;
if (DrawMeshTriangles) { if (DrawMeshTriangles) {
@ -184,8 +185,9 @@ namespace Spine {
if (DrawBones) { if (DrawBones) {
renderer.SetColor(boneOriginColor); renderer.SetColor(boneOriginColor);
for (int i = 0, n = bones.Count; i < n; i++) { for (int i = 0, n = bones.Count; i < n; i++) {
var bone = bones.Items[i]; Bone bone = bones.Items[i];
renderer.Circle(bone.WorldX, bone.WorldY, 3, z); BonePose bonePose = bone.AppliedPose;
renderer.Circle(bonePose.WorldX, bonePose.WorldY, 3, z);
} }
} }
@ -194,12 +196,12 @@ namespace Spine {
renderer.SetColor(clipColor); renderer.SetColor(clipColor);
for (int i = 0, n = slots.Count; i < n; i++) { for (int i = 0, n = slots.Count; i < n; i++) {
var slot = slots.Items[i]; var slot = slots.Items[i];
var attachment = slot.Attachment; var attachment = slot.AppliedPose.Attachment;
if (!(attachment is ClippingAttachment)) continue; if (!(attachment is ClippingAttachment)) continue;
var clip = (ClippingAttachment)attachment; var clip = (ClippingAttachment)attachment;
var nn = clip.WorldVerticesLength; var nn = clip.WorldVerticesLength;
var world = vertices = vertices.Length < nn ? new float[nn] : vertices; var world = vertices = vertices.Length < nn ? new float[nn] : vertices;
clip.ComputeWorldVertices(slot, 0, nn, world, 0, 2); clip.ComputeWorldVertices(skeleton, slot, 0, nn, world, 0, 2);
ExposedList<float> clippingPolygon = new ExposedList<float>(); ExposedList<float> clippingPolygon = new ExposedList<float>();
for (int ii = 0; ii < nn; ii += 2) { for (int ii = 0; ii < nn; ii += 2) {
var x = world[ii]; var x = world[ii];

View File

@ -114,22 +114,24 @@ namespace Spine {
public void Draw (Skeleton skeleton) { public void Draw (Skeleton skeleton) {
var drawOrder = skeleton.DrawOrder; var drawOrder = skeleton.DrawOrder;
var drawOrderItems = skeleton.DrawOrder.Items; var drawOrderItems = skeleton.DrawOrder.Items;
float skeletonR = skeleton.R, skeletonG = skeleton.G, skeletonB = skeleton.B, skeletonA = skeleton.A; Color32F skeletonColor = skeleton.GetColor();
Color color = new Color();
if (VertexEffect != null) VertexEffect.Begin(skeleton); if (VertexEffect != null) VertexEffect.Begin(skeleton);
for (int i = 0, n = drawOrder.Count; i < n; i++) { for (int i = 0, n = drawOrder.Count; i < n; i++) {
Slot slot = drawOrderItems[i]; Slot slot = drawOrderItems[i];
SlotPose slotPose = slot.AppliedPose;
if (!slot.Bone.Active) { if (!slot.Bone.Active) {
clipper.ClipEnd(slot); clipper.ClipEnd(slot);
continue; continue;
} }
Attachment attachment = slot.Attachment; Attachment attachment = slotPose.Attachment;
float attachmentZOffset = z + zSpacing * i; float attachmentZOffset = z + zSpacing * i;
float attachmentColorR, attachmentColorG, attachmentColorB, attachmentColorA; Color32F attachmentColor;
Color32F slotColor = slotPose.GetColor();
Color color;
object textureObject = null; object textureObject = null;
int verticesCount = 0; int verticesCount = 0;
float[] vertices = this.vertices; float[] vertices = this.vertices;
@ -139,7 +141,7 @@ namespace Spine {
if (attachment is RegionAttachment) { if (attachment is RegionAttachment) {
RegionAttachment regionAttachment = (RegionAttachment)attachment; RegionAttachment regionAttachment = (RegionAttachment)attachment;
attachmentColorR = regionAttachment.R; attachmentColorG = regionAttachment.G; attachmentColorB = regionAttachment.B; attachmentColorA = regionAttachment.A; attachmentColor = regionAttachment.GetColor();
regionAttachment.ComputeWorldVertices(slot, vertices, 0, 2); regionAttachment.ComputeWorldVertices(slot, vertices, 0, 2);
verticesCount = 4; verticesCount = 4;
indicesCount = 6; indicesCount = 6;
@ -149,11 +151,11 @@ namespace Spine {
textureObject = region.page.rendererObject; textureObject = region.page.rendererObject;
} else if (attachment is MeshAttachment) { } else if (attachment is MeshAttachment) {
MeshAttachment mesh = (MeshAttachment)attachment; MeshAttachment mesh = (MeshAttachment)attachment;
attachmentColorR = mesh.R; attachmentColorG = mesh.G; attachmentColorB = mesh.B; attachmentColorA = mesh.A; attachmentColor = mesh.GetColor();
int vertexCount = mesh.WorldVerticesLength; int vertexCount = mesh.WorldVerticesLength;
if (vertices.Length < vertexCount) this.vertices = vertices = new float[vertexCount]; if (vertices.Length < vertexCount) this.vertices = vertices = new float[vertexCount];
verticesCount = vertexCount >> 1; verticesCount = vertexCount >> 1;
mesh.ComputeWorldVertices(slot, vertices); mesh.ComputeWorldVertices(skeleton, slot, vertices);
indicesCount = mesh.Triangles.Length; indicesCount = mesh.Triangles.Length;
indices = mesh.Triangles; indices = mesh.Triangles;
uvs = mesh.UVs; uvs = mesh.UVs;
@ -161,7 +163,7 @@ namespace Spine {
textureObject = region.page.rendererObject; textureObject = region.page.rendererObject;
} else if (attachment is ClippingAttachment) { } else if (attachment is ClippingAttachment) {
ClippingAttachment clip = (ClippingAttachment)attachment; ClippingAttachment clip = (ClippingAttachment)attachment;
clipper.ClipStart(slot, clip); clipper.ClipStart(skeleton, slot, clip);
continue; continue;
} else { } else {
clipper.ClipEnd(slot); clipper.ClipEnd(slot);
@ -187,25 +189,25 @@ namespace Spine {
} }
// calculate color // calculate color
float a = skeletonA * slot.A * attachmentColorA; Color32F combinedColor = skeletonColor * slotColor * attachmentColor;
float a = combinedColor.a;
if (premultipliedAlpha) { if (premultipliedAlpha) {
color = new Color( color = new Color(
skeletonR * slot.R * attachmentColorR * a, combinedColor.r * a,
skeletonG * slot.G * attachmentColorG * a, combinedColor.g * a,
skeletonB * slot.B * attachmentColorB * a, a); combinedColor.b * a, a);
} else { } else {
color = new Color( color = combinedColor;
skeletonR * slot.R * attachmentColorR,
skeletonG * slot.G * attachmentColorG,
skeletonB * slot.B * attachmentColorB, a);
} }
Color darkColor = new Color(); Color darkColor = new Color();
if (slot.HasSecondColor) { Color32F? slotDarkColorOptional = slotPose.GetDarkColor();
if (slotDarkColorOptional.HasValue) {
Color32F slotDarkColor = slotDarkColorOptional.Value;
if (premultipliedAlpha) { if (premultipliedAlpha) {
darkColor = new Color(slot.R2 * a, slot.G2 * a, slot.B2 * a); darkColor = new Color(slotDarkColor.r * a, slotDarkColor.g * a, slotDarkColor.b * a);
} else { } else {
darkColor = new Color(slot.R2 * a, slot.G2 * a, slot.B2 * a); darkColor = new Color(slotDarkColor.r * a, slotDarkColor.g * a, slotDarkColor.b * a);
} }
} }
darkColor.A = premultipliedAlpha ? (byte)255 : (byte)0; darkColor.A = premultipliedAlpha ? (byte)255 : (byte)0;