@@ -169,8 +169,13 @@ void tns::TreeNSearch::set_symmetric_search(const bool activate)
169169}
170170void tns::TreeNSearch::set_cell_size (const float cell_size)
171171{
172+ if (this ->cell_size > 0.0 ) {
173+ std::cout << " tns::TreeNSearch::set_cell_size error: Cell size already set. Create a new TreeNSearch instance if you need a different cell_size." << std::endl;
174+ exit (-1 );
175+ }
172176 this ->cell_size = cell_size;
173177 this ->cell_size_inv = 1 .0f / cell_size;
178+ this ->are_cells_valid = false ;
174179}
175180int tns::TreeNSearch::_get_set_pair_id (const int set_i, const int set_j) const
176181{
@@ -414,7 +419,25 @@ void tns::TreeNSearch::_update_world_AABB()
414419 std::array<float , 3 > new_bottom = { MAXf, MAXf, MAXf };
415420 std::array<float , 3 > new_top = { MINf, MINf, MINf };
416421
417- // Find points AABB
422+ // Sequentual computation if points are too few
423+ if (this ->get_total_n_points () < this ->number_of_too_few_particles ) {
424+ for (int set_i = 0 ; set_i < this ->n_sets ; set_i++) {
425+ const float * points = this ->set_points [set_i];
426+ const int n_points = this ->get_n_points_in_set (set_i);
427+
428+ for (int point_i = 0 ; point_i < n_points; point_i++) {
429+ new_bottom[0 ] = std::min (new_bottom[0 ], points[3 * point_i]);
430+ new_bottom[1 ] = std::min (new_bottom[1 ], points[3 * point_i + 1 ]);
431+ new_bottom[2 ] = std::min (new_bottom[2 ], points[3 * point_i + 2 ]);
432+
433+ new_top[0 ] = std::max (new_top[0 ], points[3 * point_i]);
434+ new_top[1 ] = std::max (new_top[1 ], points[3 * point_i + 1 ]);
435+ new_top[2 ] = std::max (new_top[2 ], points[3 * point_i + 2 ]);
436+ }
437+ }
438+ }
439+
440+ // Parallel version
418441 // Note: Paralelized across points and sets
419442 for (int set_i = 0 ; set_i < this ->n_sets ; set_i++) {
420443 const float * points = this ->set_points [set_i];
0 commit comments