Fix scale calculation in VHACD Volume::Voxelize().

(cherry picked from commit 75553c4f90)
This commit is contained in:
Marcel Admiraal 2020-05-06 13:10:16 +01:00 committed by Rémi Verschelde
parent e3712cf689
commit f8b06c8a5c
2 changed files with 22 additions and 2 deletions

View File

@ -0,0 +1,20 @@
diff --git a/thirdparty/vhacd/inc/vhacdVolume.h b/thirdparty/vhacd/inc/vhacdVolume.h
index 8c47fa1e2c..c445f20122 100644
--- a/thirdparty/vhacd/inc/vhacdVolume.h
+++ b/thirdparty/vhacd/inc/vhacdVolume.h
@@ -316,13 +316,13 @@ void Volume::Voxelize(const T* const points, const uint32_t stridePoints, const
double d[3] = { m_maxBB[0] - m_minBB[0], m_maxBB[1] - m_minBB[1], m_maxBB[2] - m_minBB[2] };
double r;
- if (d[0] > d[1] && d[0] > d[2]) {
+ if (d[0] >= d[1] && d[0] >= d[2]) {
r = d[0];
m_dim[0] = dim;
m_dim[1] = 2 + static_cast<size_t>(dim * d[1] / d[0]);
m_dim[2] = 2 + static_cast<size_t>(dim * d[2] / d[0]);
}
- else if (d[1] > d[0] && d[1] > d[2]) {
+ else if (d[1] >= d[0] && d[1] >= d[2]) {
r = d[1];
m_dim[1] = dim;
m_dim[0] = 2 + static_cast<size_t>(dim * d[0] / d[1]);

View File

@ -316,13 +316,13 @@ void Volume::Voxelize(const T* const points, const uint32_t stridePoints, const
double d[3] = { m_maxBB[0] - m_minBB[0], m_maxBB[1] - m_minBB[1], m_maxBB[2] - m_minBB[2] }; double d[3] = { m_maxBB[0] - m_minBB[0], m_maxBB[1] - m_minBB[1], m_maxBB[2] - m_minBB[2] };
double r; double r;
if (d[0] > d[1] && d[0] > d[2]) { if (d[0] >= d[1] && d[0] >= d[2]) {
r = d[0]; r = d[0];
m_dim[0] = dim; m_dim[0] = dim;
m_dim[1] = 2 + static_cast<size_t>(dim * d[1] / d[0]); m_dim[1] = 2 + static_cast<size_t>(dim * d[1] / d[0]);
m_dim[2] = 2 + static_cast<size_t>(dim * d[2] / d[0]); m_dim[2] = 2 + static_cast<size_t>(dim * d[2] / d[0]);
} }
else if (d[1] > d[0] && d[1] > d[2]) { else if (d[1] >= d[0] && d[1] >= d[2]) {
r = d[1]; r = d[1];
m_dim[1] = dim; m_dim[1] = dim;
m_dim[0] = 2 + static_cast<size_t>(dim * d[0] / d[1]); m_dim[0] = 2 + static_cast<size_t>(dim * d[0] / d[1]);