[unity] Minor cleanup of MeshGenerator.

This commit is contained in:
pharan 2018-10-17 22:08:04 +08:00
parent 7d2647baff
commit 339a76c75e

View File

@ -245,8 +245,8 @@ namespace Spine.Unity {
} }
public static void GenerateSkeletonRendererInstruction (SkeletonRendererInstruction instructionOutput, Skeleton skeleton, Dictionary<Slot, Material> customSlotMaterials, List<Slot> separatorSlots, bool generateMeshOverride, bool immutableTriangles = false) { public static void GenerateSkeletonRendererInstruction (SkeletonRendererInstruction instructionOutput, Skeleton skeleton, Dictionary<Slot, Material> customSlotMaterials, List<Slot> separatorSlots, bool generateMeshOverride, bool immutableTriangles = false) {
// if (skeleton == null) throw new ArgumentNullException("skeleton"); // if (skeleton == null) throw new ArgumentNullException("skeleton");
// if (instructionOutput == null) throw new ArgumentNullException("instructionOutput"); // if (instructionOutput == null) throw new ArgumentNullException("instructionOutput");
ExposedList<Slot> drawOrder = skeleton.drawOrder; ExposedList<Slot> drawOrder = skeleton.drawOrder;
int drawOrderCount = drawOrder.Count; int drawOrderCount = drawOrder.Count;
@ -308,10 +308,10 @@ namespace Spine.Unity {
#if SPINE_TRIANGLECHECK #if SPINE_TRIANGLECHECK
var clippingAttachment = attachment as ClippingAttachment; var clippingAttachment = attachment as ClippingAttachment;
if (clippingAttachment != null) { if (clippingAttachment != null) {
clippingEndSlot = clippingAttachment.endSlot; clippingEndSlot = clippingAttachment.endSlot;
clippingAttachmentSource = i; clippingAttachmentSource = i;
current.hasClipping = true; current.hasClipping = true;
skeletonHasClipping = true; skeletonHasClipping = true;
} }
#endif #endif
noRender = true; noRender = true;
@ -682,8 +682,8 @@ namespace Spine.Unity {
int vertexIndex = 0; int vertexIndex = 0;
var tempVerts = this.tempVerts; var tempVerts = this.tempVerts;
Vector2 bmin = this.meshBoundsMin; Vector3 bmin = this.meshBoundsMin;
Vector2 bmax = this.meshBoundsMax; Vector3 bmax = this.meshBoundsMax;
var vbi = vertexBuffer.Items; var vbi = vertexBuffer.Items;
var ubi = uvBuffer.Items; var ubi = uvBuffer.Items;
@ -990,11 +990,10 @@ namespace Spine.Unity {
mesh.bounds = new Bounds(); mesh.bounds = new Bounds();
} else { } else {
//mesh.bounds = ArraysMeshGenerator.ToBounds(meshBoundsMin, meshBoundsMax); //mesh.bounds = ArraysMeshGenerator.ToBounds(meshBoundsMin, meshBoundsMax);
float halfWidth = (meshBoundsMax.x - meshBoundsMin.x) * 0.5f; Vector2 halfSize = (meshBoundsMax - meshBoundsMin) * 0.5f;
float halfHeight = (meshBoundsMax.y - meshBoundsMin.y) * 0.5f;
mesh.bounds = new Bounds { mesh.bounds = new Bounds {
center = new Vector3(meshBoundsMin.x + halfWidth, meshBoundsMin.y + halfHeight), center = (Vector3)(meshBoundsMin + halfSize),
extents = new Vector3(halfWidth, halfHeight, meshBoundsThickness * 0.5f) extents = new Vector3(halfSize.x, halfSize.y, meshBoundsThickness * 0.5f)
}; };
} }
} }