소스 검색

REVIEWED: `GenMeshTangents()`, avoid crash on missing texcoords data #2927

pull/2939/head
Ray 2 년 전
부모
커밋
153470d605
1개의 변경된 파일7개의 추가작업 그리고 1개의 파일을 삭제
  1. +7
    -1
      src/rmodels.c

+ 7
- 1
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
{

불러오는 중...
취소
저장