Fixes a bug where gltf textures get the wrong file location if there's no directory separator present in the file or asset path.
@@ -109,7 +109,11 @@ void gltf_imagename(cgltf_data *data, cgltf_image *image, const char *filename,
char *last1 = strrchr((char *)filename, '/');
char *last2 = strrchr((char *)filename, '\\');
char *last = max(last1, last2);
+ if (last == nullptr) {
+ sprintf_s(dest, dest_length, "%s", image->uri);
+ } else {
sprintf_s(dest, dest_length, "%.*s/%s", (int)(last - filename), filename, image->uri);
+ }
return;
}
