diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-07-12 22:15:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-12 22:15:40 +0200 |
commit | fc00a8390193220cea702d9ab684fb6c53d97a6b (patch) | |
tree | dc604ebc95c9ac755ebddab8169b8c9a0d498e93 /modules | |
parent | 30d4732623df8a9c286eb1e0b5d3321b31bcfa86 (diff) | |
parent | 1de995ae9911fdc3ce609a8c8f84e023531ea6bc (diff) |
Merge pull request #50262 from nekomatata/convex-hull-simplification
Options to clean/simplify convex hull generated from mesh
Diffstat (limited to 'modules')
-rw-r--r-- | modules/vhacd/register_types.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/modules/vhacd/register_types.cpp b/modules/vhacd/register_types.cpp index daad39bdfb..3d7aaee921 100644 --- a/modules/vhacd/register_types.cpp +++ b/modules/vhacd/register_types.cpp @@ -32,7 +32,7 @@ #include "scene/resources/mesh.h" #include "thirdparty/vhacd/public/VHACD.h" -static Vector<Vector<Face3>> convex_decompose(const Vector<Face3> &p_faces) { +static Vector<Vector<Face3>> convex_decompose(const Vector<Face3> &p_faces, int p_max_convex_hulls = -1) { Vector<float> vertices; vertices.resize(p_faces.size() * 9); Vector<uint32_t> indices; @@ -47,8 +47,12 @@ static Vector<Vector<Face3>> convex_decompose(const Vector<Face3> &p_faces) { } } - VHACD::IVHACD *decomposer = VHACD::CreateVHACD(); VHACD::IVHACD::Parameters params; + if (p_max_convex_hulls > 0) { + params.m_maxConvexHulls = p_max_convex_hulls; + } + + VHACD::IVHACD *decomposer = VHACD::CreateVHACD(); decomposer->Compute(vertices.ptr(), vertices.size() / 3, indices.ptr(), indices.size() / 3, params); int hull_count = decomposer->GetNConvexHulls(); |