Esempio n. 1
0
 internal static void Remove(FlareId flareId)
 {
     if (flareId != FlareId.NULL)
     {
         if (m_flares.Data[flareId.Index].Query != null)
         {
             MyOcclusionQueryRenderer.Remove(m_flares.Data[flareId.Index].Query);
             m_flares.Data[flareId.Index].Query = null;
         }
         m_flares.Free(flareId.Index);
     }
 }
Esempio n. 2
0
        internal static FlareId Set(FlareId flareId, MyFlareDesc desc)
        {
            if (desc.Enabled)
            {
                if (flareId == FlareId.NULL)
                {
                    flareId = new FlareId {
                        Index = m_flares.Allocate()
                    };
                }
                if (Math.Abs(desc.Intensity) > 0.01f)
                {
                    if (m_flares.Data[flareId.Index].Query == null)
                    {
                        m_flares.Data[flareId.Index].Query = MyOcclusionQueryRenderer.Get(desc.Material.ToString());
                    }
                }
                else if (m_flares.Data[flareId.Index].Query != null)
                {
                    MyOcclusionQueryRenderer.Remove(m_flares.Data[flareId.Index].Query);
                    m_flares.Data[flareId.Index].Query = null;
                }

                if (desc.MaxDistance > 0)
                {
                    if (m_flares.Data[flareId.Index].Desc.Type != Lights.MyGlareTypeEnum.Distant)
                    {
                        desc.MaxDistance = Math.Min(MyRenderConstants.MAX_GPU_OCCLUSION_QUERY_DISTANCE, desc.MaxDistance);
                    }
                }
                else
                {
                    desc.MaxDistance = MyRenderConstants.MAX_GPU_OCCLUSION_QUERY_DISTANCE;
                }

                m_flares.Data[flareId.Index].Desc = desc;
                if (desc.ParentGID == -1)
                {
                    m_flares.Data[flareId.Index].DirectionWorld = desc.Direction;
                }
            }
            else
            {
                Remove(flareId);
                flareId = FlareId.NULL;
            }
            return(flareId);
        }