Example #1
0
        public override void LoadData()
        {
            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyVoxelPrecalc.LoadData");

            MySandboxGame.Log.WriteLine("MyVoxelPrecalc.LoadData() - START");
            MySandboxGame.Log.IncreaseIndent();

            Type mesherType = typeof(MyMarchingCubesMesher);

            Debug.Assert(MyPlugins.Loaded);
            if (MyFakes.ENABLE_ISO_MESHER_FROM_PLUGIN && MyPlugins.PluginAssembly != null)
            {
                var interfaceType = typeof(IMyIsoMesher);
                foreach (var type in MyPlugins.PluginAssembly.GetTypes())
                {
                    if (interfaceType.IsAssignableFrom(type))
                    {
                        mesherType = type;
                        break;
                    }
                }
            }

            //  For calculating on main thread
            m_singleCoreTask = Activator.CreateInstance(mesherType) as IMyIsoMesher;

            Tasks = new ConcurrentQueue <MyVoxelPrecalcTaskItem>();
            if (MySandboxGame.NumberOfCores > 1)
            {
                m_tasks       = new Task[MySandboxGame.NumberOfCores];
                m_precalWorks = new MyVoxelPrecalcWork[MySandboxGame.NumberOfCores];

                for (int i = 0; i < MySandboxGame.NumberOfCores; i++)
                {
                    m_precalWorks[i] = new MyVoxelPrecalcWork(Activator.CreateInstance(mesherType) as IMyIsoMesher);
                }
            }

            MySandboxGame.Log.DecreaseIndent();
            MySandboxGame.Log.WriteLine("MyVoxelPrecalc.LoadData() - END");
            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
        }
 public MyVoxelPrecalcWork(IMyIsoMesher mesher)
 {
     m_mesher = mesher;
 }
 public MyVoxelPrecalcWork(IMyIsoMesher mesher)
 {
     m_mesher = mesher;
 }
        public override void LoadData()
        {
            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyVoxelPrecalc.LoadData");

            MySandboxGame.Log.WriteLine("MyVoxelPrecalc.LoadData() - START");
            MySandboxGame.Log.IncreaseIndent();

            Type mesherType = typeof(MyMarchingCubesMesher);
            Debug.Assert(MyPlugins.Loaded);
            if (MyFakes.ENABLE_ISO_MESHER_FROM_PLUGIN && MyPlugins.PluginAssembly != null)
            {
                var interfaceType = typeof(IMyIsoMesher);
                foreach (var type in MyPlugins.PluginAssembly.GetTypes())
                {
                    if (interfaceType.IsAssignableFrom(type))
                    {
                        mesherType = type;
                        break;
                    }
                }
            }

            //  For calculating on main thread
            m_singleCoreTask = Activator.CreateInstance(mesherType) as IMyIsoMesher;

            Tasks = new ConcurrentQueue<MyVoxelPrecalcTaskItem>();
            if (MySandboxGame.NumberOfCores > 1)
            {
                m_tasks = new Task[MySandboxGame.NumberOfCores];
                m_precalWorks = new MyVoxelPrecalcWork[MySandboxGame.NumberOfCores];

                for (int i = 0; i < MySandboxGame.NumberOfCores; i++)
                    m_precalWorks[i] = new MyVoxelPrecalcWork(Activator.CreateInstance(mesherType) as IMyIsoMesher);
            }

            MySandboxGame.Log.DecreaseIndent();
            MySandboxGame.Log.WriteLine("MyVoxelPrecalc.LoadData() - END");
            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
        }
 protected override void UnloadData()
 {
     m_precalWorks = null;
     m_singleCoreTask = null;
 }
Example #6
0
 protected override void UnloadData()
 {
     m_precalWorks    = null;
     m_singleCoreTask = null;
 }