37 #include "print_string.h" 43 typedef uint32_t OctreeElementID;
45 #define OCTREE_ELEMENT_INVALID_ID 0 46 #define OCTREE_SIZE_LIMIT 1e15 48 template<
class T,
bool use_pairs=false,
class AL=DefaultAllocator>
52 typedef void* (*PairCallback)(
void*,OctreeElementID, T*,int,OctreeElementID, T*,int);
53 typedef void (*UnpairCallback)(
void*,OctreeElementID, T*,int,OctreeElementID, T*,int,
void*);
84 _FORCE_INLINE_
bool operator<(
const PairKey& p_pair)
const {
86 return key<p_pair.key;
89 _FORCE_INLINE_ PairKey( OctreeElementID p_A, OctreeElementID p_B) {
102 _FORCE_INLINE_ PairKey() {}
127 for (
int i=0;i<8;i++)
148 uint32_t pairable_mask;
149 uint32_t pairable_type;
153 Octant *common_parent;
169 Element() { last_pass=0; _id=0; pairable=
false; subindex=0; userdata=0; octree=0; pairable_mask=0; pairable_type=0; common_parent=NULL; }
184 ElementMap element_map;
187 PairCallback pair_callback;
188 UnpairCallback unpair_callback;
189 void *pair_callback_userdata;
190 void *unpair_callback_userdata;
192 OctreeElementID last_element_id;
202 _FORCE_INLINE_
void _pair_check(PairData *p_pair) {
204 bool intersect=p_pair->A->aabb.intersects_inclusive( p_pair->B->aabb );
206 if (intersect!=p_pair->intersect) {
211 p_pair->ud=pair_callback(pair_callback_userdata,p_pair->A->_id, p_pair->A->userdata,p_pair->A->subindex,p_pair->B->_id, p_pair->B->userdata,p_pair->B->subindex);
218 if (unpair_callback) {
219 unpair_callback(pair_callback_userdata,p_pair->A->_id, p_pair->A->userdata,p_pair->A->subindex,p_pair->B->_id, p_pair->B->userdata,p_pair->B->subindex,p_pair->ud);
225 p_pair->intersect=intersect;
230 _FORCE_INLINE_
void _pair_reference(Element* p_A,Element* p_B) {
232 if (p_A==p_B || (p_A->userdata==p_B->userdata && p_A->userdata))
235 if ( !(p_A->pairable_type&p_B->pairable_mask) &&
236 !(p_B->pairable_type&p_A->pairable_mask) )
239 PairKey key(p_A->_id, p_B->_id);
240 typename PairMap::Element *E=pair_map.find(key);
248 pdata.intersect=
false;
249 E=pair_map.insert(key,pdata);
250 E->get().eA=p_A->pair_list.push_back(&E->get());
251 E->get().eB=p_B->pair_list.push_back(&E->get());
262 _FORCE_INLINE_
void _pair_unreference(Element* p_A,Element* p_B) {
267 PairKey key(p_A->_id, p_B->_id);
268 typename PairMap::Element *E=pair_map.find(key);
276 if (E->get().refcount==0) {
279 if (E->get().intersect) {
280 if (unpair_callback) {
281 unpair_callback(pair_callback_userdata,p_A->_id, p_A->userdata,p_A->subindex,p_B->_id, p_B->userdata,p_B->subindex,E->get().ud);
287 if (p_A==E->get().B) {
292 p_A->pair_list.erase( E->get().eA );
293 p_B->pair_list.erase( E->get().eB );
299 _FORCE_INLINE_
void _element_check_pairs(Element *p_element) {
304 _pair_check( E->get() );
310 _FORCE_INLINE_
void _optimize() {
313 while(root && root->children_count<2 && !root->elements.size() && !(use_pairs && root->pairable_elements.size())) {
316 Octant *new_root=NULL;
317 if (root->children_count==1) {
319 for(
int i=0;i<8;i++) {
321 if (root->children[i]) {
322 new_root=root->children[i];
323 root->children[i]=NULL;
327 ERR_FAIL_COND(!new_root);
328 new_root->parent=NULL;
329 new_root->parent_index=-1;
332 memdelete_allocator<Octant,AL>( root );
340 void _insert_element(Element *p_element,Octant *p_octant);
341 void _ensure_valid_root(
const AABB& p_aabb);
342 bool _remove_element_from_octant(Element *p_element,Octant *p_octant,Octant *p_limit=NULL);
343 void _remove_element(Element *p_element);
344 void _pair_element(Element *p_element,Octant *p_octant);
345 void _unpair_element(Element *p_element,Octant *p_octant);
348 struct _CullConvexData {
358 void _cull_convex(Octant *p_octant,_CullConvexData *p_cull);
359 void _cull_AABB(Octant *p_octant,
const AABB& p_aabb, T** p_result_array,
int *p_result_idx,
int p_result_max,
int *p_subindex_array,uint32_t p_mask);
360 void _cull_segment(Octant *p_octant,
const Vector3& p_from,
const Vector3& p_to,T** p_result_array,
int *p_result_idx,
int p_result_max,
int *p_subindex_array,uint32_t p_mask);
361 void _cull_point(Octant *p_octant,
const Vector3& p_point,T** p_result_array,
int *p_result_idx,
int p_result_max,
int *p_subindex_array,uint32_t p_mask);
363 void _remove_tree(Octant *p_octant) {
368 for(
int i=0;i<8;i++) {
370 if (p_octant->children[i])
371 _remove_tree(p_octant->children[i]);
374 memdelete_allocator<Octant,AL>(p_octant);
378 OctreeElementID create(T* p_userdata,
const AABB& p_aabb=
AABB(),
int p_subindex=0,
bool p_pairable=
false,uint32_t p_pairable_type=0,uint32_t pairable_mask=1);
379 void move(OctreeElementID p_id,
const AABB& p_aabb);
380 void set_pairable(OctreeElementID p_id,
bool p_pairable=
false,uint32_t p_pairable_type=0,uint32_t pairable_mask=1);
381 void erase(OctreeElementID p_id);
383 bool is_pairable(OctreeElementID p_id)
const;
384 T *
get(OctreeElementID p_id)
const;
385 int get_subindex(OctreeElementID p_id)
const;
387 int cull_convex(
const Vector<Plane>& p_convex,T** p_result_array,
int p_result_max,uint32_t p_mask=0xFFFFFFFF);
388 int cull_AABB(
const AABB& p_aabb,T** p_result_array,
int p_result_max,
int *p_subindex_array=NULL,uint32_t p_mask=0xFFFFFFFF);
389 int cull_segment(
const Vector3& p_from,
const Vector3& p_to,T** p_result_array,
int p_result_max,
int *p_subindex_array=NULL,uint32_t p_mask=0xFFFFFFFF);
391 int cull_point(
const Vector3& p_point,T** p_result_array,
int p_result_max,
int *p_subindex_array=NULL,uint32_t p_mask=0xFFFFFFFF);
393 void set_pair_callback( PairCallback p_callback,
void *p_userdata );
394 void set_unpair_callback( UnpairCallback p_callback,
void *p_userdata );
396 int get_octant_count()
const {
return octant_count; }
397 int get_pair_count()
const {
return pair_count; }
398 Octree(real_t p_unit_size=1.0);
399 ~
Octree() { _remove_tree(root); }
405 template<
class T,
bool use_pairs,
class AL>
407 const typename ElementMap::Element *E = element_map.find(p_id);
408 ERR_FAIL_COND_V(!E,NULL);
409 return E->get().userdata;
413 template<
class T,
bool use_pairs,
class AL>
416 const typename ElementMap::Element *E = element_map.find(p_id);
417 ERR_FAIL_COND_V(!E,
false);
418 return E->get().pairable;
421 template<
class T,
bool use_pairs,
class AL>
424 const typename ElementMap::Element *E = element_map.find(p_id);
425 ERR_FAIL_COND_V(!E,-1);
426 return E->get().subindex;
429 #define OCTREE_DIVISOR 4 431 template<
class T,
bool use_pairs,
class AL>
434 float element_size = p_element->aabb.get_longest_axis_size() * 1.01;
436 if (p_octant->aabb.size.x/OCTREE_DIVISOR < element_size) {
441 owner.octant=p_octant;
443 if (use_pairs && p_element->pairable) {
445 p_octant->pairable_elements.push_back(p_element);
446 owner.E = p_octant->pairable_elements.back();
449 p_octant->elements.push_back(p_element);
450 owner.E = p_octant->elements.back();
453 p_element->octant_owners.push_back( owner );
455 if (p_element->common_parent==NULL) {
456 p_element->common_parent=p_octant;
457 p_element->container_aabb=p_octant->aabb;
459 p_element->container_aabb.merge_with(p_octant->aabb);
463 if (use_pairs && p_octant->children_count>0) {
467 for (
int i=0;i<8;i++) {
469 if (p_octant->children[i]) {
470 _pair_element(p_element,p_octant->children[i]);
477 bool candidate=p_element->common_parent==NULL;
479 for (
int i=0;i<8;i++) {
481 if (p_octant->children[i]) {
483 if (p_octant->children[i]->aabb.intersects_inclusive( p_element->aabb ) ) {
484 _insert_element( p_element, p_octant->children[i] );
490 AABB aabb=p_octant->aabb;
494 aabb.pos.x+=aabb.size.x;
496 aabb.pos.y+=aabb.size.y;
498 aabb.pos.z+=aabb.size.z;
503 Octant *child = memnew_allocator( Octant, AL );
504 p_octant->children[i]=child;
505 child->parent=p_octant;
506 child->parent_index=i;
510 p_octant->children_count++;
512 _insert_element( p_element, child );
521 if (candidate && splits>1) {
523 p_element->common_parent=p_octant;
533 _pair_reference( p_element,E->get() );
537 if (p_element->pairable) {
539 E=p_octant->elements.front();
541 _pair_reference( p_element,E->get() );
551 template<
class T,
bool use_pairs,
class AL>
561 if ( ABS(base.pos.x+base.size.x) <= ABS(base.pos.x) ) {
570 root = memnew_allocator( Octant, AL );
573 root->parent_index=-1;
581 AABB base=root->aabb;
585 if (base.size.x > OCTREE_SIZE_LIMIT) {
586 ERR_EXPLAIN(
"Octree upper size limit reeached, does the AABB supplied contain NAN?");
590 Octant * gp = memnew_allocator( Octant, AL );
594 if ( ABS(base.pos.x+base.size.x) <= ABS(base.pos.x) ) {
598 gp->children[0]=root;
599 root->parent_index=0;
604 gp->children[(1<<0)|(1<<1)|(1<<2)]=root;
605 root->parent_index=(1<<0)|(1<<1)|(1<<2);
608 gp->children_count=1;
614 template<
class T,
bool use_pairs,
class AL>
617 bool octant_removed=
false;
623 if (p_octant==p_limit)
624 return octant_removed;
628 if (use_pairs && p_octant->last_pass!=pass) {
633 _pair_unreference( p_element,E->get() );
636 if (p_element->pairable) {
638 E=p_octant->elements.front();
640 _pair_unreference( p_element,E->get() );
644 p_octant->last_pass=pass;
650 Octant *parent=p_octant->parent;
652 if (p_octant->children_count==0 && p_octant->elements.empty() && p_octant->pairable_elements.empty()) {
656 if (p_octant==root) {
660 ERR_FAIL_INDEX_V(p_octant->parent_index,8,octant_removed);
662 parent->children[ p_octant->parent_index ]=NULL;
663 parent->children_count--;
666 memdelete_allocator<Octant,AL>(p_octant);
672 if (!removed && !unpaired)
673 return octant_removed;
679 return octant_removed;
682 template<
class T,
bool use_pairs,
class AL>
689 if (E->get()->last_pass!=pass) {
690 _pair_unreference( p_element,E->get() );
691 E->get()->last_pass=pass;
696 if (p_element->pairable) {
698 E=p_octant->elements.front();
700 if (E->get()->last_pass!=pass) {
701 _pair_unreference( p_element,E->get() );
702 E->get()->last_pass=pass;
708 p_octant->last_pass=pass;
710 if (p_octant->children_count==0)
713 for (
int i=0;i<8;i++) {
715 if (p_octant->children[i])
716 _unpair_element(p_element,p_octant->children[i]);
720 template<
class T,
bool use_pairs,
class AL>
729 if (E->get()->last_pass!=pass) {
730 _pair_reference( p_element,E->get() );
731 E->get()->last_pass=pass;
736 if (p_element->pairable) {
738 E=p_octant->elements.front();
740 if (E->get()->last_pass!=pass) {
741 _pair_reference( p_element,E->get() );
742 E->get()->last_pass=pass;
747 p_octant->last_pass=pass;
749 if (p_octant->children_count==0)
752 for (
int i=0;i<8;i++) {
754 if (p_octant->children[i])
755 _pair_element(p_element,p_octant->children[i]);
759 template<
class T,
bool use_pairs,
class AL>
768 for(;I;I=I->
next()) {
770 Octant *o=I->
get().octant;
773 o->elements.erase( I->
get().E );
775 _remove_element_from_octant( p_element, o );
781 I=p_element->octant_owners.front();
785 for(;I;I=I->
next()) {
787 Octant *o=I->
get().octant;
791 for (
int i=0;i<8;i++) {
794 _unpair_element(p_element,o->children[i]);
797 if (p_element->pairable)
798 o->pairable_elements.erase( I->
get().E );
800 o->elements.erase( I->
get().E );
805 p_element->octant_owners.clear();
809 int remaining=p_element->pair_list.size();
811 ERR_FAIL_COND( remaining );
816 template<
class T,
bool use_pairs,
class AL>
821 ERR_FAIL_COND_V( p_aabb.pos.x > 1e15 || p_aabb.pos.x < -1e15, 0 );
822 ERR_FAIL_COND_V( p_aabb.pos.y > 1e15 || p_aabb.pos.y < -1e15, 0 );
823 ERR_FAIL_COND_V( p_aabb.pos.z > 1e15 || p_aabb.pos.z < -1e15, 0 );
824 ERR_FAIL_COND_V( p_aabb.size.x > 1e15 || p_aabb.size.x < 0.0, 0 );
825 ERR_FAIL_COND_V( p_aabb.size.y > 1e15 || p_aabb.size.y < 0.0, 0 );
826 ERR_FAIL_COND_V( p_aabb.size.z > 1e15 || p_aabb.size.z < 0.0, 0 );
827 ERR_FAIL_COND_V( Math::is_nan(p_aabb.size.x) , 0 );
828 ERR_FAIL_COND_V( Math::is_nan(p_aabb.size.y) , 0 );
829 ERR_FAIL_COND_V( Math::is_nan(p_aabb.size.z) , 0 );
833 typename ElementMap::Element *E = element_map.insert(last_element_id++,
835 Element &e = E->get();
838 e.userdata=p_userdata;
839 e.subindex=p_subindex;
842 e.pairable=p_pairable;
843 e.pairable_type=p_pairable_type;
844 e.pairable_mask=p_pairable_mask;
845 e._id=last_element_id-1;
847 if (!e.aabb.has_no_surface()) {
848 _ensure_valid_root(p_aabb);
849 _insert_element(&e,root);
851 _element_check_pairs(&e);
854 return last_element_id-1;
859 template<
class T,
bool use_pairs,
class AL>
864 ERR_FAIL_COND( p_aabb.pos.x > 1e15 || p_aabb.pos.x < -1e15 );
865 ERR_FAIL_COND( p_aabb.pos.y > 1e15 || p_aabb.pos.y < -1e15 );
866 ERR_FAIL_COND( p_aabb.pos.z > 1e15 || p_aabb.pos.z < -1e15 );
867 ERR_FAIL_COND( p_aabb.size.x > 1e15 || p_aabb.size.x < 0.0 );
868 ERR_FAIL_COND( p_aabb.size.y > 1e15 || p_aabb.size.y < 0.0 );
869 ERR_FAIL_COND( p_aabb.size.z > 1e15 || p_aabb.size.z < 0.0 );
870 ERR_FAIL_COND( Math::is_nan(p_aabb.size.x) );
871 ERR_FAIL_COND( Math::is_nan(p_aabb.size.y) );
872 ERR_FAIL_COND( Math::is_nan(p_aabb.size.z) );
874 typename ElementMap::Element *E = element_map.find(p_id);
876 Element &e = E->get();
881 if (!e.aabb.has_no_surface()) {
887 if (!e.aabb.has_no_surface()) {
888 _ensure_valid_root(p_aabb);
890 _insert_element(&e,root);
892 _element_check_pairs(&e);
900 bool old_has_surf=!e.aabb.has_no_surface();
901 bool new_has_surf=!p_aabb.has_no_surface();
903 if (old_has_surf!=new_has_surf) {
908 e.common_parent=NULL;
912 _ensure_valid_root(p_aabb);
913 e.common_parent=NULL;
915 _insert_element(&e,root);
917 _element_check_pairs(&e);
928 if (e.container_aabb.encloses(p_aabb)) {
932 _element_check_pairs(&e);
938 AABB combined=e.aabb;
939 combined.merge_with(p_aabb);
940 _ensure_valid_root(combined);
942 ERR_FAIL_COND( e.octant_owners.front()==NULL );
947 Octant *common_parent=e.common_parent;
948 ERR_FAIL_COND(!common_parent);
954 while(common_parent && !common_parent->aabb.encloses(p_aabb))
955 common_parent=common_parent->parent;
957 ERR_FAIL_COND(!common_parent);
960 e.octant_owners.clear();
961 e.common_parent=NULL;
964 _insert_element(&e,common_parent);
970 Octant *o=E->get().octant;
976 if (use_pairs && e.pairable)
977 o->pairable_elements.erase( E->get().E );
979 o->elements.erase( E->get().E );
981 if (_remove_element_from_octant( &e, o, common_parent->parent )) {
994 Octant *o=E->
get().octant;
998 for (
int i=0;i<8;i++) {
1001 _unpair_element(&e,o->children[i]);
1006 _element_check_pairs(&e);
1016 template<
class T,
bool use_pairs,
class AL>
1019 typename ElementMap::Element *E = element_map.find(p_id);
1022 Element &e = E->get();
1024 if (p_pairable == e.pairable && e.pairable_type==p_pairable_type && e.pairable_mask==p_pairable_mask)
1027 if (!e.aabb.has_no_surface()) {
1028 _remove_element(&e);
1031 e.pairable=p_pairable;
1032 e.pairable_type=p_pairable_type;
1033 e.pairable_mask=p_pairable_mask;
1034 e.common_parent=NULL;
1036 if (!e.aabb.has_no_surface()) {
1037 _ensure_valid_root(e.aabb);
1038 _insert_element(&e,root);
1040 _element_check_pairs(&e);
1046 template<
class T,
bool use_pairs,
class AL>
1049 typename ElementMap::Element *E = element_map.find(p_id);
1052 Element &e = E->get();
1054 if (!e.aabb.has_no_surface()) {
1056 _remove_element(&e);
1059 element_map.erase(p_id);
1063 template<
class T,
bool use_pairs,
class AL>
1066 if (*p_cull->result_idx==p_cull->result_max)
1069 if (!p_octant->elements.empty()) {
1072 I=p_octant->elements.front();
1074 for(;I;I=I->next()) {
1076 Element *e=I->get();
1078 if (e->last_pass==pass || (use_pairs && !(e->pairable_type&p_cull->mask)))
1082 if (e->aabb.intersects_convex_shape(p_cull->planes,p_cull->plane_count)) {
1084 if (*p_cull->result_idx<p_cull->result_max) {
1085 p_cull->result_array[*p_cull->result_idx] = e->userdata;
1086 (*p_cull->result_idx)++;
1095 if (use_pairs && !p_octant->pairable_elements.empty()) {
1098 I=p_octant->pairable_elements.front();
1100 for(;I;I=I->next()) {
1102 Element *e=I->get();
1104 if (e->last_pass==pass || (use_pairs && !(e->pairable_type&p_cull->mask)))
1108 if (e->aabb.intersects_convex_shape(p_cull->planes,p_cull->plane_count)) {
1110 if (*p_cull->result_idx<p_cull->result_max) {
1112 p_cull->result_array[*p_cull->result_idx] = e->userdata;
1113 (*p_cull->result_idx)++;
1122 for (
int i=0;i<8;i++) {
1124 if (p_octant->children[i] && p_octant->children[i]->aabb.intersects_convex_shape(p_cull->planes,p_cull->plane_count)) {
1125 _cull_convex(p_octant->children[i],p_cull);
1131 template<
class T,
bool use_pairs,
class AL>
1134 if (*p_result_idx==p_result_max)
1137 if (!p_octant->elements.empty()) {
1140 I=p_octant->elements.front();
1141 for(;I;I=I->next()) {
1143 Element *e=I->get();
1145 if (e->last_pass==pass || (use_pairs && !(e->pairable_type&p_mask)))
1151 if (*p_result_idx<p_result_max) {
1153 p_result_array[*p_result_idx] = e->userdata;
1154 if (p_subindex_array)
1155 p_subindex_array[*p_result_idx] = e->subindex;
1166 if (use_pairs && !p_octant->pairable_elements.empty()) {
1169 I=p_octant->pairable_elements.front();
1170 for(;I;I=I->next()) {
1172 Element *e=I->get();
1174 if (e->last_pass==pass || (use_pairs && !(e->pairable_type&p_mask)))
1180 if (*p_result_idx<p_result_max) {
1182 p_result_array[*p_result_idx] = e->userdata;
1183 if (p_subindex_array)
1184 p_subindex_array[*p_result_idx] = e->subindex;
1194 for (
int i=0;i<8;i++) {
1196 if (p_octant->children[i] && p_octant->children[i]->aabb.intersects_inclusive(p_aabb)) {
1197 _cull_AABB(p_octant->children[i],p_aabb, p_result_array,p_result_idx,p_result_max,p_subindex_array,p_mask);
1203 template<
class T,
bool use_pairs,
class AL>
1206 if (*p_result_idx==p_result_max)
1209 if (!p_octant->elements.empty()) {
1212 I=p_octant->elements.front();
1213 for(;I;I=I->next()) {
1215 Element *e=I->get();
1217 if (e->last_pass==pass || (use_pairs && !(e->pairable_type&p_mask)))
1221 if (e->aabb.intersects_segment(p_from,p_to)) {
1223 if (*p_result_idx<p_result_max) {
1225 p_result_array[*p_result_idx] = e->userdata;
1226 if (p_subindex_array)
1227 p_subindex_array[*p_result_idx] = e->subindex;
1238 if (use_pairs && !p_octant->pairable_elements.empty()) {
1241 I=p_octant->pairable_elements.front();
1242 for(;I;I=I->next()) {
1244 Element *e=I->get();
1246 if (e->last_pass==pass || (use_pairs && !(e->pairable_type&p_mask)))
1251 if (e->aabb.intersects_segment(p_from,p_to)) {
1253 if (*p_result_idx<p_result_max) {
1255 p_result_array[*p_result_idx] = e->userdata;
1256 if (p_subindex_array)
1257 p_subindex_array[*p_result_idx] = e->subindex;
1270 for (
int i=0;i<8;i++) {
1272 if (p_octant->children[i] && p_octant->children[i]->aabb.intersects_segment(p_from,p_to)) {
1273 _cull_segment(p_octant->children[i],p_from,p_to, p_result_array,p_result_idx,p_result_max,p_subindex_array,p_mask);
1279 template<
class T,
bool use_pairs,
class AL>
1282 if (*p_result_idx==p_result_max)
1285 if (!p_octant->elements.empty()) {
1288 I=p_octant->elements.front();
1289 for(;I;I=I->next()) {
1291 Element *e=I->get();
1293 if (e->last_pass==pass || (use_pairs && !(e->pairable_type&p_mask)))
1297 if (e->aabb.has_point(p_point)) {
1299 if (*p_result_idx<p_result_max) {
1301 p_result_array[*p_result_idx] = e->userdata;
1302 if (p_subindex_array)
1303 p_subindex_array[*p_result_idx] = e->subindex;
1314 if (use_pairs && !p_octant->pairable_elements.empty()) {
1317 I=p_octant->pairable_elements.front();
1318 for(;I;I=I->next()) {
1320 Element *e=I->get();
1322 if (e->last_pass==pass || (use_pairs && !(e->pairable_type&p_mask)))
1327 if (e->aabb.has_point(p_point)) {
1329 if (*p_result_idx<p_result_max) {
1331 p_result_array[*p_result_idx] = e->userdata;
1332 if (p_subindex_array)
1333 p_subindex_array[*p_result_idx] = e->subindex;
1346 for (
int i=0;i<8;i++) {
1349 if (p_octant->children[i] && p_octant->children[i]->aabb.has_point(p_point)) {
1350 _cull_point(p_octant->children[i],p_point, p_result_array,p_result_idx,p_result_max,p_subindex_array,p_mask);
1355 template<
class T,
bool use_pairs,
class AL>
1363 _CullConvexData cdata;
1364 cdata.planes=&p_convex[0];
1365 cdata.plane_count=p_convex.size();
1366 cdata.result_array=p_result_array;
1367 cdata.result_max=p_result_max;
1368 cdata.result_idx=&result_count;
1371 _cull_convex(root,&cdata);
1373 return result_count;
1378 template<
class T,
bool use_pairs,
class AL>
1387 _cull_AABB(root,p_aabb,p_result_array,&result_count,p_result_max,p_subindex_array,p_mask);
1389 return result_count;
1393 template<
class T,
bool use_pairs,
class AL>
1401 _cull_segment(root,p_from,p_to,p_result_array,&result_count,p_result_max,p_subindex_array,p_mask);
1403 return result_count;
1407 template<
class T,
bool use_pairs,
class AL>
1415 _cull_point(root,p_point,p_result_array,&result_count,p_result_max,p_subindex_array,p_mask);
1417 return result_count;
1422 template<
class T,
bool use_pairs,
class AL>
1425 pair_callback=p_callback;
1426 pair_callback_userdata=p_userdata;
1428 template<
class T,
bool use_pairs,
class AL>
1431 unpair_callback=p_callback;
1432 unpair_callback_userdata=p_userdata;
1437 template<
class T,
bool use_pairs,
class AL>
1442 unit_size=p_unit_size;
1449 unpair_callback=NULL;
1450 pair_callback_userdata=NULL;
1451 unpair_callback_userdata=NULL;
_FORCE_INLINE_ bool intersects_inclusive(const AABB &p_aabb) const
Both AABBs overlap.
Definition: aabb.h:130
_FORCE_INLINE_ const Element * next() const
Definition: list.h:63
_FORCE_INLINE_ bool encloses(const AABB &p_aabb) const
Both AABBs (or their faces) overlap.
Definition: aabb.h:148
_FORCE_INLINE_ T & get()
Definition: list.h:119