コード例 #1
0
ファイル: MyLight.cs プロジェクト: caomw/SpaceEngineers
        internal static void UpdateSpotlight(LightId light, bool enabled,
                                             Vector3 direction, float range, float apertureCos, Vector3 up,
                                             Vector3 color, float falloff, TexId reflectorTexture)
        {
            var info = Spotlights[light.Index];

            var gid = light.ParentGID;

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

                Vector3.TransformNormal(ref direction, ref matrix, out direction);
                Vector3.TransformNormal(ref up, ref matrix, out up);
            }

            bool aabbChanged = info.Direction != direction || info.Range != range || info.ApertureCos != apertureCos || info.Up != up;

            Spotlights[light.Index].Enabled          = enabled;
            Spotlights[light.Index].Direction        = direction;
            Spotlights[light.Index].Range            = range;
            Spotlights[light.Index].ApertureCos      = apertureCos;
            Spotlights[light.Index].Up               = up;
            Spotlights[light.Index].Falloff          = falloff;
            Spotlights[light.Index].Color            = color;
            Spotlights[light.Index].ReflectorTexture = reflectorTexture;

            var proxy = Spotlights[light.Index].BvhProxyId;
            var positionDifference = Vector3.RectangularDistance(ref Spotlights[light.Index].LastBvhUpdatePosition, ref Lights.Data[light.Index].Position);

            bool dirty = (enabled && ((proxy == -1) || (positionDifference > MOVE_TOLERANCE || aabbChanged))) || (!enabled && proxy != -1);

            if (dirty)
            {
                DirtySpotlights.Add(light);
            }
            else
            {
                DirtySpotlights.Remove(light);
            }
        }
コード例 #2
0
ファイル: MyLight.cs プロジェクト: caomw/SpaceEngineers
        internal static void UpdatePointlight(LightId light, bool enabled, float range, Vector3 color, float falloff)
        {
            Pointlights[light.Index].Range   = range;
            Pointlights[light.Index].Color   = color;
            Pointlights[light.Index].Falloff = falloff;
            Pointlights[light.Index].Enabled = enabled;


            var proxy      = Pointlights[light.Index].BvhProxyId;
            var difference = Vector3.RectangularDistance(ref Pointlights[light.Index].LastBvhUpdatePosition, ref Lights.Data[light.Index].Position);

            bool dirty = (enabled && ((proxy == -1) || (difference > MOVE_TOLERANCE))) || (!enabled && proxy != -1);

            if (dirty)
            {
                DirtyPointlights.Add(light);
            }
            else
            {
                DirtyPointlights.Remove(light);
            }
        }