Validation errors are very generic
prideout opened this issue · comments
I have a tentative commit that addresses this issue, just thought I'd post an issue before posting the PR.
In Filament we use cgltf_validate
in debug builds and it's great for triaging glTF issues that are actually issues in the asset rather than an issue with Filament.
It would be nice if cgltf_validate
printed a unique message for each type of failure but I don't think we should bloat the cgltf library with lots of strings that need to be maintained.
The solution I have adds a little macro that lets you optionally trigger an assert when a validation failure occurs. If the macro is defined to assert(false)
, then you'll see a line number that tells you what specific condition triggered the failure.
For example, my PR will change cgltf_validate
from this:
if (mc->mode == cgltf_meshopt_compression_mode_triangles && mc->count % 3 != 0)
{
return cgltf_result_invalid_gltf;
}
to this:
CGLTF_ASSERT_IF(mc->mode == cgltf_meshopt_compression_mode_triangles && mc->count % 3 != 0, cgltf_result_invalid_gltf);
By default the behavior will be exactly as it is today, but users will now have a compile-time option that adds in an assert.