internal static MyMeshMaterialId GetMaterialId(ref MyMeshMaterialInfo desc, string assetFile = null) { var rk = CalculateRK(ref desc); if (!MaterialRkIndex.ContainsKey(rk)) { var id = MaterialRkIndex[rk] = new MyMeshMaterialId { Index = MaterialsPool.Allocate() }; desc.Id = id; desc.RepresentationKey = rk; MaterialsPool.Data[id.Index] = desc; MaterialProxyIndex[id] = MyMaterials1.AllocateProxy(); MaterialQueryResourcesTable.Add(id); MaterialNameIndex[desc.Name] = id; if (MERGABLE_MATERIAL_NAMES.Contains(desc.Name)) { MergableRKs.Add(desc.RepresentationKey); } else if (assetFile != null) { VRageRender.MyRender11.Log.WriteLine(String.Format("Asset {0} tries to overrwrite material {1} with different textures", assetFile, desc.Name.ToString())); } return(id); } return(MaterialRkIndex[rk]); }
internal static MyMeshMaterialId GetMaterialId(ref MyMeshMaterialInfo desc) { var rk = CalculateRK(ref desc); if (!MaterialRkIndex.ContainsKey(rk)) { var id = MaterialRkIndex[rk] = new MyMeshMaterialId { Index = MaterialsPool.Allocate() }; desc.Id = id; desc.RepresentationKey = rk; MaterialsPool.Data[id.Index] = desc; MaterialProxyIndex[id] = MyMaterials1.AllocateProxy(); MaterialQueryResourcesTable.Add(id); var nameIndex = desc.Name; if (MERGABLE_MATERIAL_NAMES.Contains(nameIndex)) { MergableRKs.Add(desc.RepresentationKey); } MaterialNameIndex[nameIndex] = id; return(id); } return(MaterialRkIndex[rk]); }
internal static MyMaterialProxyId GetMaterialProxyId(MyVoxelMaterialTriple materialSet) { if (!MaterialProxyTripleIndex.ContainsKey(materialSet)) { var matId = MaterialProxyTripleIndex[materialSet] = MyMaterials1.AllocateProxy(); MyMaterials1.ProxyPool.Data[matId.Index] = CreateProxy(materialSet); } return(MaterialProxyTripleIndex[materialSet]); }
internal static MyMaterialProxyId GetMaterialProxyId(MyVoxelMaterialTriple materialSet) { MyMaterialProxyId pid; if (!MaterialProxyTripleIndex.TryGetValue(materialSet, out pid)) { pid = MaterialProxyTripleIndex[materialSet] = MyMaterials1.AllocateProxy(); MyMaterials1.ProxyPool.Data[pid.Index] = CreateProxy(materialSet); } return(pid); }