-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some update to gltf loading #4373
Conversation
Only warns when there are more animations than currently implemented Allows mesh indices to be unsigned char
#define LOAD_ATTRIBUTE(accesor, numComp, dataType, dstPtr) \ | ||
#define LOAD_ATTRIBUTE(accesor, numComp, srcType, dstPtr) LOAD_ATTRIBUTE_CAST(accesor, numComp, srcType, dstPtr, srcType) | ||
|
||
#define LOAD_ATTRIBUTE_CAST(accesor, numComp, srcType, dstPtr, dstType) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@raysan5 mention in discord this would have to change to include something like
if (dstPtr == NULL) {
dstPtr = RL_ALLOC(accessor->count * numComp * sizeof(dstType);
}
This would reduce a lot of the 4-6 line if/else
branches to 1 Line
LOAD_ATTRIBUTE(accessor, numpComp, srcType, dstPtr, dstType)
As this touches every if branch in the gltf load i didn't even want to start that before checking
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I don't like that macro at all, it could be confusing and it's difficult/impossible to debug.
Said that, proposed improvement sounds good to me. Feel free to send a PR with the required updates.
@@ -5697,23 +5699,25 @@ static Model LoadGLTF(const char *fileName) | |||
// Load unsigned short data type into mesh.indices | |||
LOAD_ATTRIBUTE(attribute, 1, unsigned short, model.meshes[meshIndex].indices) | |||
} | |||
else if (attribute->component_type == cgltf_component_type_r_8u) | |||
{ | |||
// Init raylib mesh indices to copy glTF attribute data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With allocation inside the macro, this would be one line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
@HarryDC Thanks for the improvement! Added a note on proposed macro change: looks fine to me. |
Only warns when there are more animations than currently implemented Allows mesh indices to be unsigned char
Hit some small snags when importing from kenneys assets this is just a small update.
skins
than expected, this allows users to decide if the degraded animations work for them or notunsigned char
as an mesh index typeIt slightly changes the import macro to correctly cast to the expected type, the old macro is overloaded to maintain the old functionality