internal static void UpdateSpotlight(LightId light, bool enabled, Vector3 direction, float range, float apertureCos, Vector3 up, Vector3 color, float falloff, float glossFactor, 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].GlossFactor = glossFactor; Spotlights[light.Index].Color = color; Spotlights[light.Index].ReflectorTexture = reflectorTexture; var proxy = Spotlights[light.Index].BvhProxyId; var positionDifference = Vector3D.RectangularDistance(ref Spotlights[light.Index].LastBvhUpdatePosition, ref Lights.Data[light.Index].SpotPosition); bool dirty = (enabled && ((proxy == -1) || (positionDifference > MOVE_TOLERANCE || aabbChanged))) || (!enabled && proxy != -1); if (dirty) { DirtySpotlights.Add(light); } else { DirtySpotlights.Remove(light); } }
internal static void UpdateGlare(LightId light, MyGlareDesc desc) { if (desc.Enabled) { var gid = light.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; Glares[light] = desc; } else { Glares.Remove(light); } }