public void CalculateWeights(IWeightsGenerator weightsGenerator, ISelection <int> selection, float filterTolerance) { Debug.Assert(spriteMeshData != null); Vector2[] controlPoints; Edge[] bones; int[] pins; GetControlPoints(out controlPoints, out bones, out pins); Vector2[] vertices = new Vector2[spriteMeshData.vertexCount]; for (int i = 0; i < spriteMeshData.vertexCount; ++i) { vertices[i] = spriteMeshData.GetPosition(i); } BoneWeight[] boneWeights = weightsGenerator.Calculate(spriteMeshData.spriteName, vertices, spriteMeshData.indices.ToArray(), spriteMeshData.edges.ToArray(), controlPoints, bones, pins); Debug.Assert(boneWeights.Length == spriteMeshData.vertexCount); for (int i = 0; i < spriteMeshData.vertexCount; ++i) { if (selection == null || (selection.Count == 0 || selection.Contains(i))) { EditableBoneWeight editableBoneWeight = EditableBoneWeightUtility.CreateFromBoneWeight(boneWeights[i]); if (filterTolerance > 0f) { editableBoneWeight.FilterChannels(filterTolerance); editableBoneWeight.Normalize(); } spriteMeshData.SetWeight(i, editableBoneWeight); } } }
public Vertex2D(Vector2 position, BoneWeight weights) { m_Position = position; m_EditableBoneWeight = EditableBoneWeightUtility.CreateFromBoneWeight(weights); }
public Vertex2D(Vector2 position) { m_Position = position; m_EditableBoneWeight = EditableBoneWeightUtility.CreateFromBoneWeight(new BoneWeight()); }