private void ResetPaintMark(bool paint)
        {
            m_PaintedType = paint ? PaintedType.Painted : PaintedType.None;
            if (m_CenterNode != null && (m_CenterNode.m_PaintedType != m_PaintedType || m_CenterNode.m_PaintedType == PaintedType.Mix))
            {
                m_PaintedType = PaintedType.Mix;
                return;
            }
            if (m_TopNode != null && (m_TopNode.m_PaintedType != m_PaintedType || m_TopNode.m_PaintedType == PaintedType.Mix))
            {
                m_PaintedType = PaintedType.Mix;
                return;
            }
            if (m_LeftNode != null && (m_LeftNode.m_PaintedType != m_PaintedType || m_LeftNode.m_PaintedType == PaintedType.Mix))
            {
                m_PaintedType = PaintedType.Mix;
                return;
            }
            if (m_RightNode != null && (m_RightNode.m_PaintedType != m_PaintedType || m_RightNode.m_PaintedType == PaintedType.Mix))
            {
                m_PaintedType = PaintedType.Mix;
                return;
            }

            m_CenterNode = null;
            m_TopNode    = null;
            m_LeftNode   = null;
            m_RightNode  = null;
        }
        public void SamplingFromTexture(Vector2 weight0, Vector2 weight1, Vector2 weight2, Vector2 u0, Vector2 u1, Vector2 u2, Texture2D texture, int depth, int maxDepth)
        {
            if (depth <= maxDepth)
            {
                Vector2 halfw01 = weight0 + (weight1 - weight0) * 0.5f;
                Vector2 halfw02 = weight0 + (weight2 - weight0) * 0.5f;
                Vector2 halfw12 = weight1 + (weight2 - weight1) * 0.5f;
                if (m_CenterNode != null)
                {
                    m_CenterNode.SamplingFromTexture(halfw01, halfw12, halfw02, u0, u1, u2, texture, depth + 1, maxDepth);
                }
                else
                {
                    m_CenterNode = SampleTexture(halfw01, halfw12, halfw02, u0, u1, u2, texture, depth + 1, maxDepth);
                }

                if (m_TopNode != null)
                {
                    m_TopNode.SamplingFromTexture(halfw01, weight1, halfw12, u0, u1, u2, texture, depth + 1, maxDepth);
                }
                else
                {
                    m_TopNode = SampleTexture(halfw01, weight1, halfw12, u0, u1, u2, texture, depth + 1, maxDepth);
                }

                if (m_LeftNode != null)
                {
                    m_LeftNode.SamplingFromTexture(weight0, halfw01, halfw02, u0, u1, u2, texture, depth + 1, maxDepth);
                }
                else
                {
                    m_LeftNode = SampleTexture(weight0, halfw01, halfw02, u0, u1, u2, texture, depth + 1, maxDepth);
                }

                if (m_RightNode != null)
                {
                    m_RightNode.SamplingFromTexture(halfw02, halfw12, weight2, u0, u1, u2, texture, depth + 1, maxDepth);
                }
                else
                {
                    m_RightNode = SampleTexture(halfw02, halfw12, weight2, u0, u1, u2, texture, depth + 1, maxDepth);
                }

                ResetPaintMark();
            }
            else
            {
                bool painted = SampleTexture(weight0, weight1, weight2, u0, u1, u2, texture);
                //if (blendMode == TextureBlendMode.Replace)
                {
                    m_PaintedType = painted ? PaintedType.Painted : PaintedType.None;
                }
            }
        }
        private void ResetPaintMark()
        {
            bool initPaintedtype = false;

            if (m_CenterNode != null)
            {
                initPaintedtype = true;
                m_PaintedType   = m_CenterNode.m_PaintedType;
            }
            if (m_TopNode != null)
            {
                if (!initPaintedtype)
                {
                    initPaintedtype = true;
                    m_PaintedType   = m_TopNode.m_PaintedType;
                }
                else
                {
                    if (m_TopNode.m_PaintedType != m_PaintedType || m_TopNode.m_PaintedType == PaintedType.Mix)
                    {
                        m_PaintedType = PaintedType.Mix;
                    }
                }
            }
            if (m_LeftNode != null)
            {
                if (!initPaintedtype)
                {
                    initPaintedtype = true;
                    m_PaintedType   = m_LeftNode.m_PaintedType;
                }
                else
                {
                    if (m_LeftNode.m_PaintedType != m_PaintedType || m_LeftNode.m_PaintedType == PaintedType.Mix)
                    {
                        m_PaintedType = PaintedType.Mix;
                    }
                }
            }
            if (m_RightNode != null)
            {
                if (!initPaintedtype)
                {
                    m_PaintedType = m_RightNode.m_PaintedType;
                }
                else
                {
                    if (m_RightNode.m_PaintedType != m_PaintedType || m_RightNode.m_PaintedType == PaintedType.Mix)
                    {
                        m_PaintedType = PaintedType.Mix;
                    }
                }
            }

            if (m_PaintedType != PaintedType.Mix)
            {
                m_CenterNode = null;
                m_TopNode    = null;
                m_LeftNode   = null;
                m_RightNode  = null;
            }
        }
 public NavMeshTriangleNode(PaintedType painted = PaintedType.None)
 {
     this.m_PaintedType = painted;
 }