internal override bool CreateControlMeshForBrushIndex(CSGModel parentModel, CSGBrush brush, ShapePolygon polygon, Matrix4x4 localToWorld, float height, out ControlMesh newControlMesh, out Shape newShape) { var direction = haveForcedDirection ? forcedDirection : buildPlane.normal; if (!ShapePolygonUtility.GenerateControlMeshFromVertices(polygon, localToWorld, GeometryUtility.RotatePointIntoPlaneSpace(buildPlane, direction), height, new TexGen(), false, true, out newControlMesh, out newShape)) { return(false); } brush.Shape = newShape; brush.ControlMesh = newControlMesh; InternalCSGModelManager.ValidateBrush(brush, true); ControlMeshUtility.RebuildShape(brush); return(true); }
internal override bool CreateControlMeshForBrushIndex(CSGModel parentModel, CSGBrush brush, ShapePolygon polygon, Matrix4x4 localToWorld, float height, out ControlMesh newControlMesh, out Shape newShape) { bool smooth = settings.circleSmoothShading; bool singleSurfaceEnds = settings.circleSingleSurfaceEnds; var direction = haveForcedDirection ? forcedDirection : buildPlane.normal; if (!ShapePolygonUtility.GenerateControlMeshFromVertices(polygon, localToWorld, GeometryUtility.RotatePointIntoPlaneSpace(buildPlane, direction), height, new TexGen(), smooth, singleSurfaceEnds, out newControlMesh, out newShape)) { return(false); } brush.Shape = newShape; brush.ControlMesh = newControlMesh; InternalCSGModelManager.ValidateBrush(brush, true); ControlMeshUtility.RebuildShape(brush); var vertices = polygon.Vertices; float circumference = 0.0f; for (int j = vertices.Length - 1, i = 0; i < vertices.Length; j = i, i++) { circumference += (vertices[j] - vertices[i]).magnitude; } var shape = brush.Shape; float desiredTextureLength = Mathf.Max(1.0f, Mathf.Round(circumference)); float scalar = desiredTextureLength / circumference; shape.TexGens[0].Scale.x = scalar; shape.TexGens[0].Scale.y = shape.TexGens[0].Scale.y; shape.TexGens[0].Translation.x = 0; var count = vertices.Length; if (!singleSurfaceEnds) { GeometryUtility.ContinueTexGenFromSurfaceToSurface(brush, 0, count); GeometryUtility.ContinueTexGenFromSurfaceToSurface(brush, 0, count + count); for (int j = 0, i = 1; i < count; j = i, i++) { GeometryUtility.ContinueTexGenFromSurfaceToSurface(brush, j, i); GeometryUtility.ContinueTexGenFromSurfaceToSurface(brush, i, i + count); GeometryUtility.ContinueTexGenFromSurfaceToSurface(brush, i, i + count + count); } } else { for (int j = 0, i = 1; i < count; j = i, i++) { GeometryUtility.ContinueTexGenFromSurfaceToSurface(brush, j, i); } } return(true); }