Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions OpenKh.Command.MapGen/Models/MaterialDef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ public class MaterialDef
/// </summary>
public bool normal { get; set; } = false;

/// <summary>
/// Explicit build priority. Lower number = built first.
/// Meshes with no priority set are appended after all prioritized meshes in their original order.
/// </summary>
public int? priority { get; set; }

public static MaterialDef CreateFallbackFor(string name) =>
new MaterialDef
{
Expand Down
11 changes: 11 additions & 0 deletions OpenKh.Command.MapGen/Utils/MapBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ public MapBuilder(string modelFile, MapGenConfig config, Func<MaterialDef, Imgd>

var singleFaces = ConvertModelIntoFaces(modelFile, config);

// Apply explicit material priority ordering from mapdef.yml.
// Faces whose material has a priority set come first (ascending),
// followed by unprioritized faces in their original order.
singleFaces = singleFaces
.Select((face, originalIndex) => (face, originalIndex))
.OrderBy(x => x.face.matDef.priority.HasValue ? 0 : 1)
.ThenBy(x => x.face.matDef.priority ?? 0)
.ThenBy(x => x.originalIndex)
.Select(x => x.face)
.ToList();

logger.Debug($"Loading process has done.");

logger.Debug($"Starting MapBuilding.");
Expand Down
Loading