Example #1
0
        // Creates a new optimized/fixed brushMesh based on the brushMesh inside of the generator
        // this will not be copied to the generator until the current operation is complete.
        // This prevents, for example, dragging an edge over another edge DURING a dragging operation messing things up.
        void UpdateEditableOutline(ChiselBrush generator, float3[] vertices)
        {
            generatorModified = true;
            var outline = activeOutlines[generator];

            var internalBrushMesh = new BrushMesh(outline.brushMesh);

            // Removes infinitely thin polygons (for instance, when snapping edges to edges)
            internalBrushMesh.RemoveDegenerateTopology(out outline.edgeRemap, out outline.polygonRemap);

            internalBrushMesh.CalculatePlanes();

            // If the brush is concave, we set the generator to not be valid, so that when we commit, it will be reverted
            generator.definition.ValidState = !internalBrushMesh.IsConcave() && // TODO: eventually allow concave shapes
                                              !internalBrushMesh.IsSelfIntersecting() &&
                                              internalBrushMesh.HasVolume();

            generator.definition.brushOutline = internalBrushMesh;

            generator.OnValidate();

            outline.Rebuild();
        }
Example #2
0
        // Creates a new optimized/fixed brushMesh based on the brushMesh inside of the generator
        // this will not be copied to the generator until the current operation is complete.
        // This prevents, for example, dragging an edge over another edge DURING a dragging operation messing things up.
        void UpdateEditableOutline(ChiselBrushComponent generator)
        {
            generatorModified = true;
            var outline = activeOutlines[generator];

            var internalBrushMesh = new BrushMesh(outline.brushMesh);

            // Removes infinitely thin polygons (for instance, when snapping edges to edges)
            internalBrushMesh.RemoveDegenerateTopology(out outline.edgeRemap, out outline.polygonRemap);

            internalBrushMesh.CalculatePlanes();

            // If the brush is concave, we set the generator to not be valid, so that when we commit, it will be reverted
            generator.definition.ValidState = internalBrushMesh.HasVolume() &&          // TODO: implement this, so we know if a brush is a 0D/1D/2D shape
                                              !internalBrushMesh.IsConcave() &&         // TODO: eventually allow concave shapes
                                              !internalBrushMesh.IsSelfIntersecting();  // TODO: in which case this needs to be implemented

            generator.definition.brushOutline = internalBrushMesh;

            generator.definition.EnsurePlanarPolygons();
            generator.OnValidate();

            outline.Rebuild();
        }