mirror of
https://github.com/raysan5/raylib.git
synced 2025-09-06 03:18:14 +00:00
REVIEWED: GenMeshTangents()
, avoid crash on missing texcoords data #2927
This commit is contained in:
@@ -3329,6 +3329,12 @@ BoundingBox GetMeshBoundingBox(Mesh mesh)
|
|||||||
// Implementation based on: 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)
|
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));
|
if (mesh->tangents == NULL) mesh->tangents = (float *)RL_MALLOC(mesh->vertexCount*4*sizeof(float));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user