Пример #1
0
        public void DispatchCullPasses(MyCpuFrustumCullPasses cpuFrustumCullPasses, List <MyInstanceComponent>[] out_visibleInstances)
        {
            for (int frustumQueryIndex = 1; frustumQueryIndex < cpuFrustumCullPasses.Count; ++frustumQueryIndex)
            {
                var cullWork = MyObjectPoolManager.Allocate <MyCpuFrustumCullingWork>();
                m_tmpCullingWork.Add(cullWork);
                int passId = cpuFrustumCullPasses.At(frustumQueryIndex).PassId;
                cullWork.Init(cpuFrustumCullPasses.At(frustumQueryIndex), MyManagers.HierarchicalCulledEntities.AabbTree,
                              out_visibleInstances[passId]);
                m_tmpParallelTasks.Add(Parallel.Start(cullWork));
            }

            if (cpuFrustumCullPasses.Count != 0)
            {
                ProfilerShort.Begin("Culling in the render thread");
                var cullWork = MyObjectPoolManager.Allocate <MyCpuFrustumCullingWork>();
                m_tmpCullingWork.Add(cullWork);
                int passId = cpuFrustumCullPasses.At(0).PassId;
                cullWork.Init(cpuFrustumCullPasses.At(0), MyManagers.HierarchicalCulledEntities.AabbTree,
                              out_visibleInstances[passId]);
                cullWork.DoWork();
                ProfilerShort.End();
            }

            ProfilerShort.Begin("WaitingForOtherTasks");
            foreach (Task cullingTask in m_tmpParallelTasks)
            {
                cullingTask.Wait();
            }
            m_tmpParallelTasks.Clear();
            ProfilerShort.End();

            foreach (MyCpuFrustumCullingWork cullWork in m_tmpCullingWork)
            {
                MyObjectPoolManager.Deallocate(cullWork);
            }
            m_tmpCullingWork.Clear();
        }
Пример #2
0
        void SetSingleInstanceTransformStrategy()
        {
            if (m_transformStrategy is MySingleTransformStrategy)
            {
                return;
            }

            ITransformStrategy oldStrategy = m_transformStrategy;

            m_transformStrategy = MyObjectPoolManager.Allocate <MySingleTransformStrategy>();
            m_transformStrategy.SetCoreMatrix(m_transformStrategy.GetCoreMatrixD());
            if (oldStrategy is MyMultiTransformStrategy)
            {
                MyObjectPoolManager.Deallocate((MyMultiTransformStrategy)oldStrategy);
            }
            else if (oldStrategy is MySingleTransformStrategy)
            {
                MyObjectPoolManager.Deallocate((MySingleTransformStrategy)oldStrategy);
            }
            else
            {
                MyRenderProxy.Error("Unknown class");
            }
        }