From 0bc94158a8031fa022ae687ea4ea1a8258a82fd7 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 30 Jul 2015 21:09:14 -0700 Subject: [PATCH 1/3] make the height of the tetrahedrons in 'fatten' mode less tall. --- tools/vhacd-util/src/VHACDUtil.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/vhacd-util/src/VHACDUtil.cpp b/tools/vhacd-util/src/VHACDUtil.cpp index 2f8175cbb6..02b8e212be 100644 --- a/tools/vhacd-util/src/VHACDUtil.cpp +++ b/tools/vhacd-util/src/VHACDUtil.cpp @@ -125,12 +125,14 @@ void vhacd::VHACDUtil::fattenMeshes(const FBXMesh& mesh, FBXMesh& result, continue; } + // from the middle of the triangle, pull a point down to form a tetrahedron. float dropAmount = 0; dropAmount = glm::max(glm::length(p1 - p0), dropAmount); dropAmount = glm::max(glm::length(p2 - p1), dropAmount); dropAmount = glm::max(glm::length(p0 - p2), dropAmount); + dropAmount *= 0.25f; - glm::vec3 p3 = av - glm::vec3(0, dropAmount, 0); // a point 1 meter below the average of this triangle's points + glm::vec3 p3 = av - glm::vec3(0, dropAmount, 0); int index3 = result.vertices.size(); result.vertices << p3; // add the new point to the result mesh From c8f398024eb21f49959ab2fc92d2e3a4f95a1fbb Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 30 Jul 2015 21:16:07 -0700 Subject: [PATCH 2/3] replace a magic number with a constant --- tools/vhacd-util/src/VHACDUtil.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/vhacd-util/src/VHACDUtil.cpp b/tools/vhacd-util/src/VHACDUtil.cpp index 02b8e212be..6743ed6a9f 100644 --- a/tools/vhacd-util/src/VHACDUtil.cpp +++ b/tools/vhacd-util/src/VHACDUtil.cpp @@ -12,6 +12,8 @@ #include #include "VHACDUtil.h" +const float collisionTetrahedronScale = 0.25f; + // FBXReader jumbles the order of the meshes by reading them back out of a hashtable. This will put // them back in the order in which they appeared in the file. @@ -130,7 +132,7 @@ void vhacd::VHACDUtil::fattenMeshes(const FBXMesh& mesh, FBXMesh& result, dropAmount = glm::max(glm::length(p1 - p0), dropAmount); dropAmount = glm::max(glm::length(p2 - p1), dropAmount); dropAmount = glm::max(glm::length(p0 - p2), dropAmount); - dropAmount *= 0.25f; + dropAmount *= collisionTetrahedronScale; glm::vec3 p3 = av - glm::vec3(0, dropAmount, 0); int index3 = result.vertices.size(); From 5bae9843f5ee7fe3220d54bbf343490fa4c6ef5c Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Fri, 31 Jul 2015 09:34:50 -0700 Subject: [PATCH 3/3] code review --- tools/vhacd-util/src/VHACDUtil.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/vhacd-util/src/VHACDUtil.cpp b/tools/vhacd-util/src/VHACDUtil.cpp index 6743ed6a9f..1e7f9df7c1 100644 --- a/tools/vhacd-util/src/VHACDUtil.cpp +++ b/tools/vhacd-util/src/VHACDUtil.cpp @@ -12,7 +12,7 @@ #include #include "VHACDUtil.h" -const float collisionTetrahedronScale = 0.25f; +const float COLLISION_TETRAHEDRON_SCALE = 0.25f; // FBXReader jumbles the order of the meshes by reading them back out of a hashtable. This will put @@ -132,9 +132,9 @@ void vhacd::VHACDUtil::fattenMeshes(const FBXMesh& mesh, FBXMesh& result, dropAmount = glm::max(glm::length(p1 - p0), dropAmount); dropAmount = glm::max(glm::length(p2 - p1), dropAmount); dropAmount = glm::max(glm::length(p0 - p2), dropAmount); - dropAmount *= collisionTetrahedronScale; + dropAmount *= COLLISION_TETRAHEDRON_SCALE; - glm::vec3 p3 = av - glm::vec3(0, dropAmount, 0); + glm::vec3 p3 = av - glm::vec3(0.0f, dropAmount, 0.0f); int index3 = result.vertices.size(); result.vertices << p3; // add the new point to the result mesh