summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Kulling <kimkulling@users.noreply.github.com>2021-12-10 15:03:01 +0100
committerGitHub <noreply@github.com>2021-12-10 15:03:01 +0100
commit819d9f72574fa5f0b90aae442d8270dec64bc4b6 (patch)
tree7ca9163692e406cbaac6502c359eb6a93b7441d8
parent6bb856335f708bd6f8c9a33a48cd3f2444e74588 (diff)
parent33c676227233c3b543df53284e905781dbf62c10 (diff)
Merge pull request #4250 from assimp/kimkulling-fix_division_by_zero_issue4235-1
Update HMPLoader.cpp
-rw-r--r--code/AssetLib/HMP/HMPLoader.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/code/AssetLib/HMP/HMPLoader.cpp b/code/AssetLib/HMP/HMPLoader.cpp
index 661e4d1b2..0bc152680 100644
--- a/code/AssetLib/HMP/HMPLoader.cpp
+++ b/code/AssetLib/HMP/HMPLoader.cpp
@@ -473,16 +473,22 @@ void HMPImporter::ReadFirstSkin(unsigned int iNumSkins, const unsigned char *szC
// ------------------------------------------------------------------------------------------------
// Generate proepr texture coords
-void HMPImporter::GenerateTextureCoords(
- const unsigned int width, const unsigned int height) {
+void HMPImporter::GenerateTextureCoords(const unsigned int width, const unsigned int height) {
ai_assert(nullptr != pScene->mMeshes);
ai_assert(nullptr != pScene->mMeshes[0]);
ai_assert(nullptr != pScene->mMeshes[0]->mTextureCoords[0]);
aiVector3D *uv = pScene->mMeshes[0]->mTextureCoords[0];
-
- const float fY = (1.0f / height) + (1.0f / height) / (height - 1);
- const float fX = (1.0f / width) + (1.0f / width) / (width - 1);
+ if (uv == nullptr) {
+ return;
+ }
+
+ if (height == 0.0f || width == 0.0) {
+ return;
+ }
+
+ const float fY = (1.0f / height) + (1.0f / height) / height;
+ const float fX = (1.0f / width) + (1.0f / width) / width;
for (unsigned int y = 0; y < height; ++y) {
for (unsigned int x = 0; x < width; ++x, ++uv) {