summaryrefslogtreecommitdiff
path: root/core/math/octree.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/math/octree.h')
-rw-r--r--core/math/octree.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/core/math/octree.h b/core/math/octree.h
index 5225fbecb4..2060a61b4b 100644
--- a/core/math/octree.h
+++ b/core/math/octree.h
@@ -34,6 +34,7 @@
#include "core/list.h"
#include "core/map.h"
#include "core/math/aabb.h"
+#include "core/math/geometry.h"
#include "core/math/vector3.h"
#include "core/print_string.h"
#include "core/variant.h"
@@ -341,6 +342,8 @@ private:
const Plane *planes;
int plane_count;
+ const Vector3 *points;
+ int point_count;
T **result_array;
int *result_idx;
int result_max;
@@ -1017,8 +1020,7 @@ void Octree<T, use_pairs, AL>::_cull_convex(Octant *p_octant, _CullConvexData *p
continue;
e->last_pass = pass;
- if (e->aabb.intersects_convex_shape(p_cull->planes, p_cull->plane_count)) {
-
+ if (e->aabb.intersects_convex_shape(p_cull->planes, p_cull->plane_count, p_cull->points, p_cull->point_count)) {
if (*p_cull->result_idx < p_cull->result_max) {
p_cull->result_array[*p_cull->result_idx] = e->userdata;
(*p_cull->result_idx)++;
@@ -1043,7 +1045,7 @@ void Octree<T, use_pairs, AL>::_cull_convex(Octant *p_octant, _CullConvexData *p
continue;
e->last_pass = pass;
- if (e->aabb.intersects_convex_shape(p_cull->planes, p_cull->plane_count)) {
+ if (e->aabb.intersects_convex_shape(p_cull->planes, p_cull->plane_count, p_cull->points, p_cull->point_count)) {
if (*p_cull->result_idx < p_cull->result_max) {
@@ -1059,7 +1061,7 @@ void Octree<T, use_pairs, AL>::_cull_convex(Octant *p_octant, _CullConvexData *p
for (int i = 0; i < 8; i++) {
- if (p_octant->children[i] && p_octant->children[i]->aabb.intersects_convex_shape(p_cull->planes, p_cull->plane_count)) {
+ if (p_octant->children[i] && p_octant->children[i]->aabb.intersects_convex_shape(p_cull->planes, p_cull->plane_count, p_cull->points, p_cull->point_count)) {
_cull_convex(p_octant->children[i], p_cull);
}
}
@@ -1291,11 +1293,15 @@ int Octree<T, use_pairs, AL>::cull_convex(const Vector<Plane> &p_convex, T **p_r
if (!root)
return 0;
+ Vector<Vector3> convex_points = Geometry::compute_convex_mesh_points(&p_convex[0], p_convex.size());
+
int result_count = 0;
pass++;
_CullConvexData cdata;
cdata.planes = &p_convex[0];
cdata.plane_count = p_convex.size();
+ cdata.points = &convex_points[0];
+ cdata.point_count = convex_points.size();
cdata.result_array = p_result_array;
cdata.result_max = p_result_max;
cdata.result_idx = &result_count;