From 8f491d88ddfa3ec56dbe2e2eca29528c4d7e8972 Mon Sep 17 00:00:00 2001 From: Hristo Stamenov Date: Thu, 17 Jun 2021 10:44:28 +0300 Subject: [PATCH] Use animation vertices on initial load if possible. --- src/models.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/models.c b/src/models.c index 09cd431ce..1936b39dd 100644 --- a/src/models.c +++ b/src/models.c @@ -844,7 +844,8 @@ void UploadMesh(Mesh *mesh, bool dynamic) // NOTE: Attributes must be uploaded considering default locations points // Enable vertex attributes: position (shader-location = 0) - mesh->vboId[0] = rlLoadVertexBuffer(mesh->vertices, mesh->vertexCount*3*sizeof(float), dynamic); + void* vertices = mesh->animVertices != NULL ? mesh->animVertices : mesh->vertices; + mesh->vboId[0] = rlLoadVertexBuffer(vertices, mesh->vertexCount*3*sizeof(float), dynamic); rlSetVertexAttribute(0, 3, RL_FLOAT, 0, 0, 0); rlEnableVertexAttribute(0); @@ -856,7 +857,8 @@ void UploadMesh(Mesh *mesh, bool dynamic) if (mesh->normals != NULL) { // Enable vertex attributes: normals (shader-location = 2) - mesh->vboId[2] = rlLoadVertexBuffer(mesh->normals, mesh->vertexCount*3*sizeof(float), dynamic); + void* normals = mesh->animNormals != NULL ? mesh->animNormals : mesh->vertices; + mesh->vboId[2] = rlLoadVertexBuffer(normals, mesh->vertexCount*3*sizeof(float), dynamic); rlSetVertexAttribute(2, 3, RL_FLOAT, 0, 0, 0); rlEnableVertexAttribute(2); }