[unity] Allow empty slots as separators.

This commit is contained in:
pharan 2017-05-11 01:39:21 +08:00
parent 8e138b56e0
commit 015ade60ea
2 changed files with 17 additions and 9 deletions

View File

@ -38,7 +38,6 @@ using System.Collections.Generic;
namespace Spine.Unity {
public static class SpineMesh {
internal const HideFlags MeshHideflags = HideFlags.DontSaveInBuild | HideFlags.DontSaveInEditor;
/// <summary>Factory method for creating a new mesh for use in Spine components. This can be called in field initializers.</summary>
@ -132,6 +131,8 @@ namespace Spine.Unity {
[NonSerialized] ExposedList<Vector2> uv3;
#endregion
public int VertexCount { get { return vertexBuffer.Count; } }
#region Step 1 : Generate Instructions
public static void GenerateSingleSubmeshInstruction (SkeletonRendererInstruction instructionOutput, Skeleton skeleton, Material material) {
ExposedList<Slot> drawOrder = skeleton.drawOrder;
@ -295,7 +296,7 @@ namespace Spine.Unity {
}
if (noRender) {
if (current.forceSeparate && current.rawVertexCount > 0 && generateMeshOverride) {
if (current.forceSeparate && generateMeshOverride && current.rawVertexCount > 0) {
{ // Add
current.endSlot = i;
current.preActiveClippingSlotSource = lastPreActiveClipping;
@ -305,6 +306,7 @@ namespace Spine.Unity {
submeshIndex++;
}
current.startSlot = i;
lastPreActiveClipping = clippingAttachmentSource;
#if SPINE_TRIANGLECHECK
@ -327,7 +329,7 @@ namespace Spine.Unity {
Material material = (rendererObject.GetType() == typeof(Material)) ? (Material)rendererObject : (Material)((AtlasRegion)rendererObject).page.rendererObject;
#endif
if (current.rawVertexCount > 0 && (current.forceSeparate || !System.Object.ReferenceEquals(current.material, material))) { // Material changed. Add the previous submesh.
if (current.forceSeparate || (current.rawVertexCount > 0 && !System.Object.ReferenceEquals(current.material, material))) { // Material changed. Add the previous submesh.
{ // Add
current.endSlot = i;
current.preActiveClippingSlotSource = lastPreActiveClipping;

View File

@ -104,6 +104,11 @@ namespace Spine.Unity.Modules {
// STEP 3: modify mesh.
var mesh = smartMesh.mesh;
if (meshGenerator.VertexCount <= 0) { // Clear an empty mesh
updateTriangles = false;
mesh.Clear();
} else {
meshGenerator.FillVertexData(mesh);
if (updateTriangles) {
meshGenerator.FillTriangles(mesh);
@ -111,6 +116,7 @@ namespace Spine.Unity.Modules {
} else if (buffers.MaterialsChangedInLastUpdate()) {
meshRenderer.sharedMaterials = buffers.GetUpdatedShaderdMaterialsArray();
}
}
meshFilter.sharedMesh = mesh;
smartMesh.instructionUsed.Set(currentInstructions);