Example #1
0
 public Controller(Renderable instance, String name)
 {
     myInstance = instance;
     myName     = name;
 }
Example #2
0
 public virtual void preparePerPass(Renderable r, Pass p)
 {
 }
Example #3
0
 public virtual void preparePerView(Renderable r, View v)
 {
 }
Example #4
0
 public virtual void preparePerFrame(Renderable r)
 {
 }
Example #5
0
        public void cullRenderablesPerCamera(List <Renderable> renderables, List <View> activeViews)
        {
            //generate lists for each active camera
            initializeCamaraVisibleLists(activeViews);

#if false
            foreach (KeyValuePair <Camera, ConcurrentBag <Renderable> > cameraList in myCameraVisibles)
            {
                //breakup into several tasks
                var degreeOfParallelism = Environment.ProcessorCount;
                var tasks = new Task[degreeOfParallelism];

                for (int taskNumber = 0; taskNumber < degreeOfParallelism; taskNumber++)
                {
                    // capturing taskNumber in lambda wouldn't work correctly
                    int taskNumberCopy = taskNumber;

                    tasks[taskNumber] = Task.Factory.StartNew(
                        () =>
                    {
                        for (int i = renderables.Count * taskNumberCopy / degreeOfParallelism;
                             i < renderables.Count * (taskNumberCopy + 1) / degreeOfParallelism;
                             i++)
                        {
                            Renderable r = renderables[i];
                            if (r.isVisible(cameraList.Key) == true)
                            {
                                cameraList.Value.Add(r);
                            }
                        }
                    });
                }

                Task.WaitAll(tasks);
            }
#endif

#if false
            foreach (KeyValuePair <Camera, ConcurrentBag <Renderable> > cameraList in myCameraVisibles)
            {
                Parallel.ForEach(renderables, (r) =>
                {
                    if (r.isVisible(cameraList.Key) == true)
                    {
                        cameraList.Value.Add(r);
                    }
                });
            }
#endif

#if true
            foreach (KeyValuePair <Camera, List <Renderable> > cameraList in myCameraVisibles)
            {
                foreach (Renderable r in renderables)
                {
                    if (r.isVisible(cameraList.Key) == true)
                    {
                        cameraList.Value.Add(r);
                    }
                }
            }
#endif
        }
Example #6
0
        public void cullRenderablesPerCamera(List <Renderable> renderables, List <View> activeViews)
        {
            //generate lists for each active camera
            initializeCamaraVisibleLists(activeViews);

#if false
            foreach (KeyValuePair <Camera, List <Renderable> > cameraList in myCameraVisibles)
            {
                //breakup into several tasks
                var degreeOfParallelism = Environment.ProcessorCount;
                var tasks = new Task <List <Renderable> > [degreeOfParallelism];
                int taskRenderablesCount = renderables.Count / degreeOfParallelism;

                for (int taskNumber = 0; taskNumber < degreeOfParallelism; taskNumber++)
                {
                    //get the task number as a local up-value (closure)
                    int taskNumberCopy = taskNumber;

                    tasks[taskNumber] = Task.Factory.StartNew(
                        () =>
                    {
                        List <Renderable> ret = new List <Renderable>();
                        for (int i = 0; i < taskRenderablesCount; i++)
                        {
                            int rIdx = i + (taskRenderablesCount * taskNumberCopy);
                            if (rIdx < renderables.Count)
                            {
                                Renderable r = renderables[rIdx];
                                if (r.isVisible(cameraList.Key) == true)
                                {
                                    ret.Add(r);
                                    //cameraList.Value.Add(r);
                                }
                            }
                        }

                        return(ret);
                    });
                }

                Task.WaitAll(tasks);
                foreach (var t in tasks)
                {
                    cameraList.Value.AddRange(t.Result);
                }
            }
#endif

#if false
            foreach (KeyValuePair <Camera, ConcurrentBag <Renderable> > cameraList in myCameraVisibles)
            {
                Parallel.ForEach(renderables, (r) =>
                {
                    if (r.isVisible(cameraList.Key) == true)
                    {
                        cameraList.Value.Add(r);
                    }
                });
            }
#endif

#if true
            foreach (KeyValuePair <Camera, List <Renderable> > cameraList in myCameraVisibles)
            {
                foreach (Renderable r in renderables)
                {
                    if (r.isVisible(cameraList.Key) == true)
                    {
                        cameraList.Value.Add(r);
                    }
                }
            }
#endif
        }