private void LegacyCreateBody(Ferr2DT_SegmentDescription aDesc, List <Vector2> aSegment, List <float> aSegmentScale, List <CutOverrides> aCutOverrides, float aBodyWidth, int aTextureSlices, bool aClosed) { float distance = Ferr2D_Path.GetSegmentLength(aSegment); int textureCuts = Mathf.Max(1, Mathf.FloorToInt(distance / aBodyWidth + 0.5f)); Ferr2D_DynamicMesh mesh = DMesh; Rect body = LegacyPickBody(aDesc, aCutOverrides, aSegment[0], 0, 0); float d = (body.height / 2) * unitsPerUV.y; float yOff = fill == Ferr2DT_FillMode.InvertedClosed ? -aDesc.yOffset : aDesc.yOffset; int p1 = 0, p2 = 0, p3 = 0; int pIndex = 0; int cutIndex = 0; // loop for each instance of the texture for (int t = 0; t < textureCuts; t++) { float texPercent = (t / (float)(textureCuts)); float texPercentStep = (1f / (float)(textureCuts)); // slice each texture chunk a number of times for (int i = 0; i < aTextureSlices; i++) { float slicePercent = (i / (float)(aTextureSlices - 1)); float totalPercent = texPercent + slicePercent * texPercentStep; int ptLocal = 0; float pctLocal = 0; Ferr2D_Path.PathGlobalPercentToLocal(aSegment, totalPercent, out ptLocal, out pctLocal, distance, aClosed); // if we skip over path points, we need to add slices at each path point to prevent the mesh from bypassing it. for (int extra = 0; extra < ptLocal - pIndex; extra++) { float traveledDist = Ferr2D_Path.GetSegmentLengthToIndex(aSegment, pIndex + extra + 1); float v = (traveledDist / distance) * textureCuts; v = v - (int)v; LegacyAddVertexColumn(aDesc, aSegment, aSegmentScale, aClosed, mesh, body, d, yOff, i != 0, v, pIndex + extra + 1, 0, ref p1, ref p2, ref p3); cutIndex = -1; } pIndex = ptLocal; LegacyAddVertexColumn(aDesc, aSegment, aSegmentScale, aClosed, mesh, body, d, yOff, i != 0, slicePercent, ptLocal, pctLocal, ref p1, ref p2, ref p3); } cutIndex += 1; body = LegacyPickBody(aDesc, aCutOverrides, mesh.GetVert(p2), pIndex, cutIndex); } }