コード例 #1
0
        // When moving an edge/vertex we want to keep using the original mesh since we might be collapsing polygons
        // when snapping vertices/edges together. If we always use the current mesh then we'd suddenly may be moving
        // something else than we started out with. When we're done with the movement and release the mouse we want
        // this to become permanent however, and that's what this method does.
        void CommitChanges()
        {
            if (!generatorModified)
            {
                return;
            }

            var activeGenerators = activeOutlines.Keys.ToArray();

            Undo.RecordObjects(activeGenerators, activeGenerators.Length == 1 ? "Modified brush" : "Modified brushes");

            // Remove redundant vertices and fix the selection so that the correct edges/vertices etc. are selected
            foreach (var generator in activeGenerators)
            {
                var outline = activeOutlines[generator];

                // We remove redundant vertices here since in editableOutline we make the assumption that the vertices
                // between the original and the 'fixed' brushMesh are identical.
                // This makes it a lot easier to find 'soft edges'.
                outline.vertexRemap = generator.definition.brushOutline.RemoveUnusedVertices();
                ChiselEditableOutline.RemapSelection(generator.definition.brushOutline, outline.selection, outline.vertexRemap, outline.edgeRemap, outline.polygonRemap);
            }

            // Create new outlines for our generators
            foreach (var generator in activeGenerators)
            {
                activeOutlines[generator] = new ChiselEditableOutline(generator);
            }

            generatorModified = false;
        }
コード例 #2
0
        protected override void OnUndoRedoPerformed()
        {
            var activeGenerators = activeOutlines.Keys.ToArray();

            foreach (var generator in activeGenerators)
            {
                generator.definition.brushOutline.Validate();
                generator.definition.brushOutline.CalculatePlanes();
                activeOutlines[generator] = new ChiselEditableOutline(generator);
                UpdateEditableOutline(generator);
            }
        }
コード例 #3
0
        protected override void OnGeneratorSelected(ChiselBrush generator)
        {
            if (generator.definition.IsValid)
            {
                CommitChanges();
            }
            else
            {
                CancelChanges();
            }

            activeOutlines[generator] = new ChiselEditableOutline(generator);
        }
コード例 #4
0
        protected override void OnUndoRedoPerformed()
        {
            CommitChanges();

            // TODO: do we actually need this?
            var activeGenerators = activeOutlines.Keys.ToArray();

            foreach (var generator in activeGenerators)
            {
                generator.definition.brushOutline.Validate();
                generator.definition.brushOutline.CalculatePlanes();
                activeOutlines[generator] = new ChiselEditableOutline(generator);
            }
        }
コード例 #5
0
        void CancelChanges()
        {
            if (!generatorModified)
            {
                return;
            }

            generatorModified = false;
            var activeGenerators = activeOutlines.Keys.ToArray();

            foreach (var generator in activeGenerators)
            {
                activeOutlines[generator] = new ChiselEditableOutline(generator);
            }
            UndoAllChanges();
        }