Skip to content

Commit 83735f3

Browse files
authored
Merge pull request #1252 from Kite2810/master
mapgen build mesh priority update
2 parents 80e52ec + eeafaf4 commit 83735f3

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

OpenKh.Command.MapGen/Models/MaterialDef.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ public class MaterialDef
118118
/// </summary>
119119
public bool normal { get; set; } = false;
120120

121+
/// <summary>
122+
/// Explicit build priority. Lower number = built first.
123+
/// Meshes with no priority set are appended after all prioritized meshes in their original order.
124+
/// </summary>
125+
public int? priority { get; set; }
126+
121127
public static MaterialDef CreateFallbackFor(string name) =>
122128
new MaterialDef
123129
{

OpenKh.Command.MapGen/Utils/MapBuilder.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ public MapBuilder(string modelFile, MapGenConfig config, Func<MaterialDef, Imgd>
3636

3737
var singleFaces = ConvertModelIntoFaces(modelFile, config);
3838

39+
// Apply explicit material priority ordering from mapdef.yml.
40+
// Faces whose material has a priority set come first (ascending),
41+
// followed by unprioritized faces in their original order.
42+
singleFaces = singleFaces
43+
.Select((face, originalIndex) => (face, originalIndex))
44+
.OrderBy(x => x.face.matDef.priority.HasValue ? 0 : 1)
45+
.ThenBy(x => x.face.matDef.priority ?? 0)
46+
.ThenBy(x => x.originalIndex)
47+
.Select(x => x.face)
48+
.ToList();
49+
3950
logger.Debug($"Loading process has done.");
4051

4152
logger.Debug($"Starting MapBuilding.");

0 commit comments

Comments
 (0)