private void CreateRoads(Bounds bounds) { // not too close to the bounds; the easy roads spline might move the road outside bounds.size *= 0.9f; Vector2[] clipBounds = new Vector2[] { new Vector2(bounds.center.x - bounds.extents.x, bounds.center.z - bounds.extents.z), new Vector2(bounds.center.x + bounds.extents.x, bounds.center.z - bounds.extents.z), new Vector2(bounds.center.x + bounds.extents.x, bounds.center.z + bounds.extents.z), new Vector2(bounds.center.x - bounds.extents.x, bounds.center.z + bounds.extents.z), }; int pointCount = editor.extension.voronoiSettings.pointCount; List <Vector3> maskNodes = CreateRoad(bounds, pointCount, clipBounds); List <Vector3> nodes = ShapeCreator.CreateRandomShape(maskNodes, // editor.extension.shapeSettings.RandomConvexity, // editor.extension.shapeSettings.keepOriginalPoints, // editor.extension.shapeSettings.RandomPointsCount, // editor.extension.shapeSettings.randomAngle, // editor.extension.shapeSettings.douglasPeuckerReductionTolerance); PolygonUtils.SortClockWise(nodes); if (smoothEnabled.boolValue) { List <Vector2> positionsXY = nodes.ConvertAll(item => new Vector2(item.x, item.z)); positionsXY = getCurveSmoothingChaikin(positionsXY, 0.5f, 0); nodes = positionsXY.ConvertAll(item => new Vector3(item.x, 0, item.y)); } nodes = AlignToTerrainHeight(nodes); // remove nodes that are too close to each other RemoveNodes(nodes, minDistance.floatValue); // set ER markers erRoad.AddMarkers(nodes.ToArray()); // set closed track erRoad.ClosedTrack(closedTrack.boolValue); }