/// <summary> /// Clears all subscriptions on the given view subset. /// Only for internal use.. this method gets called when a view is deregistered. /// </summary> internal void ClearSubscriptionsWithoutUnsubscribeCall(ViewRelatedSceneLayerSubset layerViewSubset, RenderPassSubscription subscription) { // Get the subscription list // (may be null if object was removed from the layer) List <RenderPassSubscription> subscriptionList = m_viewRelatedSubscriptions[layerViewSubset.ViewIndex]; if (subscriptionList == null) { return; } // Remove the given entry from subscription list int subscriptionCount = subscriptionList.Count; int entryCount = 0; for (int loop = 0; loop < subscriptionCount; loop++) { RenderPassSubscription currentSubscriptionInfo = subscriptionList[loop]; if ((currentSubscriptionInfo.SceneObject == subscription.SceneObject) && (currentSubscriptionInfo.RenderPass == subscription.RenderPass) && (currentSubscriptionInfo.RenderMethod == subscription.RenderMethod)) { subscriptionList.RemoveAt(loop); loop--; subscriptionCount--; entryCount++; } } if (entryCount > 1) { throw new SeeingSharpGraphicsException("Inconsistency: Too much subscriptions for SceneObject detected!"); } }
/// <summary> /// Deregisters a layer view subset with the given index. /// </summary> /// <param name="layerViewSubset">The layer view subset to deregister.</param> internal void DeregisterLayerViewSubset(ViewRelatedSceneLayerSubset layerViewSubset) { if (m_viewRelatedSubscriptions.HasObjectAt(layerViewSubset.ViewIndex)) { m_viewRelatedSubscriptions.RemoveObject(layerViewSubset.ViewIndex); } }
/// <summary> /// Updades all subscription info for given subscription row. /// This method is needed because 'RenderPassSubscription" is a struct and values are changed by host object. /// </summary> /// <param name="newSubscriptionInfo">The subscription information passed by host object.</param> /// <param name="layerViewSubset">The host object.</param> internal void UpdateSubscription(RenderPassSubscription newSubscriptionInfo, ViewRelatedSceneLayerSubset layerViewSubset) { // Get the subscription list // (may be null if object was removed from the layer) List <RenderPassSubscription> subscriptionList = m_viewRelatedSubscriptions[layerViewSubset.ViewIndex]; if (subscriptionList == null) { return; } // Update the corresponding subscription entry int subscriptionCount = subscriptionList.Count; int entryCount = 0; for (int loop = 0; loop < subscriptionCount; loop++) { RenderPassSubscription currentSubscriptionInfo = subscriptionList[loop]; if ((currentSubscriptionInfo.SceneObject == newSubscriptionInfo.SceneObject) && (currentSubscriptionInfo.RenderPass == newSubscriptionInfo.RenderPass) && (currentSubscriptionInfo.RenderMethod == newSubscriptionInfo.RenderMethod)) { subscriptionList[loop] = newSubscriptionInfo; entryCount++; } } if (entryCount > 1) { throw new SeeingSharpGraphicsException("Inconsistency: Too much subscriptions for SceneObject detected!"); } }
/// <summary> /// Subscribes on the given render pass with the given action. /// </summary> /// <param name="renderPass">The render pass to which to subscribe.</param> /// <param name="renderAction">The action which performs rendering.</param> /// <param name="layerViewSubset">The ViewRelatedSceneLayerSubset to which to subscribe.</param> /// <param name="zOrder">The z order if sorting is enabled for this pass (default = 0).</param> protected internal void SubscribeToPass( RenderPassInfo renderPass, ViewRelatedSceneLayerSubset layerViewSubset, Action <RenderState> renderAction, int zOrder = 0) { List <RenderPassSubscription> subscriptionList = m_viewRelatedSubscriptions[layerViewSubset.ViewIndex]; subscriptionList.Add(layerViewSubset.SubscribeForPass(renderPass, this, renderAction, zOrder)); }
/// <summary> /// Unsubscribes from all passes. /// </summary> protected internal void UnsubsribeFromAllPasses(ViewRelatedSceneLayerSubset layerViewSubset) { List <RenderPassSubscription> subscriptionList = m_viewRelatedSubscriptions[layerViewSubset.ViewIndex]; for (int loop = 0; loop < subscriptionList.Count; loop++) { subscriptionList[loop].Unsubscribe(); } subscriptionList.Clear(); }
/// <summary> /// Registers the given view on this layer. /// </summary> internal void RegisterView(int viewIndex, ViewInformation viewInformation, ResourceDictionary resourceDictionary) { ViewRelatedSceneLayerSubset newLayerViewSubset = new ViewRelatedSceneLayerSubset(this, viewInformation, resourceDictionary, viewIndex); m_viewSubsets.AddObject( newLayerViewSubset, viewIndex); newLayerViewSubset.RegisterObjectRange(m_sceneObjects.ToArray()); }
/// <summary> /// Renders the 2D overlay to the given context. /// </summary> /// <param name="renderState">State of the render.</param> internal void Render2DOverlay(RenderState renderState) { //Delegate render call to corresponding view subset ViewRelatedSceneLayerSubset viewSubset = m_viewSubsets[renderState.ViewIndex]; if (viewSubset != null) { m_viewSubsets[renderState.ViewIndex].Render2DOverlay(renderState); } }
/// <summary> /// Initializes a new instance of the <see cref="RenderPassSubscription" /> struct. /// </summary> /// <param name="layerViewSubset">The ViewRelatedSceneLayerSubset object this subscription belongs to.</param> /// <param name="renderPass">The render pass on which to register.</param> /// <param name="sceneObject">The scene object which should be registered.</param> /// <param name="renderMethod">The render method which is to be registered.</param> /// <param name="zOrder">The z-order for sorting if the subsciptions of this pass get sorted by it.</param> internal RenderPassSubscription( ViewRelatedSceneLayerSubset layerViewSubset, RenderPassInfo renderPass, SceneObject sceneObject, Action <RenderState> renderMethod, int zOrder) { LayerViewSubset = layerViewSubset; RenderPass = renderPass; SceneObject = sceneObject; RenderMethod = renderMethod; IsSubscribed = true; SubscriptionIndex = 0; ZOrder = zOrder; }
/// <summary> /// Deregisters the given view on this layer. /// </summary> /// <param name="viewIndex">The index which this view has on the current scene.</param> /// <param name="viewInformation">The ViewInformation object describing the view.</param> internal void DeregisterView(int viewIndex, ViewInformation viewInformation) { // Dispose the layer subset (removes all its resources) ViewRelatedSceneLayerSubset viewSubset = m_viewSubsets[viewIndex]; if (viewSubset != null) { viewSubset.ClearAllSubscriptions(m_sceneObjects); viewSubset.Dispose(); } // Remote the subset m_viewSubsets.RemoveObject(viewIndex); }
/// <summary> /// Renders the scene to the given context. /// </summary> internal void Render(RenderState renderState) { if (!this.IsRenderingEnabled) { return; } //Delegate render call to corresponding view subset ViewRelatedSceneLayerSubset viewSubset = m_viewSubsets[renderState.ViewIndex]; if (viewSubset != null) { m_viewSubsets[renderState.ViewIndex].Render(renderState); } }
/// <summary> /// Counts all render pass subscriptions related to the given view subset. /// </summary> /// <param name="layerViewSubset">The layer view subset.</param> protected internal int CountRenderPassSubscriptions(ViewRelatedSceneLayerSubset layerViewSubset) { return(m_viewRelatedSubscriptions[layerViewSubset.ViewIndex].Count); }
/// <summary> /// Clears all subscriptions on the given view subset. /// Only for internal use.. this method gets called when a view is deregistered. /// </summary> /// <param name="layerViewSubset">The view subset from which to clear all subscription entries.</param> internal void ClearSubscriptionsWithoutUnsubscribeCall(ViewRelatedSceneLayerSubset layerViewSubset) { List <RenderPassSubscription> subscriptionList = m_viewRelatedSubscriptions[layerViewSubset.ViewIndex]; subscriptionList.Clear(); }
/// <summary> /// Unsubscribes from the given render pass. /// </summary> protected internal void UnsubscribeFromPass(RenderPassInfo passInfo, UpdateState updateState, ViewRelatedSceneLayerSubset layerViewSubset) { // Get the subscription list // (may be null if object was removed from the layer) List <RenderPassSubscription> subscriptionList = m_viewRelatedSubscriptions[layerViewSubset.ViewIndex]; if (subscriptionList == null) { return; } // Perform unsubscribe int entryCount = 0; for (int loop = 0; loop < subscriptionList.Count; loop++) { if (subscriptionList[loop].RenderPass == passInfo) { subscriptionList[loop].Unsubscribe(); subscriptionList.RemoveAt(loop); entryCount++; loop--; } } if (entryCount > 1) { throw new SeeingSharpGraphicsException("Inconsistency: Too much subscriptions for SceneObject detected!"); } if (entryCount == 0) { throw new SeeingSharpGraphicsException("Inconsistency: No subscription found on SceneObject!"); } }
/// <summary> /// Updates this object for the given view. /// </summary> /// <param name="updateState">Current state of the update pass.</param> /// <param name="layerViewSubset">The layer view subset wich called this update method.</param> protected abstract void UpdateForViewInternal(SceneRelatedUpdateState updateState, ViewRelatedSceneLayerSubset layerViewSubset);
/// <summary> /// Updates this object for the given view. /// </summary> /// <param name="updateState">Current state of the update pass.</param> /// <param name="layerViewSubset">The layer view subset wich called this update method.</param> internal void UpdateForView(SceneRelatedUpdateState updateState, ViewRelatedSceneLayerSubset layerViewSubset) { UpdateForViewInternal(updateState, layerViewSubset); }
protected sealed override void UpdateForViewInternal(SceneRelatedUpdateState updateState, ViewRelatedSceneLayerSubset layerViewSubset) { // No resources, so nothing to be done }
/// <summary> /// Updates this object for the given view. /// </summary> /// <param name="updateState">Current state of the update pass.</param> /// <param name="layerViewSubset">The layer view subset wich called this update method.</param> protected override void UpdateForViewInternal(SceneRelatedUpdateState updateState, ViewRelatedSceneLayerSubset layerViewSubset) { }
/// <summary> /// Registers a layer view subset with the given index. /// </summary> /// <param name="layerViewSubset">The layer view subset to register.</param> internal void RegisterLayerViewSubset(ViewRelatedSceneLayerSubset layerViewSubset) { m_viewRelatedSubscriptions.AddObject(new List <RenderPassSubscription>(), layerViewSubset.ViewIndex); }