protected virtual void Dispose(bool disposing) { if (disposing) { if (shadowMap != null) { shadowMap.Dispose(); shadowMap = null; } } }
/// <summary> /// Called when this scene object is removed from the scene. /// </summary> void IGraphicsObject.OnRemoved(DrawingContext context) { if (this.context == null || context != this.context) { throw new InvalidOperationException(); } if (shadowMap != null) { context.Passes.Remove(shadowMap); shadowMap.Dispose(); shadowMap = null; } this.context = null; OnRemoved(context); }
/// <summary> /// Called when this scene object is added to the scene. /// </summary> void IGraphicsObject.OnAdded(DrawingContext context) { if (this.context != null) { throw new InvalidOperationException(); } if (castShadow) { if (shadowMap == null) { shadowMap = new ShadowMap(GraphicsDevice); } context.Passes.Insert(0, shadowMap); } this.context = context; OnAdded(context); }