Ejemplo n.º 1
0
 internal static void Remove(FlareId flareId)
 {
     if (flareId != FlareId.NULL)
     {
         m_flares.Free(flareId.Index);
     }
 }
Ejemplo n.º 2
0
        internal static FlareId Update(int parentGID, FlareId flareId, MyFlareDesc desc)
        {
            if (desc.Enabled)
            {
                if (flareId == FlareId.NULL)
                {
                    flareId = new FlareId {
                        Index = m_flares.Allocate()
                    }
                }
                ;

                var gid = parentGID;
                if (gid != -1 && MyIDTracker <MyActor> .FindByID((uint)gid) != null)
                {
                    var matrix = MyIDTracker <MyActor> .FindByID((uint)gid).WorldMatrix;

                    Vector3.TransformNormal(ref desc.Direction, ref matrix, out desc.Direction);
                }

                desc.MaxDistance = (desc.MaxDistance > 0)
                    ? (float)Math.Min(MyRenderConstants.MAX_GPU_OCCLUSION_QUERY_DISTANCE, desc.MaxDistance)
                    : MyRenderConstants.MAX_GPU_OCCLUSION_QUERY_DISTANCE;

                m_flares.Data[flareId.Index] = desc;
            }
            else if (flareId != FlareId.NULL)
            {
                m_flares.Free(flareId.Index);
                flareId = FlareId.NULL;
            }
            return(flareId);
        }
Ejemplo n.º 3
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);
     }
 }
Ejemplo n.º 4
0
        internal static void Update(FlareId flareId)
        {
            var gid = m_flares.Data[flareId.Index].Desc.ParentGID;

            if (gid != -1 && m_flares.Data[flareId.Index].Desc.Type == Lights.MyGlareTypeEnum.Directional)
            {
                var actor = MyIDTracker <MyActor> .FindByID((uint)gid);

                if (actor != null)
                {
                    var matrix = actor.WorldMatrix;
                    Vector3.TransformNormal(ref m_flares.Data[flareId.Index].Desc.Direction, ref matrix, out m_flares.Data[flareId.Index].DirectionWorld);
                }
            }
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        internal static void Draw(FlareId flareId, Vector3D position)
        {
            var L        = MyRender11.Environment.Matrices.CameraPosition - position;
            var distance = (float)L.Length();

            switch (m_flares.Data[flareId.Index].Desc.Type)
            {
            case Lights.MyGlareTypeEnum.Distant:
                DrawDistantFlare(position, ref m_flares.Data[flareId.Index], distance);
                break;

            case Lights.MyGlareTypeEnum.Normal:
            case Lights.MyGlareTypeEnum.Directional:
                DrawNormalFlare(position, ref m_flares.Data[flareId.Index], L, distance);
                break;

            default:
                break;
            }
        }
Ejemplo n.º 7
0
        internal static FlareId Update(FlareId flareId, MyFlareDesc desc)
        {
            if (desc.Enabled)
            {
                if (flareId == FlareId.NULL)
                {
                    flareId = new FlareId {
                        Index = m_flares.Allocate()
                    };
                }

                desc.MaxDistance = (desc.MaxDistance > 0)
                    ? (float)Math.Min(MyRenderConstants.MAX_GPU_OCCLUSION_QUERY_DISTANCE, desc.MaxDistance)
                    : MyRenderConstants.MAX_GPU_OCCLUSION_QUERY_DISTANCE;

                m_flares.Data[flareId.Index] = desc;
            }
            else if (flareId != FlareId.NULL)
            {
                m_flares.Free(flareId.Index);
                flareId = FlareId.NULL;
            }
            return(flareId);
        }