summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorkai-z99 <[email protected]>2024-06-16 01:44:31 -0700
committerGitHub <[email protected]>2024-06-16 10:44:31 +0200
commita29d334734f720431872266743ba5560870e3453 (patch)
tree04e9004c6926f4572309ed02fb692f06a64ae01f /src
parentcc40a91343b124abf87ab0ae2fae22abf1f9561b (diff)
downloadraylib-a29d334734f720431872266743ba5560870e3453.tar.gz
raylib-a29d334734f720431872266743ba5560870e3453.zip
[rmodels] Read uninitialized values in GenMeshTangents() - fix bounding case (#4066)
* fix * assert
Diffstat (limited to 'src')
-rw-r--r--src/rmodels.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/rmodels.c b/src/rmodels.c
index 5a6c6414..308fb0a7 100644
--- a/src/rmodels.c
+++ b/src/rmodels.c
@@ -3436,7 +3436,12 @@ void GenMeshTangents(Mesh *mesh)
Vector3 *tan1 = (Vector3 *)RL_MALLOC(mesh->vertexCount*sizeof(Vector3));
Vector3 *tan2 = (Vector3 *)RL_MALLOC(mesh->vertexCount*sizeof(Vector3));
- for (int i = 0; i < mesh->vertexCount - 3; i += 3)
+ if (mesh->vertexCount % 3 != 0)
+ {
+ TRACELOG(LOG_WARNING, "MESH: vertexCount expected to be a multiple of 3. Expect uninitialized values.");
+ }
+
+ for (int i = 0; i <= mesh->vertexCount - 3; i += 3)
{
// Get triangle vertices
Vector3 v1 = { mesh->vertices[(i + 0)*3 + 0], mesh->vertices[(i + 0)*3 + 1], mesh->vertices[(i + 0)*3 + 2] };