Пример #1
0
        public override void OnInvalidate(InvalidateArgs invalidateType)
        {
            if ((invalidateType.InvalidateType == InvalidateType.Content ||
                 invalidateType.InvalidateType == InvalidateType.Matrix ||
                 invalidateType.InvalidateType == InvalidateType.Mesh) &&
                invalidateType.Source != this &&
                !RebuildLocked)
            {
                Rebuild(null);
            }
            else if (invalidateType.InvalidateType == InvalidateType.Color)
            {
                var sourceItem = OperationSourceObject3D.GetOrCreateSourceContainer(this).Children.FirstOrDefault();
                foreach (var item in Children)
                {
                    if (item != sourceItem)
                    {
                        item.Color = sourceItem.Color;
                    }
                }

                base.OnInvalidate(invalidateType);
            }
            else if (invalidateType.InvalidateType == InvalidateType.Properties &&
                     invalidateType.Source == this)
            {
                Rebuild(null);
            }
            else
            {
                base.OnInvalidate(invalidateType);
            }
        }
Пример #2
0
        private void Rebuild(UndoBuffer undoBuffer)
        {
            using (this.RebuildLock())
            {
                this.DebugDepth("Rebuild");

                var sourceContainer = OperationSourceObject3D.GetOrCreateSourceContainer(this);

                this.Children.Modify(list =>
                {
                    list.Clear();
                    // add back in the sourceContainer
                    list.Add(sourceContainer);
                    // get the source item
                    var sourceItem = sourceContainer.Children.First();

                    for (int i = 0; i < Math.Max(Count, 1); i++)
                    {
                        var next    = sourceItem.Clone();
                        next.Matrix = sourceItem.Matrix * Matrix4X4.CreateTranslation(Direction.Normal.GetNormal() * Distance * i);
                        list.Add(next);
                    }
                });
            }

            this.Invalidate(new InvalidateArgs(this, InvalidateType.Content));
        }
Пример #3
0
        private void Rebuild(UndoBuffer undoBuffer)
        {
            using (this.RebuildLock())
            {
                this.DebugDepth("Rebuild");
                var aabb = this.GetAxisAlignedBoundingBox();

                // check if we have initialized the Axis
                if (Axis.Origin.X == double.NegativeInfinity)
                {
                    // make it something reasonable (just to the left of the aabb of the object)
                    Axis.Origin = aabb.Center - new Vector3(-30, 0, 0);
                }

                // make sure our length is in the right axis
                for (int i = 0; i < 3; i++)
                {
                    if (Axis.Normal[i] != 0 && Axis.Origin[i] == 0)
                    {
                        var newOrigin = Vector3.Zero;
                        newOrigin[i] = Math.Max(aabb.Center[0] - Axis.Origin[0],
                                                Math.Max(aabb.Center[1] - Axis.Origin[1],
                                                         aabb.Center[2] - Axis.Origin[2]));
                    }
                }

                var sourceContainer = OperationSourceObject3D.GetOrCreateSourceContainer(this);
                this.Children.Modify(list =>
                {
                    list.Clear();
                    // add back in the sourceContainer
                    list.Add(sourceContainer);
                    // get the source item
                    var sourceItem = sourceContainer.Children.First();

                    var offset = Vector3.Zero;
                    for (int i = 0; i < Math.Max(Count, 1); i++)
                    {
                        var next = sourceItem.Clone();

                        var normal       = Axis.Normal.GetNormal();
                        var angleRadians = MathHelper.DegreesToRadians(Angle) / Count * i;
                        next.Rotate(Axis.Origin, normal, angleRadians);

                        if (!RotatePart)
                        {
                            var nextAabb = next.GetAxisAlignedBoundingBox();
                            next.Rotate(nextAabb.Center, normal, -angleRadians);
                        }

                        list.Add(next);
                    }
                });
            }

            this.Invalidate(new InvalidateArgs(this, InvalidateType.Content));
        }
Пример #4
0
        public override void Apply(UndoBuffer undoBuffer)
        {
            OperationSourceObject3D.Apply(this);

            base.Apply(undoBuffer);
        }
Пример #5
0
        public override void Remove(UndoBuffer undoBuffer)
        {
            OperationSourceObject3D.Remove(this);

            base.Remove(undoBuffer);
        }
Пример #6
0
        public override void Flatten(UndoBuffer undoBuffer)
        {
            OperationSourceObject3D.Flatten(this);

            base.Flatten(undoBuffer);
        }