You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Scale quickhull tolerance with mesh size
Taken from three.js's implementation. Tested with a wide variety of meshes.
This commit is contained in:
@@ -36,8 +36,6 @@ uint32_t QuickHull::debug_stop_after = 0xFFFFFFFF;
|
|||||||
|
|
||||||
Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_mesh) {
|
Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_mesh) {
|
||||||
|
|
||||||
static const real_t over_tolerance = 0.0001;
|
|
||||||
|
|
||||||
/* CREATE AABB VOLUME */
|
/* CREATE AABB VOLUME */
|
||||||
|
|
||||||
AABB aabb;
|
AABB aabb;
|
||||||
@@ -180,6 +178,8 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
|
|||||||
faces.push_back(f);
|
faces.push_back(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
real_t over_tolerance = 3 * UNIT_EPSILON * (aabb.size.x + aabb.size.y + aabb.size.z);
|
||||||
|
|
||||||
/* COMPUTE AVAILABLE VERTICES */
|
/* COMPUTE AVAILABLE VERTICES */
|
||||||
|
|
||||||
for (int i = 0; i < p_points.size(); i++) {
|
for (int i = 0; i < p_points.size(); i++) {
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public:
|
|||||||
struct Face {
|
struct Face {
|
||||||
|
|
||||||
Plane plane;
|
Plane plane;
|
||||||
int vertices[3];
|
uint32_t vertices[3];
|
||||||
Vector<int> points_over;
|
Vector<int> points_over;
|
||||||
|
|
||||||
bool operator<(const Face &p_face) const {
|
bool operator<(const Face &p_face) const {
|
||||||
|
|||||||
Reference in New Issue
Block a user