Beispiel #1
0
        // temporary solution to be able to see a brush wireframe
        static BrushOutline CreateOutline(BrushMesh brushMesh)
        {
            var brushOutline = new BrushOutline();

            brushOutline.Reset();
            if (brushMesh == null)
            {
                return(brushOutline);
            }
            brushOutline.surfaceOutlines = new Outline[brushMesh.surfaces.Length];
            brushOutline.vertices        = brushMesh.vertices.ToArray();

            var surfaceOutlines = brushOutline.surfaceOutlines;

            for (int p = 0; p < brushMesh.polygons.Length; p++)
            {
                surfaceOutlines[p] = new Outline();
                surfaceOutlines[p].Reset();
            }

            var brushVisibleOuterLines   = new List <int>();
            var surfaceVisibleOuterLines = new List <int>();

            for (int p = 0; p < brushMesh.polygons.Length; p++)
            {
                var surfaceOutline = surfaceOutlines[p];
                surfaceVisibleOuterLines.Clear();
                var firstEdge = brushMesh.polygons[p].firstEdge;
                var edgeCount = brushMesh.polygons[p].edgeCount;
                var lastEdge  = firstEdge + edgeCount;

                var vertexIndex0 = brushMesh.halfEdges[lastEdge - 1].vertexIndex;
                var vertexIndex1 = 0;
                for (int h = firstEdge; h < lastEdge; vertexIndex0 = vertexIndex1, h++)
                {
                    vertexIndex1 = brushMesh.halfEdges[h].vertexIndex;
                    if (vertexIndex0 > vertexIndex1) // avoid duplicate edges
                    {
                        brushVisibleOuterLines.Add(vertexIndex0);
                        brushVisibleOuterLines.Add(vertexIndex1);
                    }
                    surfaceVisibleOuterLines.Add(vertexIndex0);
                    surfaceVisibleOuterLines.Add(vertexIndex1);
                }

                surfaceOutline.visibleOuterLines = surfaceVisibleOuterLines.ToArray();
            }
            brushOutline.brushOutline.visibleOuterLines = brushVisibleOuterLines.ToArray();
            return(brushOutline);
        }
Beispiel #2
0
 public void Reset()
 {
     brushOutlineDirty      = true;
     brushOutlineGeneration = 0;
     brushOutline.Reset();
 }