예제 #1
0
        internal override void DrawGizmos(BrushTarget target, BrushSettings settings)
        {
            PolyMesh mesh = target.editableObject.editMesh;

            if (Util.IsValid(target) && paintMode == PaintMode.Fill)
            {
                Vector3[] vertices = mesh.vertices;
                int[]     indices  = mesh.GetTriangles();

                PolyHandles.PushMatrix();
                PolyHandles.PushHandleColor();

                Handles.matrix = target.transform.localToWorldMatrix;

                int index = 0;

                foreach (PolyRaycastHit hit in target.raycastHits)
                {
                    if (hit.triangle > -1)
                    {
                        Handles.color = Color.green;

                        index = hit.triangle * 3;

                        Handles.DrawLine(vertices[indices[index + 0]] + hit.normal * .1f, vertices[indices[index + 1]] + hit.normal * .1f);
                        Handles.DrawLine(vertices[indices[index + 1]] + hit.normal * .1f, vertices[indices[index + 2]] + hit.normal * .1f);
                        Handles.DrawLine(vertices[indices[index + 2]] + hit.normal * .1f, vertices[indices[index + 0]] + hit.normal * .1f);

                        m_FillModeEdges[0].x = indices[index + 0];
                        m_FillModeEdges[0].y = indices[index + 1];

                        m_FillModeEdges[1].x = indices[index + 1];
                        m_FillModeEdges[1].y = indices[index + 2];

                        m_FillModeEdges[2].x = indices[index + 2];
                        m_FillModeEdges[2].y = indices[index + 0];

                        for (int i = 0; i < 3; i++)
                        {
                            if (m_TriangleLookup.TryGetValue(m_FillModeEdges[i], out m_FillModeAdjacentTriangles))
                            {
                                for (int n = 0; n < m_FillModeAdjacentTriangles.Count; n++)
                                {
                                    index = m_FillModeAdjacentTriangles[n] * 3;

                                    Handles.DrawLine(vertices[indices[index + 0]] + hit.normal * .1f, vertices[indices[index + 1]] + hit.normal * .1f);
                                    Handles.DrawLine(vertices[indices[index + 1]] + hit.normal * .1f, vertices[indices[index + 2]] + hit.normal * .1f);
                                    Handles.DrawLine(vertices[indices[index + 2]] + hit.normal * .1f, vertices[indices[index + 0]] + hit.normal * .1f);
                                }
                            }
                        }
                    }
                }

                PolyHandles.PopHandleColor();
                PolyHandles.PopMatrix();
            }
            else
            {
                base.DrawGizmos(target, settings);
            }
        }