summaryrefslogtreecommitdiffstats
path: root/core/math
diff options
context:
space:
mode:
authorJakub Marcowski <01158831@pw.edu.pl>2023-10-14 15:18:14 +0200
committerJakub Marcowski <01158831@pw.edu.pl>2023-10-16 11:48:49 +0200
commitbc78c832e98bb8e9b36a4d236d5ad9ce36de66c5 (patch)
tree91a6e05bc0234a47d6d6ef9f0c5b54c126f0ff13 /core/math
parenta574c0296b38d5f786f249b12e6251e562c528cc (diff)
downloadredot-engine-bc78c832e98bb8e9b36a4d236d5ad9ce36de66c5.tar.gz
Expose 3D Delaunay tetrahedralization in `Geometry3D`
Diffstat (limited to 'core/math')
-rw-r--r--core/math/geometry_3d.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/core/math/geometry_3d.h b/core/math/geometry_3d.h
index 99c554fe05..305a64e39c 100644
--- a/core/math/geometry_3d.h
+++ b/core/math/geometry_3d.h
@@ -31,6 +31,7 @@
#ifndef GEOMETRY_3D_H
#define GEOMETRY_3D_H
+#include "core/math/delaunay_3d.h"
#include "core/math/face3.h"
#include "core/object/object.h"
#include "core/templates/local_vector.h"
@@ -532,6 +533,21 @@ public:
return clipped;
}
+ static Vector<int32_t> tetrahedralize_delaunay(const Vector<Vector3> &p_points) {
+ Vector<Delaunay3D::OutputSimplex> tetr = Delaunay3D::tetrahedralize(p_points);
+ Vector<int32_t> tetrahedrons;
+
+ tetrahedrons.resize(4 * tetr.size());
+ int32_t *ptr = tetrahedrons.ptrw();
+ for (int i = 0; i < tetr.size(); i++) {
+ *ptr++ = tetr[i].points[0];
+ *ptr++ = tetr[i].points[1];
+ *ptr++ = tetr[i].points[2];
+ *ptr++ = tetr[i].points[3];
+ }
+ return tetrahedrons;
+ }
+
// Create a "wrap" that encloses the given geometry.
static Vector<Face3> wrap_geometry(Vector<Face3> p_array, real_t *p_error = nullptr);