summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRay <[email protected]>2023-02-21 23:55:55 +0100
committerRay <[email protected]>2023-02-21 23:55:55 +0100
commit153470d60503e840d5b0a15abe3647a4316e988c (patch)
tree56a812fa27ab4e9ba07196d5e9ba3866afa1fdd6 /src
parentb4d824d6fcdbfb64023664ebd1c9b258d021a0cc (diff)
downloadraylib-153470d60503e840d5b0a15abe3647a4316e988c.tar.gz
raylib-153470d60503e840d5b0a15abe3647a4316e988c.zip
REVIEWED: `GenMeshTangents()`, avoid crash on missing texcoords data #2927
Diffstat (limited to 'src')
-rw-r--r--src/rmodels.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/rmodels.c b/src/rmodels.c
index 2fd2d5a4..f8d6ec13 100644
--- a/src/rmodels.c
+++ b/src/rmodels.c
@@ -3326,9 +3326,15 @@ BoundingBox GetMeshBoundingBox(Mesh mesh)
// Compute mesh tangents
// NOTE: To calculate mesh tangents and binormals we need mesh vertex positions and texture coordinates
-// Implementation base don: https://answers.unity.com/questions/7789/calculating-tangents-vector4.html
+// Implementation based on: https://answers.unity.com/questions/7789/calculating-tangents-vector4.html
void GenMeshTangents(Mesh *mesh)
{
+ if ((mesh->vertices == NULL) || (mesh->texcoords == NULL))
+ {
+ TRACELOG(LOG_WARNING, "MESH: Tangents generation requires texcoord vertex attribute data");
+ return;
+ }
+
if (mesh->tangents == NULL) mesh->tangents = (float *)RL_MALLOC(mesh->vertexCount*4*sizeof(float));
else
{