Skip to content

Commit 84f73f7

Browse files
Merge pull request #8 from LagoLunatic/material-underscores
Merged from LagoLunatic: Fixed materials not converting correctly if they have underscores in their name
2 parents 1b4472d + e0dba14 commit 84f73f7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

SuperBMDLib/source/BMD/MAT3.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -508,20 +508,20 @@ private void LoadFromJson(Assimp.Scene scene, TEX1 textures, SHP1 shapes, string
508508
Assimp.Material meshMat = scene.Materials[scene.Meshes[i].MaterialIndex];
509509
string test = meshMat.Name.Replace("-material", "");
510510

511-
if (test.Contains("_"))
511+
List<string> materialNamesWithoutParentheses = new List<string>();
512+
foreach (string materialName in m_MaterialNames)
512513
{
513-
string[] without_underscores = test.Split('_');
514-
test = $"{ without_underscores[0] }({ without_underscores[1] })";
514+
materialNamesWithoutParentheses.Add(materialName.Replace("(", "_").Replace(")", "_"));
515515
}
516516

517-
while (!m_MaterialNames.Contains(test))
517+
while (!materialNamesWithoutParentheses.Contains(test))
518518
{
519519
test = test.Substring(1);
520520
}
521521

522522
for (int j = 0; j < m_Materials.Count; j++)
523523
{
524-
if (test == m_MaterialNames[j])
524+
if (test == materialNamesWithoutParentheses[j])
525525
{
526526
scene.Meshes[i].MaterialIndex = j;
527527
break;

0 commit comments

Comments
 (0)