public override Task Rebuild() { this.DebugDepth("Rebuild"); bool valuesChanged = false; var startingAngle = StartingAngle.ClampIfNotCalculated(this, 0, 360 - .01, ref valuesChanged); var endingAngle = EndingAngle.ClampIfNotCalculated(this, startingAngle + .01, 360, ref valuesChanged); var sides = Sides.Value(this); var axisPosition = AxisPosition.Value(this); if (startingAngle > 0 || endingAngle < 360) { Sides = agg_basics.Clamp(sides, 1, 360, ref valuesChanged); } else { Sides = agg_basics.Clamp(sides, 3, 360, ref valuesChanged); } Invalidate(InvalidateType.DisplayValues); var rebuildLock = RebuildLock(); // now create a long running task to process the image return(ApplicationController.Instance.Tasks.Execute( "Revolve".Localize(), null, (reporter, cancellationToken) => { var vertexSource = this.VertexSource; var pathBounds = vertexSource.GetBounds(); vertexSource = vertexSource.Translate(-pathBounds.Left - axisPosition, 0); Mesh mesh = VertexSourceToMesh.Revolve(vertexSource, sides, MathHelper.DegreesToRadians(360 - endingAngle), MathHelper.DegreesToRadians(360 - startingAngle), false); // take the axis offset out mesh.Transform(Matrix4X4.CreateTranslation(pathBounds.Left + axisPosition, 0, 0)); if (mesh.Vertices.Count == 0) { mesh = null; } Mesh = mesh; UiThread.RunOnIdle(() => { rebuildLock.Dispose(); Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children)); }); return Task.CompletedTask; })); }