コード例 #1
0
        public void Add(UGrassInstance instance)
        {
            UGrassGroup group = null;

            for (int i = 0; i < m_Groups.Count; i++)
            {
                UGrassGroup g = m_Groups[i];
                if (Vector3.Distance(instance.position, g.center) < m_MaxRadius && g.length < m_MaxVector)
                {
                    group = g;
                    if (!m_ApplyGroup.Contains(i))
                    {
                        m_ApplyGroup.Add(i);
                    }
                }
            }
            if (group == null)
            {
                if (!m_ApplyGroup.Contains(m_Groups.Count))
                {
                    m_ApplyGroup.Add(m_Groups.Count);
                }
                m_Groups.Add(new UGrassGroup(m_GameObject.transform, m_Terrain, material, instance));
            }
            else
            {
                group.Add(instance);
            }
        }
コード例 #2
0
        public void AddArea(UGrassInstance instance, float density)
        {
            int         groupIndex = GetGroupIndex(instance);
            UGrassGroup group      = m_Groups[groupIndex];

            if (CheckGrassDistance(group, instance.position, density))
            {
                group.Add(instance);
                if (!m_ApplyGroup.Contains(groupIndex))
                {
                    m_ApplyGroup.Add(groupIndex);
                }
            }
        }