private Vector3[] Deform(Slice[] slices, Mesh mesh, MeshDeformer deformer, bool isRigid) { Vector3[] vertices = mesh.vertices; for (int s = 0; s < slices.Length; ++s) { Slice slice = slices[s]; Vector3 center = deformer.GetPoint(slice.T, slice.CurveIndex); center = deformer.transform.InverseTransformPoint(center); Vector3 dir = deformer.transform.InverseTransformVector(deformer.GetDirection(slice.T, slice.CurveIndex)); float t = slice.T; if (isRigid) { t = 1.0f; } if (dir == Vector3.zero) { continue; } float twistAngle = deformer.GetTwist(t, slice.CurveIndex); Vector3 thickness = deformer.GetThickness(t, slice.CurveIndex); float wrapCurvature = deformer.GetWrap(t, slice.CurveIndex); Quaternion rotation = Quaternion.AngleAxis(twistAngle, dir) * Quaternion.LookRotation(dir, m_up) * m_axisRotation; Matrix4x4 matrix = Matrix4x4.TRS(center, rotation, Vector3.one); int[] indices = slice.Indices; for (int i = 0; i < indices.Length; ++i) { int index = indices[i]; Vector3 vertex = vertices[index]; vertex = AxisTransform(deformer, vertex, slice.Center, thickness); vertex = WrapAroundAxisTransform(deformer, vertex, slice.Center, wrapCurvature); vertex = matrix.MultiplyPoint(vertex); vertices[index] = vertex; } } return(vertices); }