public static void DrawSimpleOutlines(LineMeshManager lineMeshManager, GeometryWireframe outline, Matrix4x4 transformation, Color color)
        {
            if (outline == null ||
                outline.vertices == null ||
                outline.vertices.Length == 0 ||

                (outline.visibleOuterLines == null &&
                 outline.invisibleOuterLines == null &&
                 outline.visibleInnerLines == null &&
                 outline.invisibleInnerLines == null &&
                 outline.invalidLines == null))
            {
                return;
            }

            var vertices = outline.vertices;
            var indices  = outline.visibleOuterLines;

            if (indices != null &&
                indices.Length > 0 &&
                (indices.Length & 1) == 0)
            {
                lineMeshManager.DrawLines(transformation, vertices, indices, color);
            }

            indices = outline.invisibleOuterLines;
            if (indices != null &&
                indices.Length > 0 &&
                (indices.Length & 1) == 0)
            {
                lineMeshManager.DrawLines(transformation, vertices, indices, color);
            }
        }
        public static void DrawSelectedBrush(GeometryWireframe outline, Vector3 translation, Color wireframeColor, float thickness = -1)
        {
            Color selectedOuterColor         = wireframeColor;
            Color selectedInnerColor         = wireframeColor * inner_factor;
            Color selectedOuterOccludedColor = selectedOuterColor * occluded_factor;
            Color selectedInnerOccludedColor = selectedInnerColor * occluded_factor;

            selectedOuterOccludedColor.a *= 0.5f;
            selectedInnerOccludedColor.a *= 0.5f;

            CSGRenderer.DrawOutlines(outline, translation, selectedOuterColor, selectedOuterOccludedColor, selectedInnerColor, selectedInnerOccludedColor, thickness);
        }
        public static void DrawSimpleOutlines(LineMeshManager lineMeshManager, GeometryWireframe outline, Vector3 translation, Color color)
        {
            if (outline == null ||
                outline.vertices == null ||
                outline.vertices.Length == 0 ||

                (outline.visibleOuterLines == null &&
                 outline.invisibleOuterLines == null &&
                 outline.visibleInnerLines == null &&
                 outline.invisibleInnerLines == null &&
                 outline.invalidLines == null))
            {
                return;
            }

            var translationMatrix = MathConstants.identityMatrix;

            translationMatrix.m03 = translation.x;
            translationMatrix.m13 = translation.y;
            translationMatrix.m23 = translation.z;

            var vertices = outline.vertices;
            var indices  = outline.visibleOuterLines;

            if (indices != null &&
                indices.Length > 0 &&
                (indices.Length & 1) == 0)
            {
                lineMeshManager.DrawLines(translationMatrix, vertices, indices, color);
            }

            indices = outline.invisibleOuterLines;
            if (indices != null &&
                indices.Length > 0 &&
                (indices.Length & 1) == 0)
            {
                lineMeshManager.DrawLines(translationMatrix, vertices, indices, color);
            }
        }
        public GeometryWireframe Clone()
        {
            var clone = new GeometryWireframe();

            if (vertices != null)
            {
                clone.vertices = new Vector3[vertices.Length];
                Array.Copy(vertices, clone.vertices, vertices.Length);
            }
            else
            {
                clone.vertices = null;
            }

            if (visibleOuterLines != null)
            {
                clone.visibleOuterLines = new Int32[visibleOuterLines.Length];
                Array.Copy(visibleOuterLines, clone.visibleOuterLines, visibleOuterLines.Length);
            }
            else
            {
                clone.visibleOuterLines = null;
            }

            if (visibleInnerLines != null)
            {
                clone.visibleInnerLines = new Int32[visibleInnerLines.Length];
                Array.Copy(visibleInnerLines, clone.visibleInnerLines, visibleInnerLines.Length);
            }
            else
            {
                clone.visibleInnerLines = null;
            }

            if (visibleTriangles != null)
            {
                clone.visibleTriangles = new Int32[visibleTriangles.Length];
                Array.Copy(visibleTriangles, clone.visibleTriangles, visibleTriangles.Length);
            }
            else
            {
                clone.visibleTriangles = null;
            }

            if (invisibleOuterLines != null)
            {
                clone.invisibleOuterLines = new Int32[invisibleOuterLines.Length];
                Array.Copy(invisibleOuterLines, clone.invisibleOuterLines, invisibleOuterLines.Length);
            }
            else
            {
                clone.invisibleOuterLines = null;
            }

            if (invisibleInnerLines != null)
            {
                clone.invisibleInnerLines = new Int32[invisibleInnerLines.Length];
                Array.Copy(invisibleInnerLines, clone.invisibleInnerLines, invisibleInnerLines.Length);
            }
            else
            {
                clone.invisibleInnerLines = null;
            }

            if (invalidLines != null)
            {
                clone.invalidLines = new Int32[invalidLines.Length];
                Array.Copy(invalidLines, clone.invalidLines, invalidLines.Length);
            }
            else
            {
                clone.invalidLines = null;
            }

            return(clone);
        }
        public static void DrawOutlines(GeometryWireframe outline, Matrix4x4 transformation,
                                        Color outerColor, Color outerColorOccluded, Color innerColor, Color innerColorOccluded,
                                        float thickness = -1)
        {
            if (outline == null ||
                outline.vertices == null ||
                outline.vertices.Length == 0 ||

                (outline.visibleOuterLines == null &&
                 outline.invisibleOuterLines == null &&
                 outline.visibleInnerLines == null &&
                 outline.invisibleInnerLines == null &&
                 outline.invalidLines == null))
            {
                return;
            }

            Handles.matrix = transformation;

            if (outline.visibleOuterLines != null && outline.visibleOuterLines.Length > 0)
            {
                if (thickness <= 0)
                {
                    PaintUtility.DrawLines(transformation, outline.vertices, outline.visibleOuterLines, outerColor);
                }
                else
                {
                    //PaintUtility.DrawUnoccludedLines(transformation, outline.vertices, outline.visibleOuterLines, outerColor);
                    PaintUtility.DrawLines(transformation, outline.vertices, outline.visibleOuterLines, thickness, outerColor);
                }
            }

            if (outline.visibleInnerLines != null && outline.visibleInnerLines.Length > 0)
            {
                if (thickness <= 0)
                {
                    PaintUtility.DrawLines(transformation, outline.vertices, outline.visibleInnerLines, innerColor);
                }
                else
                {
                    //PaintUtility.DrawUnoccludedLines(transformation, outline.vertices, outline.visibleInnerLines, innerColor);
                    PaintUtility.DrawLines(transformation, outline.vertices, outline.visibleInnerLines, thickness, innerColor);
                }
            }

            if (outline.visibleOuterLines != null && outline.visibleOuterLines.Length > 0)
            {
                Handles.color = outerColorOccluded;
                Handles.DrawDottedLines(outline.vertices, outline.visibleOuterLines, visibleOuterLineDots);
            }
            if (outline.visibleInnerLines != null && outline.visibleInnerLines.Length > 0)
            {
                Handles.color = innerColorOccluded;
                Handles.DrawDottedLines(outline.vertices, outline.visibleInnerLines, visibleInnerLineDots);
            }

            if (outline.invisibleOuterLines != null && outline.invisibleOuterLines.Length > 0)
            {
                Handles.color = outerColorOccluded;
                Handles.DrawDottedLines(outline.vertices, outline.invisibleOuterLines, invisibleOuterLineDots);
            }
            if (outline.invisibleInnerLines != null && outline.invisibleInnerLines.Length > 0)
            {
                Handles.color = innerColor;
                Handles.DrawDottedLines(outline.vertices, outline.invisibleInnerLines, invisibleInnerLineDots);
            }
#if TEST_ENABLED
            if (outline.invalidLines != null && outline.invalidLines.Length > 0)
            {
                Handles.color = Color.red;
                Handles.DrawDottedLines(outline.vertices, outline.invalidLines, invalidLineDots);
            }
#endif
        }
        public static void DrawOutlines(GeometryWireframe outline, Vector3 translation,
                                        Color outerColor, Color outerColorOccluded, Color innerColor, Color innerColorOccluded,
                                        float thickness = -1)
        {
            if (outline == null ||
                outline.vertices == null ||
                outline.vertices.Length == 0 ||

                (outline.visibleOuterLines == null &&
                 outline.invisibleOuterLines == null &&
                 outline.visibleInnerLines == null &&
                 outline.invisibleInnerLines == null &&
                 outline.invalidLines == null))
            {
                return;
            }

            var translationMatrix = MathConstants.identityMatrix;

            translationMatrix.m03 = translation.x;
            translationMatrix.m13 = translation.y;
            translationMatrix.m23 = translation.z;
            Handles.matrix        = translationMatrix;

            if (outline.visibleOuterLines != null && outline.visibleOuterLines.Length > 0)
            {
                if (thickness <= 0)
                {
                    PaintUtility.DrawLines(translationMatrix, outline.vertices, outline.visibleOuterLines, outerColor);
                }
                else
                {
                    //PaintUtility.DrawUnoccludedLines(translationMatrix, outline.vertices, outline.visibleOuterLines, outerColor);
                    PaintUtility.DrawLines(translationMatrix, outline.vertices, outline.visibleOuterLines, thickness, outerColor);
                }
            }

            if (outline.visibleInnerLines != null && outline.visibleInnerLines.Length > 0)
            {
                if (thickness <= 0)
                {
                    PaintUtility.DrawLines(translationMatrix, outline.vertices, outline.visibleInnerLines, innerColor);
                }
                else
                {
                    //PaintUtility.DrawUnoccludedLines(translationMatrix, outline.vertices, outline.visibleInnerLines, innerColor);
                    PaintUtility.DrawLines(translationMatrix, outline.vertices, outline.visibleInnerLines, thickness, innerColor);
                }
            }

            if (outline.visibleOuterLines != null && outline.visibleOuterLines.Length > 0)
            {
                Handles.color = outerColorOccluded;
                Handles.DrawDottedLines(outline.vertices, outline.visibleOuterLines, visibleOuterLineDots);
            }
            if (outline.visibleInnerLines != null && outline.visibleInnerLines.Length > 0)
            {
                Handles.color = innerColorOccluded;
                Handles.DrawDottedLines(outline.vertices, outline.visibleInnerLines, visibleInnerLineDots);
            }

            if (outline.invisibleOuterLines != null && outline.invisibleOuterLines.Length > 0)
            {
                Handles.color = outerColorOccluded;
                Handles.DrawDottedLines(outline.vertices, outline.invisibleOuterLines, invisibleOuterLineDots);
            }
            if (outline.invisibleInnerLines != null && outline.invisibleInnerLines.Length > 0)
            {
                Handles.color = innerColor;
                Handles.DrawDottedLines(outline.vertices, outline.invisibleInnerLines, invisibleInnerLineDots);
            }
            if (outline.invalidLines != null && outline.invalidLines.Length > 0)
            {
                Handles.color = Color.red;
                Handles.DrawDottedLines(outline.vertices, outline.invalidLines, invalidLineDots);
            }
        }