when creating a walking surface collision hull from a flat mesh, ignore triangles with a normal that's not mostly up or down

This commit is contained in:
Seth Alves 2015-07-24 07:16:40 -07:00
parent 2ac6304752
commit 6ba135de09

View file

@ -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);