From fd5e457bb49b4a87ca9dc9880f3b8df1683a594d Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sun, 11 Mar 2018 10:41:49 +0100 Subject: [PATCH] Correct issue with triangleCount --- src/models.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/models.c b/src/models.c index 8e9a6586..47302a1d 100644 --- a/src/models.c +++ b/src/models.c @@ -1179,9 +1179,9 @@ Mesh GenMeshHeightmap(Image heightmap, Vector3 size) Color *pixels = GetImageData(heightmap); // NOTE: One vertex per pixel - int triangleCount = (mapX-1)*(mapZ-1)*2; // One quad every four pixels + mesh.triangleCount = (mapX-1)*(mapZ-1)*2; // One quad every four pixels - mesh.vertexCount = triangleCount*3; + mesh.vertexCount = mesh.triangleCount*3; mesh.vertices = (float *)malloc(mesh.vertexCount*3*sizeof(float)); mesh.normals = (float *)malloc(mesh.vertexCount*3*sizeof(float)); @@ -1584,6 +1584,7 @@ Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize) // Move data from mapVertices temp arays to vertices float array mesh.vertexCount = vCounter; + mesh.triangleCount = vCounter/3; mesh.vertices = (float *)malloc(mesh.vertexCount*3*sizeof(float)); mesh.normals = (float *)malloc(mesh.vertexCount*3*sizeof(float));