[models] Fix M3D vertex color import. (#2878)
* Fix vertex color import for .m3d * Only load vertex colors when color map and/or materials are present * Only execute when color array is present --------- Co-authored-by: Uneven Prankster <unevenprankster@pm.me>
This commit is contained in:
parent
df5a736c00
commit
929a46cbab
@ -5633,11 +5633,9 @@ static Model LoadM3D(const char *fileName)
|
||||
model.meshes[k].texcoords = (float *)RL_CALLOC(model.meshes[k].vertexCount*2, sizeof(float));
|
||||
model.meshes[k].normals = (float *)RL_CALLOC(model.meshes[k].vertexCount*3, sizeof(float));
|
||||
|
||||
// without material, we rely on vertex colors
|
||||
if (mi == M3D_UNDEF && model.meshes[k].colors == NULL)
|
||||
if(m3d->cmap != NULL || mi != M3D_UNDEF)
|
||||
{
|
||||
model.meshes[k].colors = RL_CALLOC(model.meshes[k].vertexCount*4, sizeof(unsigned char));
|
||||
for (j = 0; j < model.meshes[k].vertexCount*4; j += 4) memcpy(&model.meshes[k].colors[j], &WHITE, 4);
|
||||
}
|
||||
|
||||
if (m3d->numbone && m3d->numskin)
|
||||
@ -5662,10 +5660,10 @@ static Model LoadM3D(const char *fileName)
|
||||
model.meshes[k].vertices[l * 9 + 6] = m3d->vertex[m3d->face[i].vertex[2]].x*m3d->scale;
|
||||
model.meshes[k].vertices[l * 9 + 7] = m3d->vertex[m3d->face[i].vertex[2]].y*m3d->scale;
|
||||
model.meshes[k].vertices[l * 9 + 8] = m3d->vertex[m3d->face[i].vertex[2]].z*m3d->scale;
|
||||
|
||||
if (mi == M3D_UNDEF)
|
||||
|
||||
// without vertex color (full transparency), we use the default color
|
||||
if(model.meshes[k].colors != NULL)
|
||||
{
|
||||
// without vertex color (full transparency), we use the default color
|
||||
if (m3d->vertex[m3d->face[i].vertex[0]].color & 0xFF000000)
|
||||
memcpy(&model.meshes[k].colors[l * 12 + 0], &m3d->vertex[m3d->face[i].vertex[0]].color, 4);
|
||||
if (m3d->vertex[m3d->face[i].vertex[1]].color & 0xFF000000)
|
||||
|
Loading…
x
Reference in New Issue
Block a user