mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Options to clean/simplify convex hull generated from mesh
Clean: remove duplicate and interior vertices (uses Bullet algorithm) Simplify: modify the geometry for further simplification (uses VHACD algorithm) In the editor, single convex hull now uses the clean option. Added a new editor entry to create a simplified convex hull, can be useful for creating convex hull from highly tessellated triangle meshes. Specific change for 3.x: Add support for Vector<Vector3> and PoolVector<Vector3> in the convex hull generator.
This commit is contained in:
parent
66aadc2981
commit
240c33708c
11 changed files with 88 additions and 23 deletions
|
@ -2249,14 +2249,22 @@ real_t ConvexHullComputer::compute(const Vector3 *p_coords, int32_t p_count, rea
|
|||
}
|
||||
|
||||
Error ConvexHullComputer::convex_hull(const Vector<Vector3> &p_points, Geometry::MeshData &r_mesh) {
|
||||
return convex_hull(p_points.ptr(), p_points.size(), r_mesh);
|
||||
}
|
||||
|
||||
Error ConvexHullComputer::convex_hull(const PoolVector<Vector3> &p_points, Geometry::MeshData &r_mesh) {
|
||||
return convex_hull(p_points.read().ptr(), p_points.size(), r_mesh);
|
||||
}
|
||||
|
||||
Error ConvexHullComputer::convex_hull(const Vector3 *p_points, int32_t p_point_count, Geometry::MeshData &r_mesh) {
|
||||
r_mesh = Geometry::MeshData(); // clear
|
||||
|
||||
if (p_points.size() == 0) {
|
||||
if (p_point_count == 0) {
|
||||
return FAILED; // matches QuickHull
|
||||
}
|
||||
|
||||
ConvexHullComputer ch;
|
||||
ch.compute(p_points.ptr(), p_points.size(), -1.0, -1.0);
|
||||
ch.compute(p_points, p_point_count, -1.0, -1.0);
|
||||
|
||||
r_mesh.vertices = ch.vertices;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue