コード例 #1
0
        public override Task Rebuild()
        {
            this.DebugDepth("Rebuild");
            bool valuesChanged = false;

            var width         = Width.ClampIfNotCalculated(this, MinEdgeSize, 1000000, ref valuesChanged);
            var depth         = Depth.ClampIfNotCalculated(this, MinEdgeSize, 1000000, ref valuesChanged);
            var height        = Height.ClampIfNotCalculated(this, MinEdgeSize, 1000000, ref valuesChanged);
            var roundSegments = RoundSegments.ClampIfNotCalculated(this, 1, 90, ref valuesChanged);
            var roundRadius   = Radius.ClampIfNotCalculated(this, 0, Math.Min(width, Math.Min(depth, height)) / 2, ref valuesChanged);

            Invalidate(InvalidateType.DisplayValues);

            using (RebuildLock())
            {
                using (new CenterAndHeightMaintainer(this))
                {
                    if (Round)
                    {
                        Mesh = RoundedCornerBox.Create(roundSegments, new Vector3(width, depth, height), roundRadius);
                    }
                    else
                    {
                        Mesh = PlatonicSolids.CreateCube(Width.Value(this), Depth.Value(this), Height.Value(this));
                    }
                }
            }

            Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
            return(Task.CompletedTask);
        }