Ignore case when checking texture naming convention

This commit is contained in:
sergeypdev 2024-02-28 17:26:14 +04:00
parent 8fa5c63039
commit aec4a4a882
2 changed files with 10 additions and 4 deletions

View File

@ -275,10 +275,10 @@ export fn game_init(global_allocator: *std.mem.Allocator) void {
}
}
const scene = globals.g_mem.world.createScene(globals.g_assetman.resolveScene(a.Scenes.scifi_helmet.SciFiHelmet.scene));
const scene = globals.g_mem.world.createScene(globals.g_assetman.resolveScene(a.Scenes.amd_ryzen_9.scene));
const ent = globals.g_mem.world.getEntity(scene) orelse @panic("WTF");
ent.data.transform.pos = Vec3.new(0, 1, 0);
// ent.data.transform.scale = Vec3.one().scale(4);
ent.data.transform.scale = Vec3.one().scale(0.2);
}
export fn game_update() bool {

View File

@ -552,13 +552,18 @@ fn processTextureFromFile(allocator: std.mem.Allocator, input: []const u8, outpu
/// Using naming conventions
fn guessTextureTypeFromName(name: []const u8) TextureType {
const stem = std.fs.path.stem(name);
const sub_ext = std.fs.path.extension(stem);
var buf: [std.fs.MAX_NAME_BYTES]u8 = undefined;
const lower_stem = std.ascii.lowerString(&buf, stem);
const sub_ext = std.fs.path.extension(lower_stem);
if (std.mem.eql(u8, sub_ext, ".norm")) {
return .Normal;
}
if (std.mem.endsWith(u8, stem, "Normal")) {
if (std.mem.endsWith(u8, lower_stem, "normal")) {
return .Normal;
}
if (std.mem.endsWith(u8, lower_stem, "metallicroughness")) {
return .MetallicRoughness;
}
return .Color;
}
@ -566,6 +571,7 @@ fn guessTextureTypeFromName(name: []const u8) TextureType {
const TextureType = enum {
Color,
Normal,
MetallicRoughness,
HDR,
};