コード例 #1
0
        private static void LogModel(MyAssetMesh mesh, string assetName)
        {
            var fsPath = Path.IsPathRooted(assetName) ? assetName : Path.Combine(MyFileSystem.ContentPath, assetName);
            var fi     = new FileInfo(fsPath);

            if (MyPerformanceCounter.LogFiles)
            {
                MyPerformanceCounter.PerAppLifetime.LoadedModelFiles.Add(fsPath);
            }

            if (!fi.Exists)
            {
                return;
            }

            MyPerformanceCounter.PerAppLifetime.MyModelsFilesSize += (int)fi.Length;
            MyPerformanceCounter.PerAppLifetime.ModelsCount++;
            foreach (var lod in mesh.LODs)
            {
                foreach (var vb in lod.m_meshInfo.VB)
                {
                    MyPerformanceCounter.PerAppLifetime.ModelVertexBuffersSize += vb.ByteSize;
                    MyPerformanceCounter.PerAppLifetime.MyModelsVertexesCount  += vb.Capacity;
                }

                MyPerformanceCounter.PerAppLifetime.ModelIndexBuffersSize += lod.m_meshInfo.IB.ByteSize;
            }
        }
コード例 #2
0
        internal static MyMaterialProxy Create(MyMaterialDescription?desc, string materialTag)
        {
            int key = desc.HasValue ? desc.Value.CalculateKey() : 0;

            key = MyHashHelper.Combine(key, materialTag.GetHashCode());

            var proxy = m_proxies.SetDefault(key, null);

            if (proxy != null)
            {
                return(proxy);
            }

            proxy = MyShaderMaterialReflection.CreateBindings(materialTag);

            if (desc == null)
            {
                // TODO: change later
                desc = MyAssetMesh.GetDebugMaterialDescriptor();
            }

            LoadTextures(proxy, desc.Value);

            proxy.RecalcConstantsHash();

            m_proxies[key]     = proxy;
            m_descriptors[key] = desc.Value;

            m_reverseMapping[proxy] = desc.Value;

            return(proxy);
        }
コード例 #3
0
        internal static MyAssetMesh GetMaterials(string assetName)
        {
            var model = m_meshes.Get(assetName);

            if (model != null)
            {
                return(model);
            }

            MyAssetMesh.LoadMaterials(assetName);

            return(model);
        }
コード例 #4
0
        internal static MyAssetMesh GetModel(string assetName)
        {
            var model = m_meshes.Get(assetName);

            if (model != null)
            {
                return(model);
            }

            model = new MyAssetMesh(assetName);
            model.LoadAsset();

            if (LOG_MESH_STATISTICS)
            {
                model.DebugWriteInfo();
            }

            m_meshes[assetName] = model;
            LogModel(model, assetName);
            return(model);
        }
コード例 #5
0
ファイル: MyRenderMesh.cs プロジェクト: rem02/SpaceEngineers
        private static void LogModel(MyAssetMesh mesh, string assetName)
        {
            var fsPath = Path.IsPathRooted(assetName) ? assetName : Path.Combine(MyFileSystem.ContentPath, assetName);
            var fi = new FileInfo(fsPath);
            if (MyPerformanceCounter.LogFiles)
                MyPerformanceCounter.PerAppLifetime.LoadedModelFiles.Add(fsPath);

            if (!fi.Exists)
                return;

            MyPerformanceCounter.PerAppLifetime.MyModelsFilesSize += (int)fi.Length;
            MyPerformanceCounter.PerAppLifetime.ModelsCount++;
            foreach(var lod in mesh.LODs)
            {
                foreach (var vb in lod.m_meshInfo.VB)
                {
                    MyPerformanceCounter.PerAppLifetime.ModelVertexBuffersSize += vb.ByteSize;
                    MyPerformanceCounter.PerAppLifetime.MyModelsVertexesCount += vb.Capacity;
                }

                MyPerformanceCounter.PerAppLifetime.ModelIndexBuffersSize += lod.m_meshInfo.IB.ByteSize;
            }
        }
コード例 #6
0
ファイル: MyRenderMesh.cs プロジェクト: rem02/SpaceEngineers
        internal static MyAssetMesh GetModel(string assetName)
        {
            var model = m_meshes.Get(assetName);
            if(model != null)
            {
                return model;
            }

            model = new MyAssetMesh(assetName);
            model.LoadAsset();

            if (LOG_MESH_STATISTICS)
            {
                model.DebugWriteInfo();
            }

            m_meshes[assetName] = model;
            LogModel(model, assetName);
            return model;
        }