コード例 #1
0
        /// <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!");
            }
        }
コード例 #2
0
 /// <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);
     }
 }
コード例 #3
0
        /// <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!");
            }
        }
コード例 #4
0
        /// <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));
        }
コード例 #5
0
        /// <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();
        }
コード例 #6
0
        /// <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());
        }
コード例 #7
0
        /// <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);
            }
        }
コード例 #8
0
 /// <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;
 }
コード例 #9
0
        /// <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);
        }
コード例 #10
0
        /// <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);
            }
        }
コード例 #11
0
 /// <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);
 }
コード例 #12
0
        /// <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();
        }
コード例 #13
0
        /// <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!");
            }
        }
コード例 #14
0
 /// <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);
コード例 #15
0
 /// <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);
 }
コード例 #16
0
 protected sealed override void UpdateForViewInternal(SceneRelatedUpdateState updateState, ViewRelatedSceneLayerSubset layerViewSubset)
 {
     // No resources, so nothing to be done
 }
コード例 #17
0
 /// <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)
 {
 }
コード例 #18
0
 /// <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);
 }