summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRay <[email protected]>2023-02-12 12:10:01 +0100
committerRay <[email protected]>2023-02-12 12:10:01 +0100
commit21961a786df76a86302942f3da8f7c08b7f31863 (patch)
treeaaf64d3c500ab0175647e3c67e327557576f8147 /src
parent4647441ad81848334ff2827015a9e337a6a0393a (diff)
downloadraylib-21961a786df76a86302942f3da8f7c08b7f31863.tar.gz
raylib-21961a786df76a86302942f3da8f7c08b7f31863.zip
REVIEWED: Vertex colors support on M3D loading #2878
Diffstat (limited to 'src')
-rw-r--r--src/rmodels.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/rmodels.c b/src/rmodels.c
index 893c031e..2fd2d5a4 100644
--- a/src/rmodels.c
+++ b/src/rmodels.c
@@ -5633,8 +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));
- // If color map is provided, we allocate storage for vertex colors
- if (m3d->cmap != NULL) model.meshes[k].colors = RL_CALLOC(model.meshes[k].vertexCount*4, sizeof(unsigned char));
+ // If no map is provided, we allocate storage for vertex colors
+ // M3D specs only consider vertex colors if no material is provided
+ if (mi != M3D_UNDEF) model.meshes[k].colors = RL_CALLOC(model.meshes[k].vertexCount*4, sizeof(unsigned char));
if (m3d->numbone && m3d->numskin)
{