Beispiel #1
0
        private void UpdateFoliage(bool refresh = false)
        {
            var foliageComponent = m_actor.GetFoliage();

            bool removeComponent         = m_lod > MyFoliageComponent.LodLimit || !m_actor.IsVisible;
            bool shouldInitializeFoliage = false;

            if (refresh && foliageComponent != null)
            {
                foliageComponent.RefreshStreams();
            }

            if (foliageComponent == null && !removeComponent)
            {
                shouldInitializeFoliage = m_mesh.ShouldHaveFoliage();
            }

            if (shouldInitializeFoliage)
            {
                m_actor.AddComponent <MyFoliageComponent>(MyComponentFactory <MyFoliageComponent> .Create());
            }
            else if (foliageComponent != null && removeComponent)
            {
                foliageComponent.InvalidateStreams();
                m_actor.RemoveComponent <MyFoliageComponent>(foliageComponent);
            }
        }