Add Span and some basic uses from Geometry.

This commit is contained in:
lawnjelly
2025-10-08 14:55:42 +01:00
parent 8c10cd6646
commit db9921b17f
12 changed files with 264 additions and 18 deletions

View File

@@ -1398,11 +1398,13 @@ bool Geometry::convex_hull_intersects_convex_hull(const Plane *p_planes_a, int p
return false;
}
Vector<Vector3> Geometry::compute_convex_mesh_points(const Plane *p_planes, int p_plane_count, real_t p_epsilon) {
Vector<Vector3> Geometry::compute_convex_mesh_points(const Span<Plane> &p_planes, real_t p_epsilon) {
Vector<Vector3> points;
// Iterate through every unique combination of any three planes.
for (int i = p_plane_count - 1; i >= 0; i--) {
int plane_count = p_planes.size();
for (int i = plane_count - 1; i >= 0; i--) {
for (int j = i - 1; j >= 0; j--) {
for (int k = j - 1; k >= 0; k--) {
// Find the point where these planes all cross over (if they
@@ -1412,7 +1414,7 @@ Vector<Vector3> Geometry::compute_convex_mesh_points(const Plane *p_planes, int
// See if any *other* plane excludes this point because it's
// on the wrong side.
bool excluded = false;
for (int n = 0; n < p_plane_count; n++) {
for (int n = 0; n < plane_count; n++) {
if (n != i && n != j && n != k) {
real_t dist = p_planes[n].distance_to(convex_shape_point);
if (dist > p_epsilon) {