/// <inheritdoc/> protected override void OnEntityRemoved(Entity entity, EntityLightShadow data) { if (ManageShadows && data.ShadowMap != null) { InternalShadowMaps.Remove(data.ShadowMap); List <ShadowMap> shadowMaps = null; if (!texturesDefault.TryGetValue(data.ShadowMap.Texture, out shadowMaps)) { texturesVsm.TryGetValue(data.ShadowMap.Texture, out shadowMaps); } if (shadowMaps == null) { throw new Exception("Untracked shadow map texture"); } shadowMaps.Remove(data.ShadowMap); // if no more shadow maps on this texture, delete it. if (shadowMaps.Count == 0) { InternalShadowMapTextures.Remove(data.ShadowMap.Texture); Utilities.Dispose(ref data.ShadowMap.Texture.ShadowMapDepthTexture); Utilities.Dispose(ref data.ShadowMap.Texture.ShadowMapTargetTexture); Utilities.Dispose(ref data.ShadowMap.Texture.IntermediateBlurTexture); if (!texturesDefault.Remove(data.ShadowMap.Texture)) { texturesVsm.Remove(data.ShadowMap.Texture); } } } base.OnEntityRemoved(entity, data); }
private void RemoveShadowMap(EntityLightShadow data) { InternalShadowMaps.Remove(data.ShadowMap); InternalActiveShadowMaps.Remove(data.ShadowMap); data.ShadowMap = null; }