Beispiel #1
0
        private void RenderFeatures_CollectionChanged(object sender, ref FastTrackingCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                for (int index = 0; index < renderObjectsWithoutFeatures.Count; index++)
                {
                    var renderObject = renderObjectsWithoutFeatures[index];

                    // Try to reprocess object that didn't have any stage before
                    if (renderObject.RenderFeature == null)
                    {
                        RenderSystem.AddRenderObject(renderObject);
                        if (renderObject.RenderFeature != null)
                        {
                            renderObjectsWithoutFeatures.SwapRemoveAt(index--);
                            ReevaluateActiveRenderStages(renderObject);
                        }
                    }
                }
                break;

            case NotifyCollectionChangedAction.Remove:
                foreach (var renderObject in RenderObjects)
                {
                    if (renderObject.RenderFeature == e.Item)
                    {
                        RenderSystem.RemoveRenderObject(renderObject);
                        renderObjectsWithoutFeatures.Add(renderObject);
                    }
                }
                break;
            }
        }
Beispiel #2
0
        internal void AddRenderObject(List <RenderObject> renderObjects, RenderObject renderObject)
        {
            if (renderObject.VisibilityObjectNode != StaticObjectNodeReference.Invalid)
            {
                return;
            }

            renderObject.VisibilityObjectNode = new StaticObjectNodeReference(renderObjects.Count);

            renderObjects.Add(renderObject);

            // Resize arrays to accomodate for new data
            RenderData.PrepareDataArrays();

            RenderSystem.AddRenderObject(renderObject);
            if (renderObject.RenderFeature != null)
            {
                ReevaluateActiveRenderStages(renderObject);
            }
            else
            {
                renderObjectsWithoutFeatures.Add(renderObject);
            }
        }