From 6ba135de0937641f55a4743a15b7f98f972604f8 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Fri, 24 Jul 2015 07:16:40 -0700 Subject: [PATCH] when creating a walking surface collision hull from a flat mesh, ignore triangles with a normal that's not mostly up or down --- tools/vhacd-util/src/VHACDUtil.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/vhacd-util/src/VHACDUtil.cpp b/tools/vhacd-util/src/VHACDUtil.cpp index f1ff0e9e4f..4860785091 100644 --- a/tools/vhacd-util/src/VHACDUtil.cpp +++ b/tools/vhacd-util/src/VHACDUtil.cpp @@ -118,6 +118,13 @@ void vhacd::VHACDUtil::fattenMeshes(const FBXMesh& mesh, FBXMesh& result, glm::vec3 p2 = result.vertices[index2]; glm::vec3 av = (p0 + p1 + p2) / 3.0f; // center of the triangular face + glm::vec3 normal = glm::normalize(glm::cross(p1 - p0, p2 - p0)); + float threshold = 1.0f / sqrtf(3.0f); + if (normal.y > -threshold && normal.y < threshold) { + // this triangle is more a wall than a floor, skip it. + continue; + } + float dropAmount = 0; dropAmount = glm::max(glm::length(p1 - p0), dropAmount); dropAmount = glm::max(glm::length(p2 - p1), dropAmount);