/// <summary> /// Retrieves a list of line segments that directly represent the collision volume of the terrain. This includes offsets and removed edges. /// </summary> /// <returns>A list of line segments.</returns> public List <List <Vector2> > LegacyGetColliderVerts() { if (TerrainMaterial == null) { return(new List <List <Vector2> >()); } List <Vector2> tVerts = Path.GetVertsRaw(); // drop a skirt on skirt-based terrain if ((fill == Ferr2DT_FillMode.Skirt || fill == Ferr2DT_FillMode.FillOnlySkirt) && tVerts.Count > 0) { Vector2 start = tVerts[0]; Vector2 end = tVerts[tVerts.Count - 1]; tVerts.Add(new Vector2(end.x, fillY)); tVerts.Add(new Vector2(start.x, fillY)); tVerts.Add(new Vector2(start.x, start.y)); } float fillDist = (TerrainMaterial.ToUV(TerrainMaterial.GetBody((Ferr2DT_TerrainDirection)0, 0)).width *(TerrainMaterial.edgeMaterial.mainTexture.width / pixelsPerUnit)) / (Mathf.Max(1, splitCount)) * splitDist; List <Ferr2DT_TerrainDirection> dirs = new List <Ferr2DT_TerrainDirection>(); List <List <Vector2> > result = new List <List <Vector2> >(); List <List <int> > list = GetSegments(tVerts, out dirs); List <Vector2> curr = new List <Vector2>(); // remove segments that aren't on the terrain for (int i = 0; i < list.Count; i++) { if ((dirs[i] == Ferr2DT_TerrainDirection.Bottom && !collidersBottom) || (dirs[i] == Ferr2DT_TerrainDirection.Left && !collidersLeft) || (dirs[i] == Ferr2DT_TerrainDirection.Top && !collidersTop) || (dirs[i] == Ferr2DT_TerrainDirection.Right && !collidersRight)) { if (curr.Count > 0) { result.Add(new List <Vector2>(curr)); curr.Clear( ); } } else { // create a list of verts and scales for this edge List <float> tScales = null; List <Vector2> tList = null; Ferr2D_Path.IndicesToPath(tVerts, vertScales, list[i], out tList, out tScales); // smooth it! if (smoothPath && tList.Count > 2) { Ferr2D_Path.SmoothSegment(tList, tScales, fillDist, false, out tList, out tScales); } // offset the verts based on scale and terrain edge info tList = LegacyOffsetColliderVerts(tList, tScales, dirs[i]); // sharpen corners properly! if (curr.Count > 0 && sharpCorners) { LegacyMergeCorner(ref curr, ref tList); } curr.AddRange(tList); } } if (sharpCorners) { LegacyMergeCorner(ref curr, ref curr); } if (curr.Count > 0) { result.Add(curr); } return(result); }