Ensure that the default vertex colors are not black for undefined material maps

This commit is contained in:
Jeff Myers 2024-03-05 08:41:07 -08:00
parent c7b362d19d
commit dfdebe198d

View File

@ -5811,6 +5811,13 @@ static Model LoadM3D(const char *fileName)
// M3D specs only consider vertex colors if no material is provided, however raylib uses both and mixes the colors // M3D specs only consider vertex colors if no material is provided, however raylib uses both and mixes the colors
if ((mi == M3D_UNDEF) || vcolor) model.meshes[k].colors = RL_CALLOC(model.meshes[k].vertexCount * 4, sizeof(unsigned char)); if ((mi == M3D_UNDEF) || vcolor) model.meshes[k].colors = RL_CALLOC(model.meshes[k].vertexCount * 4, sizeof(unsigned char));
// If no map is provided and we allocated vertex colors, set them too white
if ((mi == M3D_UNDEF) && model.meshes[k].colors != NULL)
{
for (int c = 0; c < model.meshes[k].vertexCount * 4; c++)
model.meshes[k].colors[c] = 255;
}
if (m3d->numbone && m3d->numskin) if (m3d->numbone && m3d->numskin)
{ {
model.meshes[k].boneIds = (unsigned char *)RL_CALLOC(model.meshes[k].vertexCount*4, sizeof(unsigned char)); model.meshes[k].boneIds = (unsigned char *)RL_CALLOC(model.meshes[k].vertexCount*4, sizeof(unsigned char));