From 4e76e8aca95185cd3b938941c0aacdfac150e636 Mon Sep 17 00:00:00 2001 From: Jeongseok Lee Date: Fri, 12 Aug 2016 19:51:57 -0400 Subject: [PATCH 01/10] Add broadphase test to prevent duplicate pair checking --- test/test_fcl_broadphase_collision_1.cpp | 197 +++++++++++++++++++++++ 1 file changed, 197 insertions(+) diff --git a/test/test_fcl_broadphase_collision_1.cpp b/test/test_fcl_broadphase_collision_1.cpp index eaa30fe3b..bcc3548c1 100644 --- a/test/test_fcl_broadphase_collision_1.cpp +++ b/test/test_fcl_broadphase_collision_1.cpp @@ -55,6 +55,11 @@ using namespace fcl; +/// @brief make sure if broadphase algorithms doesn't check twice for the same +/// collision object pair +template +void broad_phase_duplicate_check_test(S env_scale, std::size_t env_size, bool verbose = false); + /// @brief test for broad phase update template void broad_phase_update_collision_test(S env_scale, std::size_t env_size, std::size_t query_size, std::size_t num_max_contacts = 1, bool exhaustive = false, bool use_mesh = false); @@ -73,6 +78,17 @@ struct GoogleDenseHashTable : public google::dense_hash_map(2000, 1000); +#else + broad_phase_duplicate_check_test(2000, 100); +#endif +} + /// check the update, only return collision or not GTEST_TEST(FCL_BROADPHASE, test_core_bf_broad_phase_update_collision_binary) { @@ -145,6 +161,187 @@ GTEST_TEST(FCL_BROADPHASE, test_core_mesh_bf_broad_phase_update_collision_mesh_e #endif } +//============================================================================== +template +struct CollisionDataForUniquenessChecking +{ + std::set*, CollisionObject*>> checkedPairs; + + bool checkUniquenessAndAddPair(CollisionObject* o1, CollisionObject* o2) + { + auto search = checkedPairs.find(std::make_pair(o1, o2)); + + if (search != checkedPairs.end()) + return false; + + checkedPairs.emplace(o1, o2); + + return true; + } +}; + +//============================================================================== +template +bool collisionFunctionForUniquenessChecking( + CollisionObject* o1, CollisionObject* o2, void* cdata_) +{ + auto* cdata = static_cast*>(cdata_); + + EXPECT_TRUE(cdata->checkUniquenessAndAddPair(o1, o2)); + + return false; +} + +//============================================================================== +template +void broad_phase_duplicate_check_test(S env_scale, std::size_t env_size, bool verbose) +{ + std::vector ts; + std::vector timers; + + std::vector*> env; + generateEnvironments(env, env_scale, env_size); + +// for (auto i = 0u; i < env_size; ++i) +// env.emplace_back(new CollisionObject(std::make_shared>(10))); + + std::vector*> managers; + managers.push_back(new NaiveCollisionManager()); + managers.push_back(new SSaPCollisionManager()); + managers.push_back(new SaPCollisionManager()); + managers.push_back(new IntervalTreeCollisionManager()); + Vector3 lower_limit, upper_limit; + SpatialHashingCollisionManager::computeBound(env, lower_limit, upper_limit); + S cell_size = std::min(std::min((upper_limit[0] - lower_limit[0]) / 20, (upper_limit[1] - lower_limit[1]) / 20), (upper_limit[2] - lower_limit[2])/20); + managers.push_back(new SpatialHashingCollisionManager, CollisionObject*, SpatialHash> >(cell_size, lower_limit, upper_limit)); +#if USE_GOOGLEHASH + managers.push_back(new SpatialHashingCollisionManager, CollisionObject*, SpatialHash, GoogleSparseHashTable> >(cell_size, lower_limit, upper_limit)); + managers.push_back(new SpatialHashingCollisionManager, CollisionObject*, SpatialHash, GoogleDenseHashTable> >(cell_size, lower_limit, upper_limit)); +#endif + managers.push_back(new DynamicAABBTreeCollisionManager()); + managers.push_back(new DynamicAABBTreeCollisionManager_Array()); + + { + DynamicAABBTreeCollisionManager* m = new DynamicAABBTreeCollisionManager(); + m->tree_init_level = 2; + managers.push_back(m); + } + + { + DynamicAABBTreeCollisionManager_Array* m = new DynamicAABBTreeCollisionManager_Array(); + m->tree_init_level = 2; + managers.push_back(m); + } + + ts.resize(managers.size()); + timers.resize(managers.size()); + + for(size_t i = 0; i < managers.size(); ++i) + { + timers[i].start(); + managers[i]->registerObjects(env); + timers[i].stop(); + ts[i].push_back(timers[i].getElapsedTime()); + } + + for(size_t i = 0; i < managers.size(); ++i) + { + timers[i].start(); + managers[i]->setup(); + timers[i].stop(); + ts[i].push_back(timers[i].getElapsedTime()); + } + + // update the environment + S delta_angle_max = 10 / 360.0 * 2 * constants::pi(); + S delta_trans_max = 0.01 * env_scale; + for(size_t i = 0; i < env.size(); ++i) + { + S rand_angle_x = 2 * (rand() / (S)RAND_MAX - 0.5) * delta_angle_max; + S rand_trans_x = 2 * (rand() / (S)RAND_MAX - 0.5) * delta_trans_max; + S rand_angle_y = 2 * (rand() / (S)RAND_MAX - 0.5) * delta_angle_max; + S rand_trans_y = 2 * (rand() / (S)RAND_MAX - 0.5) * delta_trans_max; + S rand_angle_z = 2 * (rand() / (S)RAND_MAX - 0.5) * delta_angle_max; + S rand_trans_z = 2 * (rand() / (S)RAND_MAX - 0.5) * delta_trans_max; + + Matrix3 dR( + AngleAxis(rand_angle_x, Vector3::UnitX()) + * AngleAxis(rand_angle_y, Vector3::UnitY()) + * AngleAxis(rand_angle_z, Vector3::UnitZ())); + Vector3 dT(rand_trans_x, rand_trans_y, rand_trans_z); + + Matrix3 R = env[i]->getRotation(); + Vector3 T = env[i]->getTranslation(); + env[i]->setTransform(dR * R, dR * T + dT); + env[i]->computeAABB(); + } + + for(size_t i = 0; i < managers.size(); ++i) + { + timers[i].start(); + managers[i]->update(); + timers[i].stop(); + ts[i].push_back(timers[i].getElapsedTime()); + } + + std::vector> self_data(managers.size()); + + for(size_t i = 0; i < managers.size(); ++i) + { + timers[i].start(); + managers[i]->collide(&self_data[i], collisionFunctionForUniquenessChecking); + timers[i].stop(); + ts[i].push_back(timers[i].getElapsedTime()); + } + + for (auto obj : env) + delete obj; + + if (!verbose) + return; + + std::cout.setf(std::ios_base::left, std::ios_base::adjustfield); + size_t w = 7; + + std::cout << "collision timing summary" << std::endl; + std::cout << env_size << " objs" << std::endl; + std::cout << "register time" << std::endl; + for(size_t i = 0; i < ts.size(); ++i) + std::cout << std::setw(w) << ts[i].records[0] << " "; + std::cout << std::endl; + + std::cout << "setup time" << std::endl; + for(size_t i = 0; i < ts.size(); ++i) + std::cout << std::setw(w) << ts[i].records[1] << " "; + std::cout << std::endl; + + std::cout << "update time" << std::endl; + for(size_t i = 0; i < ts.size(); ++i) + std::cout << std::setw(w) << ts[i].records[2] << " "; + std::cout << std::endl; + + std::cout << "self collision time" << std::endl; + for(size_t i = 0; i < ts.size(); ++i) + std::cout << std::setw(w) << ts[i].records[3] << " "; + std::cout << std::endl; + + std::cout << "collision time" << std::endl; + for(size_t i = 0; i < ts.size(); ++i) + { + S tmp = 0; + for(size_t j = 4; j < ts[i].records.size(); ++j) + tmp += ts[i].records[j]; + std::cout << std::setw(w) << tmp << " "; + } + std::cout << std::endl; + + std::cout << "overall time" << std::endl; + for(size_t i = 0; i < ts.size(); ++i) + std::cout << std::setw(w) << ts[i].overall_time << " "; + std::cout << std::endl; + std::cout << std::endl; +} + template void broad_phase_update_collision_test(S env_scale, std::size_t env_size, std::size_t query_size, std::size_t num_max_contacts, bool exhaustive, bool use_mesh) { From 705c7c8c075af14ce3deae479333d280664b85c9 Mon Sep 17 00:00:00 2001 From: Jeongseok Lee Date: Fri, 12 Aug 2016 19:54:20 -0400 Subject: [PATCH 02/10] Fix duplicate pair checking of SpatialHashingCollisionManager --- .../fcl/broadphase/broadphase_spatialhash.h | 406 +++++++++++++----- 1 file changed, 288 insertions(+), 118 deletions(-) diff --git a/include/fcl/broadphase/broadphase_spatialhash.h b/include/fcl/broadphase/broadphase_spatialhash.h index f69841b8c..07e240490 100644 --- a/include/fcl/broadphase/broadphase_spatialhash.h +++ b/include/fcl/broadphase/broadphase_spatialhash.h @@ -125,6 +125,10 @@ class SpatialHashingCollisionManager : public BroadPhaseCollisionManager /// @brief all objects in the scene std::list*> objs; + /// @brief objects partially penetrating (not totally inside nor outside) the + /// scene limit are in another list + std::list*> objs_partially_penetrating_scene_limit; + /// @brief objects outside the scene limit are in another list std::list*> objs_outside_scene_limit; @@ -137,6 +141,23 @@ class SpatialHashingCollisionManager : public BroadPhaseCollisionManager /// @brief objects in the scene limit (given by scene_min and scene_max) are in the spatial hash table HashTable* hash_table; +private: + + enum ObjectStatus + { + Inside, + PartiallyPenetrating, + Outside + }; + + template + bool distanceObjectToObjects( + CollisionObject* obj, + const Container& objs, + void* cdata, + DistanceCallBack callback, + S& min_dist) const; + }; template, CollisionObject*, SpatialHash>> @@ -184,12 +205,14 @@ void SpatialHashingCollisionManager::registerObject( if(scene_limit.overlap(obj_aabb, overlap_aabb)) { if(!scene_limit.contain(obj_aabb)) - objs_outside_scene_limit.push_back(obj); + objs_partially_penetrating_scene_limit.push_back(obj); hash_table->insert(overlap_aabb, obj); } else + { objs_outside_scene_limit.push_back(obj); + } obj_aabb_map[obj] = obj_aabb; } @@ -206,12 +229,14 @@ void SpatialHashingCollisionManager::unregisterObject(CollisionObj if(scene_limit.overlap(obj_aabb, overlap_aabb)) { if(!scene_limit.contain(obj_aabb)) - objs_outside_scene_limit.remove(obj); + objs_partially_penetrating_scene_limit.remove(obj); hash_table->remove(overlap_aabb, obj); } else + { objs_outside_scene_limit.remove(obj); + } obj_aabb_map.erase(obj); } @@ -228,6 +253,7 @@ template void SpatialHashingCollisionManager::update() { hash_table->clear(); + objs_partially_penetrating_scene_limit.clear(); objs_outside_scene_limit.clear(); for(auto it = objs.cbegin(), end = objs.cend(); it != end; ++it) @@ -239,12 +265,14 @@ void SpatialHashingCollisionManager::update() if(scene_limit.overlap(obj_aabb, overlap_aabb)) { if(!scene_limit.contain(obj_aabb)) - objs_outside_scene_limit.push_back(obj); + objs_partially_penetrating_scene_limit.push_back(obj); hash_table->insert(overlap_aabb, obj); } else + { objs_outside_scene_limit.push_back(obj); + } obj_aabb_map[obj] = obj_aabb; } @@ -257,27 +285,109 @@ void SpatialHashingCollisionManager::update(CollisionObject* up const AABB& new_aabb = updated_obj->getAABB(); const AABB& old_aabb = obj_aabb_map[updated_obj]; - if(!scene_limit.contain(old_aabb)) // previously not completely in scene limit + AABB old_overlap_aabb; + const auto is_old_aabb_overlapping + = scene_limit.overlap(old_aabb, old_overlap_aabb); + if(is_old_aabb_overlapping) + hash_table->remove(old_overlap_aabb, updated_obj); + + AABB new_overlap_aabb; + const auto is_new_aabb_overlapping + = scene_limit.overlap(new_aabb, new_overlap_aabb); + if(is_new_aabb_overlapping) + hash_table->insert(new_overlap_aabb, updated_obj); + + ObjectStatus old_status; + if(is_old_aabb_overlapping) + { + if(scene_limit.contain(old_aabb)) + old_status = Inside; + else + old_status = PartiallyPenetrating; + } + else + { + old_status = Outside; + } + + if(is_new_aabb_overlapping) { if(scene_limit.contain(new_aabb)) { - auto find_it = std::find(objs_outside_scene_limit.begin(), - objs_outside_scene_limit.end(), - updated_obj); + if (old_status == PartiallyPenetrating) + { + // Status change: PartiallyPenetrating --> Inside + // Required action(s): + // - remove object from "objs_partially_penetrating_scene_limit" + + auto find_it = std::find(objs_partially_penetrating_scene_limit.begin(), + objs_partially_penetrating_scene_limit.end(), + updated_obj); + objs_partially_penetrating_scene_limit.erase(find_it); + } + else if (old_status == Outside) + { + // Status change: Outside --> Inside + // Required action(s): + // - remove object from "objs_outside_scene_limit" + + auto find_it = std::find(objs_outside_scene_limit.begin(), + objs_outside_scene_limit.end(), + updated_obj); + objs_outside_scene_limit.erase(find_it); + } + } + else + { + if (old_status == Inside) + { + // Status change: Inside --> PartiallyPenetrating + // Required action(s): + // - add object to "objs_partially_penetrating_scene_limit" + + objs_partially_penetrating_scene_limit.push_back(updated_obj); + } + else if (old_status == Outside) + { + // Status change: Outside --> PartiallyPenetrating + // Required action(s): + // - remove object from "objs_outside_scene_limit" + // - add object to "objs_partially_penetrating_scene_limit" - objs_outside_scene_limit.erase(find_it); + auto find_it = std::find(objs_outside_scene_limit.begin(), + objs_outside_scene_limit.end(), + updated_obj); + objs_outside_scene_limit.erase(find_it); + + objs_partially_penetrating_scene_limit.push_back(updated_obj); + } } } - else if(!scene_limit.contain(new_aabb)) // previous completely in scenelimit, now not - objs_outside_scene_limit.push_back(updated_obj); + else + { + if (old_status == Inside) + { + // Status change: Inside --> Outside + // Required action(s): + // - add object to "objs_outside_scene_limit" - AABB old_overlap_aabb; - if(scene_limit.overlap(old_aabb, old_overlap_aabb)) - hash_table->remove(old_overlap_aabb, updated_obj); + objs_outside_scene_limit.push_back(updated_obj); + } + else if (old_status == PartiallyPenetrating) + { + // Status change: PartiallyPenetrating --> Outside + // Required action(s): + // - remove object from "objs_partially_penetrating_scene_limit" + // - add object to "objs_outside_scene_limit" - AABB new_overlap_aabb; - if(scene_limit.overlap(new_aabb, new_overlap_aabb)) - hash_table->insert(new_overlap_aabb, updated_obj); + auto find_it = std::find(objs_partially_penetrating_scene_limit.begin(), + objs_partially_penetrating_scene_limit.end(), + updated_obj); + objs_partially_penetrating_scene_limit.erase(find_it); + + objs_outside_scene_limit.push_back(updated_obj); + } + } obj_aabb_map[updated_obj] = new_aabb; } @@ -327,38 +437,54 @@ void SpatialHashingCollisionManager::distance(CollisionObject* //============================================================================== template -bool SpatialHashingCollisionManager::collide_(CollisionObject* obj, void* cdata, CollisionCallBack callback) const +bool SpatialHashingCollisionManager::collide_( + CollisionObject* obj, void* cdata, CollisionCallBack callback) const { - const AABB& obj_aabb = obj->getAABB(); + const auto& obj_aabb = obj->getAABB(); AABB overlap_aabb; if(scene_limit.overlap(obj_aabb, overlap_aabb)) { - if(!scene_limit.contain(obj_aabb)) + const auto query_result = hash_table->query(overlap_aabb); + for(const auto& obj2 : query_result) { - for(auto it = objs_outside_scene_limit.cbegin(), end = objs_outside_scene_limit.cend(); - it != end; ++it) - { - if(obj == *it) continue; - if(callback(obj, *it, cdata)) return true; - } + if(obj == obj2) + continue; + + if(callback(obj, obj2, cdata)) + return true; } - std::vector*> query_result = hash_table->query(overlap_aabb); - for(unsigned int i = 0; i < query_result.size(); ++i) + if(!scene_limit.contain(obj_aabb)) { - if(obj == query_result[i]) continue; - if(callback(obj, query_result[i], cdata)) return true; + for(const auto& obj2 : objs_outside_scene_limit) + { + if(obj == obj2) + continue; + + if(callback(obj, obj2, cdata)) + return true; + } } } else { - ; - for(auto it = objs_outside_scene_limit.cbegin(), end = objs_outside_scene_limit.cend(); - it != end; ++it) + for(const auto& obj2 : objs_partially_penetrating_scene_limit) { - if(obj == *it) continue; - if(callback(obj, *it, cdata)) return true; + if(obj == obj2) + continue; + + if(callback(obj, obj2, cdata)) + return true; + } + + for(const auto& obj2 : objs_outside_scene_limit) + { + if(obj == obj2) + continue; + + if(callback(obj, obj2, cdata)) + return true; } } @@ -367,10 +493,11 @@ bool SpatialHashingCollisionManager::collide_(CollisionObject* //============================================================================== template -bool SpatialHashingCollisionManager::distance_(CollisionObject* obj, void* cdata, DistanceCallBack callback, S& min_dist) const +bool SpatialHashingCollisionManager::distance_( + CollisionObject* obj, void* cdata, DistanceCallBack callback, S& min_dist) const { - Vector3 delta = (obj->getAABB().max_ - obj->getAABB().min_) * 0.5; - AABB aabb = obj->getAABB(); + auto delta = (obj->getAABB().max_ - obj->getAABB().min_) * 0.5; + auto aabb = obj->getAABB(); if(min_dist < std::numeric_limits::max()) { Vector3 min_dist_delta(min_dist, min_dist, min_dist); @@ -379,7 +506,7 @@ bool SpatialHashingCollisionManager::distance_(CollisionObject* AABB overlap_aabb; - int status = 1; + auto status = 1; S old_min_distance; while(1) @@ -388,76 +515,42 @@ bool SpatialHashingCollisionManager::distance_(CollisionObject* if(scene_limit.overlap(aabb, overlap_aabb)) { - if(!scene_limit.contain(aabb)) + if (distanceObjectToObjects( + obj, hash_table->query(overlap_aabb), cdata, callback, min_dist)) { - for(auto it = objs_outside_scene_limit.cbegin(), end = objs_outside_scene_limit.cend(); - it != end; ++it) - { - if(obj == *it) continue; - if(!this->enable_tested_set_) - { - if(obj->getAABB().distance((*it)->getAABB()) < min_dist) - if(callback(obj, *it, cdata, min_dist)) return true; - } - else - { - if(!this->inTestedSet(obj, *it)) - { - if(obj->getAABB().distance((*it)->getAABB()) < min_dist) - if(callback(obj, *it, cdata, min_dist)) return true; - this->insertTestedSet(obj, *it); - } - } - } + return true; } - std::vector*> query_result = hash_table->query(overlap_aabb); - for(unsigned int i = 0; i < query_result.size(); ++i) + if(!scene_limit.contain(aabb)) { - if(obj == query_result[i]) continue; - if(!this->enable_tested_set_) + if (distanceObjectToObjects( + obj, objs_outside_scene_limit, cdata, callback, min_dist)) { - if(obj->getAABB().distance(query_result[i]->getAABB()) < min_dist) - if(callback(obj, query_result[i], cdata, min_dist)) return true; - } - else - { - if(!this->inTestedSet(obj, query_result[i])) - { - if(obj->getAABB().distance(query_result[i]->getAABB()) < min_dist) - if(callback(obj, query_result[i], cdata, min_dist)) return true; - this->insertTestedSet(obj, query_result[i]); - } + return true; } } } else { - for(auto it = objs_outside_scene_limit.cbegin(), end = objs_outside_scene_limit.cend(); - it != end; ++it) + if (distanceObjectToObjects( + obj, objs_partially_penetrating_scene_limit, cdata, callback, min_dist)) { - if(obj == *it) continue; - if(!this->enable_tested_set_) - { - if(obj->getAABB().distance((*it)->getAABB()) < min_dist) - if(callback(obj, *it, cdata, min_dist)) return true; - } - else - { - if(!this->inTestedSet(obj, *it)) - { - if(obj->getAABB().distance((*it)->getAABB()) < min_dist) - if(callback(obj, *it, cdata, min_dist)) return true; - this->insertTestedSet(obj, *it); - } - } + return true; + } + + if (distanceObjectToObjects( + obj, objs_outside_scene_limit, cdata, callback, min_dist)) + { + return true; } } if(status == 1) { if(old_min_distance < std::numeric_limits::max()) + { break; + } else { if(min_dist < old_min_distance) @@ -476,7 +569,9 @@ bool SpatialHashingCollisionManager::distance_(CollisionObject* } } else if(status == 0) + { break; + } } return false; @@ -484,38 +579,59 @@ bool SpatialHashingCollisionManager::distance_(CollisionObject* //============================================================================== template -void SpatialHashingCollisionManager::collide(void* cdata, CollisionCallBack callback) const +void SpatialHashingCollisionManager::collide( + void* cdata, CollisionCallBack callback) const { - if(size() == 0) return; + if(size() == 0) + return; - for(auto it1 = objs.cbegin(), end1 = objs.cend(); it1 != end1; ++it1) + for(const auto& obj1 : objs) { - const AABB& obj_aabb = (*it1)->getAABB(); + const auto& obj_aabb = obj1->getAABB(); AABB overlap_aabb; if(scene_limit.overlap(obj_aabb, overlap_aabb)) { - if(!scene_limit.contain(obj_aabb)) + auto query_result = hash_table->query(overlap_aabb); + for(const auto& obj2 : query_result) { - for(auto it2 = objs_outside_scene_limit.cbegin(), end2 = objs_outside_scene_limit.cend(); - it2 != end2; ++it2) + if(obj1 < obj2) { - if(*it1 < *it2) { if(callback(*it1, *it2, cdata)) return; } + if(callback(obj1, obj2, cdata)) + return; } } - std::vector*> query_result = hash_table->query(overlap_aabb); - for(unsigned int i = 0; i < query_result.size(); ++i) + if(!scene_limit.contain(obj_aabb)) { - if(*it1 < query_result[i]) { if(callback(*it1, query_result[i], cdata)) return; } + for(const auto& obj2 : objs_outside_scene_limit) + { + if(obj1 < obj2) + { + if(callback(obj1, obj2, cdata)) + return; + } + } } } else { - for(auto it2 = objs_outside_scene_limit.cbegin(), end2 = objs_outside_scene_limit.cend(); - it2 != end2; ++it2) + for(const auto& obj2 : objs_partially_penetrating_scene_limit) { - if(*it1 < *it2) { if(callback(*it1, *it2, cdata)) return; } + if(obj1 < obj2) + { + if(callback(obj1, obj2, cdata)) + return; + } + } + + for(const auto& obj2 : objs_outside_scene_limit) + { + if(obj1 < obj2) + { + if(callback(obj1, obj2, cdata)) + return; + } } } } @@ -523,17 +639,22 @@ void SpatialHashingCollisionManager::collide(void* cdata, Collisio //============================================================================== template -void SpatialHashingCollisionManager::distance(void* cdata, DistanceCallBack callback) const +void SpatialHashingCollisionManager::distance( + void* cdata, DistanceCallBack callback) const { - if(size() == 0) return; + if(size() == 0) + return; this->enable_tested_set_ = true; this->tested_set.clear(); S min_dist = std::numeric_limits::max(); - for(auto it = objs.cbegin(), end = objs.cend(); it != end; ++it) - if(distance_(*it, cdata, callback, min_dist)) break; + for(const auto& obj : objs) + { + if(distance_(obj, cdata, callback, min_dist)) + break; + } this->enable_tested_set_ = false; this->tested_set.clear(); @@ -545,7 +666,8 @@ void SpatialHashingCollisionManager::collide(BroadPhaseCollisionMa { auto* other_manager = static_cast* >(other_manager_); - if((size() == 0) || (other_manager->size() == 0)) return; + if((size() == 0) || (other_manager->size() == 0)) + return; if(this == other_manager) { @@ -555,13 +677,19 @@ void SpatialHashingCollisionManager::collide(BroadPhaseCollisionMa if(this->size() < other_manager->size()) { - for(auto it = objs.cbegin(), end = objs.cend(); it != end; ++it) - if(other_manager->collide_(*it, cdata, callback)) return; + for(const auto& obj : objs) + { + if(other_manager->collide_(obj, cdata, callback)) + return; + } } else { - for(auto it = other_manager->objs.cbegin(), end = other_manager->objs.cend(); it != end; ++it) - if(collide_(*it, cdata, callback)) return; + for(const auto& obj : other_manager->objs) + { + if(collide_(obj, cdata, callback)) + return; + } } } @@ -571,7 +699,8 @@ void SpatialHashingCollisionManager::distance(BroadPhaseCollisionM { auto* other_manager = static_cast* >(other_manager_); - if((size() == 0) || (other_manager->size() == 0)) return; + if((size() == 0) || (other_manager->size() == 0)) + return; if(this == other_manager) { @@ -583,13 +712,13 @@ void SpatialHashingCollisionManager::distance(BroadPhaseCollisionM if(this->size() < other_manager->size()) { - for(auto it = objs.cbegin(), end = objs.cend(); it != end; ++it) - if(other_manager->distance_(*it, cdata, callback, min_dist)) return; + for(const auto& obj : objs) + if(other_manager->distance_(obj, cdata, callback, min_dist)) return; } else { - for(auto it = other_manager->objs.cbegin(), end = other_manager->objs.cend(); it != end; ++it) - if(distance_(*it, cdata, callback, min_dist)) return; + for(const auto& obj : other_manager->objs) + if(distance_(obj, cdata, callback, min_dist)) return; } } @@ -620,6 +749,47 @@ void SpatialHashingCollisionManager::computeBound( u = bound.max_; } +//============================================================================== +template +template +bool SpatialHashingCollisionManager::distanceObjectToObjects( + CollisionObject* obj, + const Container& objs, + void* cdata, + DistanceCallBack callback, + S& min_dist) const +{ + for(auto& obj2 : objs) + { + if(obj == obj2) + continue; + + if(!this->enable_tested_set_) + { + if(obj->getAABB().distance(obj2->getAABB()) < min_dist) + { + if(callback(obj, obj2, cdata, min_dist)) + return true; + } + } + else + { + if(!this->inTestedSet(obj, obj2)) + { + if(obj->getAABB().distance(obj2->getAABB()) < min_dist) + { + if(callback(obj, obj2, cdata, min_dist)) + return true; + } + + this->insertTestedSet(obj, obj2); + } + } + } + + return false; +} + } // namespace fcl #endif From 591582b78acc2e88a73ce4578dd4c58e59db24fd Mon Sep 17 00:00:00 2001 From: Jeongseok Lee Date: Fri, 12 Aug 2016 20:51:21 -0400 Subject: [PATCH 03/10] Fix build error on VS2015 --- include/fcl/broadphase/spatial_hash.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/fcl/broadphase/spatial_hash.h b/include/fcl/broadphase/spatial_hash.h index 2a766f4f0..069971a13 100644 --- a/include/fcl/broadphase/spatial_hash.h +++ b/include/fcl/broadphase/spatial_hash.h @@ -71,8 +71,7 @@ using SpatialHashd = SpatialHash; //============================================================================== template -SpatialHash::SpatialHash( - const AABB& scene_limit_, SpatialHash::S cell_size_) +SpatialHash::SpatialHash(const AABB& scene_limit_, S cell_size_) : cell_size(cell_size_), scene_limit(scene_limit_) { width[0] = std::ceil(scene_limit.width() / cell_size); @@ -82,8 +81,7 @@ SpatialHash::SpatialHash( //============================================================================== template -std::vector SpatialHash::operator()( - const AABB& aabb) const +std::vector SpatialHash::operator()(const AABB& aabb) const { int min_x = std::floor((aabb.min_[0] - scene_limit.min_[0]) / cell_size); int max_x = std::ceil((aabb.max_[0] - scene_limit.min_[0]) / cell_size); From af79525f6e7f792582346740c5d7113c3c34f86e Mon Sep 17 00:00:00 2001 From: Jeongseok Lee Date: Fri, 12 Aug 2016 20:53:20 -0400 Subject: [PATCH 04/10] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6354a12dd..6a37feb72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Switched to Eigen for math operations: [#150](https://github.com/flexible-collision-library/fcl/pull/150), [#96](https://github.com/flexible-collision-library/fcl/issues/96) * Added missing copyright headers: [#149](https://github.com/flexible-collision-library/fcl/pull/149) +* Fixed redundant pair checking of SpatialHashingCollisionManager: [#156](https://github.com/flexible-collision-library/fcl/pull/156) * Removed dependency on boost: [#148](https://github.com/flexible-collision-library/fcl/pull/148), [#147](https://github.com/flexible-collision-library/fcl/pull/147), [#146](https://github.com/flexible-collision-library/fcl/pull/146), [#140](https://github.com/flexible-collision-library/fcl/pull/140) ### FCL 0.5.0 (2016-07-19) From aca1eda9627515639e6029ce151191bd02088472 Mon Sep 17 00:00:00 2001 From: Jeongseok Lee Date: Fri, 12 Aug 2016 22:46:06 -0400 Subject: [PATCH 05/10] Add more EIGEN_MAKE_ALIGNED_OPERATOR_NEW to objects contain fixed-size vectorizable Eigen objects --- include/fcl/articulated_model/joint.h | 3 +++ include/fcl/ccd/motion.h | 1 + include/fcl/collision_data.h | 4 ++++ include/fcl/math/sampler_se2.h | 2 ++ include/fcl/narrowphase/detail/gjk.h | 2 ++ .../octree/collision/mesh_octree_collision_traversal_node.h | 2 ++ .../octree/collision/octree_collision_traversal_node.h | 2 ++ .../octree/collision/octree_mesh_collision_traversal_node.h | 2 ++ .../octree/collision/octree_shape_collision_traversal_node.h | 2 ++ .../octree/collision/shape_octree_collision_traversal_node.h | 2 ++ 10 files changed, 22 insertions(+) diff --git a/include/fcl/articulated_model/joint.h b/include/fcl/articulated_model/joint.h index 4414c336f..074b506ee 100644 --- a/include/fcl/articulated_model/joint.h +++ b/include/fcl/articulated_model/joint.h @@ -101,6 +101,9 @@ class Joint std::shared_ptr joint_cfg_; Transform3 transform_to_parent_; + +public: + EIGEN_MAKE_ALIGNED_OPERATOR_NEW }; template diff --git a/include/fcl/ccd/motion.h b/include/fcl/ccd/motion.h index 84ca3ff2d..72b10e807 100644 --- a/include/fcl/ccd/motion.h +++ b/include/fcl/ccd/motion.h @@ -114,6 +114,7 @@ class TranslationMotion : public MotionBase mutable Transform3 tf; +public: EIGEN_MAKE_ALIGNED_OPERATOR_NEW }; diff --git a/include/fcl/collision_data.h b/include/fcl/collision_data.h index 5074df992..ba4800b72 100644 --- a/include/fcl/collision_data.h +++ b/include/fcl/collision_data.h @@ -380,6 +380,8 @@ struct ContinuousCollisionResult Transform3 contact_tf1, contact_tf2; ContinuousCollisionResult(); + + EIGEN_MAKE_ALIGNED_OPERATOR_NEW }; using ContinuousCollisionResultf = ContinuousCollisionResult; @@ -413,6 +415,8 @@ struct PenetrationDepthResult /// @brief the transform where the collision is resolved Transform3 resolved_tf; + + EIGEN_MAKE_ALIGNED_OPERATOR_NEW }; //============================================================================// diff --git a/include/fcl/math/sampler_se2.h b/include/fcl/math/sampler_se2.h index e384960a6..ccb2f6ec1 100644 --- a/include/fcl/math/sampler_se2.h +++ b/include/fcl/math/sampler_se2.h @@ -70,6 +70,8 @@ class SamplerSE2 : public SamplerBase Vector2 lower_bound; Vector2 upper_bound; +public: + EIGEN_MAKE_ALIGNED_OPERATOR_NEW }; using SamplerSE2f = SamplerSE2; diff --git a/include/fcl/narrowphase/detail/gjk.h b/include/fcl/narrowphase/detail/gjk.h index b206943d1..9473af23c 100644 --- a/include/fcl/narrowphase/detail/gjk.h +++ b/include/fcl/narrowphase/detail/gjk.h @@ -118,6 +118,8 @@ struct MinkowskiDiff else return support0(d, v); } + + EIGEN_MAKE_ALIGNED_OPERATOR_NEW }; using MinkowskiDifff = MinkowskiDiff; diff --git a/include/fcl/traversal/octree/collision/mesh_octree_collision_traversal_node.h b/include/fcl/traversal/octree/collision/mesh_octree_collision_traversal_node.h index 126252f80..cbde4cb0f 100644 --- a/include/fcl/traversal/octree/collision/mesh_octree_collision_traversal_node.h +++ b/include/fcl/traversal/octree/collision/mesh_octree_collision_traversal_node.h @@ -72,6 +72,8 @@ class MeshOcTreeCollisionTraversalNode Transform3 tf1, tf2; const OcTreeSolver* otsolver; + + EIGEN_MAKE_ALIGNED_OPERATOR_NEW }; /// @brief Initialize traversal node for collision between one mesh and one diff --git a/include/fcl/traversal/octree/collision/octree_collision_traversal_node.h b/include/fcl/traversal/octree/collision/octree_collision_traversal_node.h index 7759d8ff4..111fec026 100644 --- a/include/fcl/traversal/octree/collision/octree_collision_traversal_node.h +++ b/include/fcl/traversal/octree/collision/octree_collision_traversal_node.h @@ -71,6 +71,8 @@ class OcTreeCollisionTraversalNode Transform3 tf1, tf2; const OcTreeSolver* otsolver; + + EIGEN_MAKE_ALIGNED_OPERATOR_NEW }; /// @brief Initialize traversal node for collision between two octrees, given diff --git a/include/fcl/traversal/octree/collision/octree_mesh_collision_traversal_node.h b/include/fcl/traversal/octree/collision/octree_mesh_collision_traversal_node.h index 02a4ed104..98b622150 100644 --- a/include/fcl/traversal/octree/collision/octree_mesh_collision_traversal_node.h +++ b/include/fcl/traversal/octree/collision/octree_mesh_collision_traversal_node.h @@ -72,6 +72,8 @@ class OcTreeMeshCollisionTraversalNode Transform3 tf1, tf2; const OcTreeSolver* otsolver; + + EIGEN_MAKE_ALIGNED_OPERATOR_NEW }; /// @brief Initialize traversal node for collision between one octree and one diff --git a/include/fcl/traversal/octree/collision/octree_shape_collision_traversal_node.h b/include/fcl/traversal/octree/collision/octree_shape_collision_traversal_node.h index 830090f76..902fc5581 100644 --- a/include/fcl/traversal/octree/collision/octree_shape_collision_traversal_node.h +++ b/include/fcl/traversal/octree/collision/octree_shape_collision_traversal_node.h @@ -72,6 +72,8 @@ class OcTreeShapeCollisionTraversalNode Transform3 tf1, tf2; const OcTreeSolver* otsolver; + + EIGEN_MAKE_ALIGNED_OPERATOR_NEW }; /// @brief Initialize traversal node for collision between one octree and one diff --git a/include/fcl/traversal/octree/collision/shape_octree_collision_traversal_node.h b/include/fcl/traversal/octree/collision/shape_octree_collision_traversal_node.h index eec7f3f79..cc46b34d2 100644 --- a/include/fcl/traversal/octree/collision/shape_octree_collision_traversal_node.h +++ b/include/fcl/traversal/octree/collision/shape_octree_collision_traversal_node.h @@ -72,6 +72,8 @@ class ShapeOcTreeCollisionTraversalNode Transform3 tf1, tf2; const OcTreeSolver* otsolver; + + EIGEN_MAKE_ALIGNED_OPERATOR_NEW }; /// @brief Initialize traversal node for collision between one shape and one From 75cca21752a9cd47e888cea6c6b7c69dc0fc5b04 Mon Sep 17 00:00:00 2001 From: Jeongseok Lee Date: Fri, 12 Aug 2016 22:50:48 -0400 Subject: [PATCH 06/10] Enable Win32 build test on Appveyor --- .appveyor.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index a0a084ba7..ad331af19 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -7,10 +7,10 @@ os: Visual Studio 2015 clone_folder: C:\projects\fcl shallow_clone: true -# branches: -# only: -# - master -platform: x64 +# build platform, i.e. Win32 (instead of x86), x64, Any CPU. This setting is optional. +platform: + - Win32 + - x64 environment: CTEST_OUTPUT_ON_FAILURE: 1 From d3d370c6e689ffd7dd214876c2f9cb21b05ae95d Mon Sep 17 00:00:00 2001 From: Jeongseok Lee Date: Fri, 12 Aug 2016 22:55:12 -0400 Subject: [PATCH 07/10] Fix CMake generator to be aware of platform (Win32|x64) --- .appveyor.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index ad331af19..ffd0dfa8f 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -23,11 +23,13 @@ configuration: - Release before_build: + - cmd: if "%platform%"=="Win32" set CMAKE_GENERATOR_NAME=Visual Studio 14 2015 + - cmd: if "%platform%"=="x64" set CMAKE_GENERATOR_NAME=Visual Studio 14 2015 Win64 - cmd: if not exist C:\"Program Files"\libccd\lib\ccd.lib ( curl -L -o libccd-2.0.tar.gz https://github.com/danfis/libccd/archive/v2.0.tar.gz && cmake -E tar zxf libccd-2.0.tar.gz && cd libccd-2.0 && - cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=%Configuration% . && + cmake -G "%CMAKE_GENERATOR_NAME%" -DCMAKE_BUILD_TYPE=%Configuration% . && cmake --build . --target install --config %Configuration% && cd .. ) else (echo Using cached libccd) @@ -37,14 +39,14 @@ before_build: cd eigen-eigen-dc6cfdf9bcec && mkdir build && cd build && - cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=%Configuration% .. && + cmake -G "%CMAKE_GENERATOR_NAME%" -DCMAKE_BUILD_TYPE=%Configuration% .. && cmake --build . --target install --config %Configuration% && cd ..\.. ) else (echo Using cached Eigen3) - cmd: set - cmd: mkdir build - cmd: cd build - - cmd: cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=%Configuration% -DCCD_INCLUDE_DIRS="C:\Program Files\libccd\include" -DCCD_LIBRARY="C:\Program Files\libccd\lib\ccd.lib" -DEIGEN3_INCLUDE_DIR="C:\Program Files\Eigen\include\eigen3" .. + - cmd: cmake -G "%CMAKE_GENERATOR_NAME%" -DCMAKE_BUILD_TYPE=%Configuration% -DCCD_INCLUDE_DIRS="C:\Program Files\libccd\include" -DCCD_LIBRARY="C:\Program Files\libccd\lib\ccd.lib" -DEIGEN3_INCLUDE_DIR="C:\Program Files\Eigen\include\eigen3" .. build: project: C:\projects\fcl\build\fcl.sln From 9cb648624fde765a8e1c2444a7f46c112be8e6fa Mon Sep 17 00:00:00 2001 From: Jeongseok Lee Date: Fri, 12 Aug 2016 23:07:34 -0400 Subject: [PATCH 08/10] Replace NULL with nullptr --- include/fcl/BV/AABB.h | 2 +- include/fcl/BV/BV_node.h | 6 +- include/fcl/BV/OBB.h | 8 +- include/fcl/BV/OBBRSS.h | 14 ++-- include/fcl/BV/RSS.h | 26 +++--- include/fcl/BV/detail/fitter.h | 28 +++---- include/fcl/BV/kDOP.h | 2 +- include/fcl/BV/kIOS.h | 10 +-- include/fcl/BVH/BVH_model.h | 34 ++++---- include/fcl/BVH/BV_fitter.h | 16 ++-- include/fcl/BVH/BV_splitter.h | 4 +- include/fcl/broadphase/broadphase_SaP.h | 80 +++++++++---------- .../broadphase/broadphase_dynamic_AABB_tree.h | 16 ++-- .../broadphase_dynamic_AABB_tree_array.h | 12 +-- .../fcl/broadphase/broadphase_interval_tree.h | 8 +- include/fcl/broadphase/hierarchy_tree.h | 70 ++++++++-------- include/fcl/broadphase/interval_tree.h | 14 ++-- include/fcl/ccd/conservative_advancement.h | 16 ++-- include/fcl/collision_data.h | 12 +-- include/fcl/collision_func_matrix.h | 2 +- include/fcl/collision_node.h | 10 +-- include/fcl/distance_func_matrix.h | 2 +- include/fcl/intersect.h | 28 +++---- include/fcl/narrowphase/detail/gjk.h | 12 +-- include/fcl/narrowphase/detail/gjk_libccd.h | 18 ++--- include/fcl/narrowphase/gjk_solver_indep.h | 34 ++++---- include/fcl/narrowphase/gjk_solver_libccd.h | 40 +++++----- include/fcl/shape/convex.h | 2 +- .../collision/bvh_collision_traversal_node.h | 4 +- .../bvh_shape_collision_traversal_node.h | 4 +- .../collision/collision_traversal_node_base.h | 2 +- .../collision/mesh_collision_traversal_node.h | 8 +- ...mesh_continuous_collision_traversal_node.h | 12 +-- .../mesh_shape_collision_traversal_node.h | 14 ++-- .../shape_bvh_collision_traversal_node.h | 4 +- .../shape_collision_traversal_node.h | 10 +-- .../shape_mesh_collision_traversal_node.h | 10 +-- .../distance/bvh_distance_traversal_node.h | 4 +- .../bvh_shape_distance_traversal_node.h | 4 +- .../distance/distance_traversal_node_base.h | 2 +- ..._conservative_advancement_traversal_node.h | 4 +- .../distance/mesh_distance_traversal_node.h | 8 +- ..._conservative_advancement_traversal_node.h | 4 +- .../mesh_shape_distance_traversal_node.h | 6 +- .../shape_bvh_distance_traversal_node.h | 4 +- ..._conservative_advancement_traversal_node.h | 4 +- .../distance/shape_distance_traversal_node.h | 6 +- ..._conservative_advancement_traversal_node.h | 4 +- .../shape_mesh_distance_traversal_node.h | 6 +- .../mesh_octree_collision_traversal_node.h | 6 +- .../octree_collision_traversal_node.h | 6 +- .../octree_mesh_collision_traversal_node.h | 6 +- .../octree_shape_collision_traversal_node.h | 6 +- .../shape_octree_collision_traversal_node.h | 6 +- .../mesh_octree_distance_traversal_node.h | 6 +- .../distance/octree_distance_traversal_node.h | 6 +- .../octree_mesh_distance_traversal_node.h | 6 +- .../octree_shape_distance_traversal_node.h | 6 +- .../shape_octree_distance_traversal_node.h | 6 +- include/fcl/traversal/octree/octree_solver.h | 40 +++++----- test/test_fcl_broadphase_collision_1.cpp | 2 +- test/test_fcl_broadphase_collision_2.cpp | 2 +- test/test_fcl_broadphase_distance.cpp | 2 +- test/test_fcl_collision.cpp | 12 +-- test/test_fcl_distance.cpp | 4 +- test/test_fcl_geometric_shapes.cpp | 76 +++++++++--------- test/test_fcl_sphere_capsule.cpp | 8 +- test/test_fcl_utility.cpp | 6 +- test/test_fcl_utility.h | 18 ++--- 69 files changed, 440 insertions(+), 440 deletions(-) diff --git a/include/fcl/BV/AABB.h b/include/fcl/BV/AABB.h index 1e998fc9f..dd97f134f 100644 --- a/include/fcl/BV/AABB.h +++ b/include/fcl/BV/AABB.h @@ -118,7 +118,7 @@ class AABB /// @brief Center of the AABB Vector3 center() const; - /// @brief Distance between two AABBs; P and Q, should not be NULL, return the nearest points + /// @brief Distance between two AABBs; P and Q, should not be nullptr, return the nearest points S distance( const AABB& other, Vector3* P, Vector3* Q) const; diff --git a/include/fcl/BV/BV_node.h b/include/fcl/BV/BV_node.h index 3ecccfd27..fa6f82e0a 100644 --- a/include/fcl/BV/BV_node.h +++ b/include/fcl/BV/BV_node.h @@ -86,12 +86,12 @@ struct BVNode : public BVNodeBase /// @brief Check whether two BVNode collide bool overlap(const BVNode& other) const; - /// @brief Compute the distance between two BVNode. P1 and P2, if not NULL and + /// @brief Compute the distance between two BVNode. P1 and P2, if not nullptr and /// the underlying BV supports distance, return the nearest points. S distance( const BVNode& other, - Vector3* P1 = NULL, - Vector3* P2 = NULL) const; + Vector3* P1 = nullptr, + Vector3* P2 = nullptr) const; /// @brief Access the center of the BV Vector3 getCenter() const; diff --git a/include/fcl/BV/OBB.h b/include/fcl/BV/OBB.h index 63cb5cc9a..25f0cdb39 100644 --- a/include/fcl/BV/OBB.h +++ b/include/fcl/BV/OBB.h @@ -112,8 +112,8 @@ class OBB const Vector3 center() const; /// @brief Distance between two OBBs, not implemented. - S distance(const OBB& other, Vector3* P = NULL, - Vector3* Q = NULL) const; + S distance(const OBB& other, Vector3* P = nullptr, + Vector3* Q = nullptr) const; EIGEN_MAKE_ALIGNED_OPERATOR_NEW @@ -368,7 +368,7 @@ OBB merge_largedist(const OBB& b1, const OBB& b2) vertex_proj[i].noalias() -= b.axis.col(0) * vertex[i].dot(b.axis.col(0)); } - getCovariance(vertex_proj, NULL, NULL, NULL, 16, M); + getCovariance(vertex_proj, nullptr, nullptr, nullptr, 16, M); eigen_old(M, s, E); int min, mid, max; @@ -403,7 +403,7 @@ OBB merge_largedist(const OBB& b1, const OBB& b2) // set obb centers and extensions getExtentAndCenter( - vertex, NULL, NULL, NULL, 16, b.axis, b.To, b.extent); + vertex, nullptr, nullptr, nullptr, 16, b.axis, b.To, b.extent); return b; } diff --git a/include/fcl/BV/OBBRSS.h b/include/fcl/BV/OBBRSS.h index af53b0a5a..02f111d5b 100644 --- a/include/fcl/BV/OBBRSS.h +++ b/include/fcl/BV/OBBRSS.h @@ -95,9 +95,9 @@ class OBBRSS /// @brief Center of the OBBRSS const Vector3 center() const; - /// @brief Distance between two OBBRSS; P and Q , is not NULL, returns the nearest points + /// @brief Distance between two OBBRSS; P and Q , is not nullptr, returns the nearest points S distance(const OBBRSS& other, - Vector3* P = NULL, Vector3* Q = NULL) const; + Vector3* P = nullptr, Vector3* Q = nullptr) const; EIGEN_MAKE_ALIGNED_OPERATOR_NEW @@ -126,23 +126,23 @@ bool overlap( const OBBRSS& b2); /// @brief Computate distance between two OBBRSS, b1 is in configuation (R0, T0) -/// and b2 is in indentity; P and Q, is not NULL, returns the nearest points +/// and b2 is in indentity; P and Q, is not nullptr, returns the nearest points template S distance( const Eigen::MatrixBase& R0, const Eigen::MatrixBase& T0, const OBBRSS& b1, const OBBRSS& b2, - Vector3* P = NULL, Vector3* Q = NULL); + Vector3* P = nullptr, Vector3* Q = nullptr); /// @brief Computate distance between two OBBRSS, b1 is in configuation (R0, T0) -/// and b2 is in indentity; P and Q, is not NULL, returns the nearest points +/// and b2 is in indentity; P and Q, is not nullptr, returns the nearest points template S distance( const Transform3& tf, const OBBRSS& b1, const OBBRSS& b2, - Vector3* P = NULL, - Vector3* Q = NULL); + Vector3* P = nullptr, + Vector3* Q = nullptr); //============================================================================// // // diff --git a/include/fcl/BV/RSS.h b/include/fcl/BV/RSS.h index fa6a081f1..e04b964b0 100644 --- a/include/fcl/BV/RSS.h +++ b/include/fcl/BV/RSS.h @@ -110,10 +110,10 @@ class RSS /// @brief The RSS center const Vector3 center() const; - /// @brief the distance between two RSS; P and Q, if not NULL, return the nearest points + /// @brief the distance between two RSS; P and Q, if not nullptr, return the nearest points S distance(const RSS& other, - Vector3* P = NULL, - Vector3* Q = NULL) const; + Vector3* P = nullptr, + Vector3* Q = nullptr) const; EIGEN_MAKE_ALIGNED_OPERATOR_NEW @@ -161,8 +161,8 @@ S rectDistance( const Vector3& Tab, const S a[2], const S b[2], - Vector3* P = NULL, - Vector3* Q = NULL); + Vector3* P = nullptr, + Vector3* Q = nullptr); /// @brief Distance between two oriented rectangles; P and Q (optional return /// values) are the closest points in the rectangles, both are in the local @@ -172,8 +172,8 @@ S rectDistance( const Transform3& tfab, const S a[2], const S b[2], - Vector3* P = NULL, - Vector3* Q = NULL); + Vector3* P = nullptr, + Vector3* Q = nullptr); /// @brief distance between two RSS bounding volumes /// P and Q (optional return values) are the closest points in the rectangles, @@ -186,8 +186,8 @@ S distance( const Eigen::MatrixBase& T0, const RSS& b1, const RSS& b2, - Vector3* P = NULL, - Vector3* Q = NULL); + Vector3* P = nullptr, + Vector3* Q = nullptr); /// @brief distance between two RSS bounding volumes /// P and Q (optional return values) are the closest points in the rectangles, @@ -199,8 +199,8 @@ S distance( const Transform3& tf, const RSS& b1, const RSS& b2, - Vector3* P = NULL, - Vector3* Q = NULL); + Vector3* P = nullptr, + Vector3* Q = nullptr); /// @brief Check collision between two RSSs, b1 is in configuration (R0, T0) and /// b2 is in identity. @@ -488,7 +488,7 @@ RSS RSS::operator +(const RSS& other) const Matrix3 E; // row first eigen-vectors Vector3 s(0, 0, 0); - getCovariance(v, NULL, NULL, NULL, 16, M); + getCovariance(v, nullptr, nullptr, nullptr, 16, M); eigen_old(M, s, E); int min, mid, max; @@ -504,7 +504,7 @@ RSS RSS::operator +(const RSS& other) const bv.axis.col(2).noalias() = axis.col(0).cross(axis.col(1)); // set rss origin, rectangle size and radius - getRadiusAndOriginAndRectangleSize(v, NULL, NULL, NULL, 16, bv.axis, bv.To, bv.l, bv.r); + getRadiusAndOriginAndRectangleSize(v, nullptr, nullptr, nullptr, 16, bv.axis, bv.To, bv.l, bv.r); return bv; } diff --git a/include/fcl/BV/detail/fitter.h b/include/fcl/BV/detail/fitter.h index a3d7efd89..79c70d4d6 100644 --- a/include/fcl/BV/detail/fitter.h +++ b/include/fcl/BV/detail/fitter.h @@ -109,7 +109,7 @@ void fit3(Vector3* ps, OBB& bv) bv.axis.col(0).normalize(); bv.axis.col(1).noalias() = bv.axis.col(2).cross(bv.axis.col(0)); - getExtentAndCenter(ps, NULL, NULL, NULL, 3, bv.axis, bv.To, bv.extent); + getExtentAndCenter(ps, nullptr, nullptr, nullptr, 3, bv.axis, bv.To, bv.extent); } template @@ -128,12 +128,12 @@ void fitn(Vector3* ps, int n, OBB& bv) Matrix3 E; Vector3 s = Vector3::Zero(); // three eigen values - getCovariance(ps, NULL, NULL, NULL, n, M); + getCovariance(ps, nullptr, nullptr, nullptr, n, M); eigen_old(M, s, E); axisFromEigen(E, s, bv.axis); // set obb centers and extensions - getExtentAndCenter(ps, NULL, NULL, NULL, n, bv.axis, bv.To, bv.extent); + getExtentAndCenter(ps, nullptr, nullptr, nullptr, n, bv.axis, bv.To, bv.extent); } } // namespace OBB_fit_functions @@ -192,7 +192,7 @@ void fit3(Vector3* ps, RSS& bv) bv.axis.col(0).noalias() = e[imax].normalized(); bv.axis.col(1).noalias() = bv.axis.col(2).cross(bv.axis.col(0)); - getRadiusAndOriginAndRectangleSize(ps, NULL, NULL, NULL, 3, bv.axis, bv.To, bv.l, bv.r); + getRadiusAndOriginAndRectangleSize(ps, nullptr, nullptr, nullptr, 3, bv.axis, bv.To, bv.l, bv.r); } template @@ -211,12 +211,12 @@ void fitn(Vector3* ps, int n, RSS& bv) Matrix3 E; // row first eigen-vectors Vector3 s = Vector3::Zero(); - getCovariance(ps, NULL, NULL, NULL, n, M); + getCovariance(ps, nullptr, nullptr, nullptr, n, M); eigen_old(M, s, E); axisFromEigen(E, s, bv.axis); // set rss origin, rectangle size and radius - getRadiusAndOriginAndRectangleSize(ps, NULL, NULL, NULL, n, bv.axis, bv.To, bv.l, bv.r); + getRadiusAndOriginAndRectangleSize(ps, nullptr, nullptr, nullptr, n, bv.axis, bv.To, bv.l, bv.r); } } // namespace RSS_fit_functions @@ -296,7 +296,7 @@ void fit3(Vector3* ps, kIOS& bv) bv.obb.axis.col(0) = e[imax].normalized(); bv.obb.axis.col(1).noalias() = bv.obb.axis.col(2).cross(bv.obb.axis.col(0)); - getExtentAndCenter(ps, NULL, NULL, NULL, 3, bv.obb.axis, bv.obb.To, bv.obb.extent); + getExtentAndCenter(ps, nullptr, nullptr, nullptr, 3, bv.obb.axis, bv.obb.To, bv.obb.extent); // compute radius and center S r0; @@ -322,16 +322,16 @@ void fitn(Vector3* ps, int n, kIOS& bv) Matrix3 E; Vector3 s = Vector3::Zero(); // three eigen values; - getCovariance(ps, NULL, NULL, NULL, n, M); + getCovariance(ps, nullptr, nullptr, nullptr, n, M); eigen_old(M, s, E); axisFromEigen(E, s, bv.obb.axis); - getExtentAndCenter(ps, NULL, NULL, NULL, n, bv.obb.axis, bv.obb.To, bv.obb.extent); + getExtentAndCenter(ps, nullptr, nullptr, nullptr, n, bv.obb.axis, bv.obb.To, bv.obb.extent); // get center and extension const Vector3& center = bv.obb.To; const Vector3& extent = bv.obb.extent; - S r0 = maximumDistance(ps, NULL, NULL, NULL, n, center); + S r0 = maximumDistance(ps, nullptr, nullptr, nullptr, n, center); // decide the k in kIOS if(extent[0] > kIOS::ratio() * extent[2]) @@ -353,8 +353,8 @@ void fitn(Vector3* ps, int n, kIOS& bv) bv.spheres[2].o = center + delta; S r11 = 0, r12 = 0; - r11 = maximumDistance(ps, NULL, NULL, NULL, n, bv.spheres[1].o); - r12 = maximumDistance(ps, NULL, NULL, NULL, n, bv.spheres[2].o); + r11 = maximumDistance(ps, nullptr, nullptr, nullptr, n, bv.spheres[1].o); + r12 = maximumDistance(ps, nullptr, nullptr, nullptr, n, bv.spheres[2].o); bv.spheres[1].o.noalias() += bv.obb.axis.col(2) * (-r10 + r11); bv.spheres[2].o.noalias() += bv.obb.axis.col(2) * (r10 - r12); @@ -370,8 +370,8 @@ void fitn(Vector3* ps, int n, kIOS& bv) bv.spheres[4].o = bv.spheres[0].o + delta; S r21 = 0, r22 = 0; - r21 = maximumDistance(ps, NULL, NULL, NULL, n, bv.spheres[3].o); - r22 = maximumDistance(ps, NULL, NULL, NULL, n, bv.spheres[4].o); + r21 = maximumDistance(ps, nullptr, nullptr, nullptr, n, bv.spheres[3].o); + r22 = maximumDistance(ps, nullptr, nullptr, nullptr, n, bv.spheres[4].o); bv.spheres[3].o.noalias() += bv.obb.axis.col(1) * (-r10 + r21); bv.spheres[4].o.noalias() += bv.obb.axis.col(1) * (r10 - r22); diff --git a/include/fcl/BV/kDOP.h b/include/fcl/BV/kDOP.h index a6b4ce512..a2a1bd606 100644 --- a/include/fcl/BV/kDOP.h +++ b/include/fcl/BV/kDOP.h @@ -132,7 +132,7 @@ class KDOP /// @brief The distance between two KDOP. Not implemented. S distance( const KDOP& other, - Vector3* P = NULL, Vector3* Q = NULL) const; + Vector3* P = nullptr, Vector3* Q = nullptr) const; private: /// @brief Origin's distances to N KDOP planes diff --git a/include/fcl/BV/kIOS.h b/include/fcl/BV/kIOS.h index 88a8ebaa2..8bc6e6841 100644 --- a/include/fcl/BV/kIOS.h +++ b/include/fcl/BV/kIOS.h @@ -114,7 +114,7 @@ class kIOS /// @brief The distance between two kIOS S distance( const kIOS& other, - Vector3* P = NULL, Vector3* Q = NULL) const; + Vector3* P = nullptr, Vector3* Q = nullptr) const; static constexpr S ratio() { return 1.5; } static constexpr S invSinA() { return 2; } @@ -155,8 +155,8 @@ S distance( const Eigen::MatrixBase& T0, const kIOS& b1, const kIOS& b2, - Vector3* P = NULL, - Vector3* Q = NULL); + Vector3* P = nullptr, + Vector3* Q = nullptr); /// @brief Approximate distance between two kIOS bounding volumes /// @todo P and Q is not returned, need implementation @@ -165,8 +165,8 @@ S distance( const Transform3& tf, const kIOS& b1, const kIOS& b2, - Vector3* P = NULL, - Vector3* Q = NULL); + Vector3* P = nullptr, + Vector3* Q = nullptr); //============================================================================// // // diff --git a/include/fcl/BVH/BVH_model.h b/include/fcl/BVH/BVH_model.h index 9ec29a6c4..09d3437d6 100644 --- a/include/fcl/BVH/BVH_model.h +++ b/include/fcl/BVH/BVH_model.h @@ -161,7 +161,7 @@ class BVHModel : public CollisionGeometry /// @brief Geometry point data Vector3* vertices; - /// @brief Geometry triangle index data, will be NULL for point clouds + /// @brief Geometry triangle index data, will be nullptr for point clouds Triangle* tri_indices; /// @brief Geometry point data in previous frame @@ -248,9 +248,9 @@ BVHModelType BVHModel::getModelType() const //============================================================================== template -BVHModel::BVHModel() : vertices(NULL), - tri_indices(NULL), - prev_vertices(NULL), +BVHModel::BVHModel() : vertices(nullptr), + tri_indices(nullptr), + prev_vertices(nullptr), num_tris(0), num_vertices(0), build_state(BVH_BUILD_STATE_EMPTY), @@ -260,8 +260,8 @@ BVHModel::BVHModel() : vertices(NULL), num_vertices_allocated(0), num_bvs_allocated(0), num_vertex_updated(0), - primitive_indices(NULL), - bvs(NULL), + primitive_indices(nullptr), + bvs(nullptr), num_bvs(0) { // Do nothing @@ -285,7 +285,7 @@ BVHModel::BVHModel(const BVHModel& other) memcpy(vertices, other.vertices, sizeof(Vector3) * num_vertices); } else - vertices = NULL; + vertices = nullptr; if(other.tri_indices) { @@ -293,7 +293,7 @@ BVHModel::BVHModel(const BVHModel& other) memcpy(tri_indices, other.tri_indices, sizeof(Triangle) * num_tris); } else - tri_indices = NULL; + tri_indices = nullptr; if(other.prev_vertices) { @@ -301,7 +301,7 @@ BVHModel::BVHModel(const BVHModel& other) memcpy(prev_vertices, other.prev_vertices, sizeof(Vector3) * num_vertices); } else - prev_vertices = NULL; + prev_vertices = nullptr; if(other.primitive_indices) { @@ -322,7 +322,7 @@ BVHModel::BVHModel(const BVHModel& other) memcpy(primitive_indices, other.primitive_indices, sizeof(unsigned int) * num_primitives); } else - primitive_indices = NULL; + primitive_indices = nullptr; num_bvs = num_bvs_allocated = other.num_bvs; if(other.bvs) @@ -331,7 +331,7 @@ BVHModel::BVHModel(const BVHModel& other) memcpy(bvs, other.bvs, sizeof(BVNode) * num_bvs); } else - bvs = NULL; + bvs = nullptr; } //============================================================================== @@ -397,11 +397,11 @@ int BVHModel::beginModel(int num_tris_, int num_vertices_) { if(build_state != BVH_BUILD_STATE_EMPTY) { - delete [] vertices; vertices = NULL; - delete [] tri_indices; tri_indices = NULL; - delete [] bvs; bvs = NULL; - delete [] prev_vertices; prev_vertices = NULL; - delete [] primitive_indices; primitive_indices = NULL; + delete [] vertices; vertices = nullptr; + delete [] tri_indices; tri_indices = nullptr; + delete [] bvs; bvs = nullptr; + delete [] prev_vertices; prev_vertices = nullptr; + delete [] primitive_indices; primitive_indices = nullptr; num_vertices_allocated = num_vertices = num_tris_allocated = num_tris = num_bvs_allocated = num_bvs = 0; } @@ -704,7 +704,7 @@ int BVHModel::beginReplaceModel() return BVH_ERR_BUILD_EMPTY_PREVIOUS_FRAME; } - if(prev_vertices) delete [] prev_vertices; prev_vertices = NULL; + if(prev_vertices) delete [] prev_vertices; prev_vertices = nullptr; num_vertex_updated = 0; diff --git a/include/fcl/BVH/BV_fitter.h b/include/fcl/BVH/BV_fitter.h index 314fa5786..137643e07 100644 --- a/include/fcl/BVH/BV_fitter.h +++ b/include/fcl/BVH/BV_fitter.h @@ -166,9 +166,9 @@ BV BVFitter::fit(unsigned int* primitive_indices, int num_primitives) template void BVFitter::clear() { - vertices = NULL; - prev_vertices = NULL; - tri_indices = NULL; + vertices = nullptr; + prev_vertices = nullptr; + tri_indices = nullptr; type = BVH_MODEL_UNKNOWN; } @@ -183,7 +183,7 @@ struct SetImpl BVHModelType type_) { fitter.vertices = vertices_; - fitter.prev_vertices = NULL; + fitter.prev_vertices = nullptr; fitter.tri_indices = tri_indices_; fitter.type = type_; } @@ -213,7 +213,7 @@ struct SetImpl> BVHModelType type_) { fitter.vertices = vertices_; - fitter.prev_vertices = NULL; + fitter.prev_vertices = nullptr; fitter.tri_indices = tri_indices_; fitter.type = type_; } @@ -243,7 +243,7 @@ struct SetImpl> BVHModelType type_) { fitter.vertices = vertices_; - fitter.prev_vertices = NULL; + fitter.prev_vertices = nullptr; fitter.tri_indices = tri_indices_; fitter.type = type_; } @@ -273,7 +273,7 @@ struct SetImpl> BVHModelType type_) { fitter.vertices = vertices_; - fitter.prev_vertices = NULL; + fitter.prev_vertices = nullptr; fitter.tri_indices = tri_indices_; fitter.type = type_; } @@ -303,7 +303,7 @@ struct SetImpl> BVHModelType type_) { fitter.vertices = vertices_; - fitter.prev_vertices = NULL; + fitter.prev_vertices = nullptr; fitter.tri_indices = tri_indices_; fitter.type = type_; } diff --git a/include/fcl/BVH/BV_splitter.h b/include/fcl/BVH/BV_splitter.h index 1373b75e0..7c1b44b7b 100644 --- a/include/fcl/BVH/BV_splitter.h +++ b/include/fcl/BVH/BV_splitter.h @@ -652,8 +652,8 @@ struct ApplyImpl> template void BVSplitter::clear() { - vertices = NULL; - tri_indices = NULL; + vertices = nullptr; + tri_indices = nullptr; type = BVH_MODEL_UNKNOWN; } diff --git a/include/fcl/broadphase/broadphase_SaP.h b/include/fcl/broadphase/broadphase_SaP.h index b72cf8d4d..4a42b24ec 100644 --- a/include/fcl/broadphase/broadphase_SaP.h +++ b/include/fcl/broadphase/broadphase_SaP.h @@ -54,9 +54,9 @@ class SaPCollisionManager : public BroadPhaseCollisionManager SaPCollisionManager() { - elist[0] = NULL; - elist[1] = NULL; - elist[2] = NULL; + elist[0] = nullptr; + elist[1] = nullptr; + elist[2] = nullptr; optimal_axis = 0; } @@ -339,12 +339,12 @@ void SaPCollisionManager::unregisterObject(CollisionObject* obj) return; SaPAABB* curr = *it; - *it = NULL; + *it = nullptr; for(int coord = 0; coord < 3; ++coord) { //first delete the lo endpoint of the interval. - if(curr->lo->prev[coord] == NULL) + if(curr->lo->prev[coord] == nullptr) elist[coord] = curr->lo->next[coord]; else curr->lo->prev[coord]->next[coord] = curr->lo->next[coord]; @@ -352,12 +352,12 @@ void SaPCollisionManager::unregisterObject(CollisionObject* obj) curr->lo->next[coord]->prev[coord] = curr->lo->prev[coord]; //then, delete the "hi" endpoint. - if(curr->hi->prev[coord] == NULL) + if(curr->hi->prev[coord] == nullptr) elist[coord] = curr->hi->next[coord]; else curr->hi->prev[coord]->next[coord] = curr->hi->next[coord]; - if(curr->hi->next[coord] != NULL) + if(curr->hi->next[coord] != nullptr) curr->hi->next[coord]->prev[coord] = curr->hi->prev[coord]; } @@ -406,7 +406,7 @@ void SaPCollisionManager::registerObjects(const std::vector(&EndPoint::getVal), std::placeholders::_1, coord), std::bind(static_cast(&EndPoint::getVal), std::placeholders::_2, coord))); - endpoints[0]->prev[coord] = NULL; + endpoints[0]->prev[coord] = nullptr; endpoints[0]->next[coord] = endpoints[1]; for(size_t i = 1; i < endpoints.size() - 1; ++i) { @@ -414,7 +414,7 @@ void SaPCollisionManager::registerObjects(const std::vectornext[coord] = endpoints[i+1]; } endpoints[endpoints.size() - 1]->prev[coord] = endpoints[endpoints.size() - 2]; - endpoints[endpoints.size() - 1]->next[coord] = NULL; + endpoints[endpoints.size() - 1]->next[coord] = nullptr; elist[coord] = endpoints[0]; @@ -427,23 +427,23 @@ void SaPCollisionManager::registerObjects(const std::vectoraabb; EndPoint* pos_it = pos->next[axis]; - while(pos_it != NULL) + while(pos_it != nullptr) { if(pos_it->aabb == aabb) { - if(pos_next == NULL) pos_next = pos_it; + if(pos_next == nullptr) pos_next = pos_it; break; } if(pos_it->minmax == 0) { - if(pos_next == NULL) pos_next = pos_it; + if(pos_next == nullptr) pos_next = pos_it; if(pos_it->aabb->cached.overlap(aabb->cached)) overlap_pairs.emplace_back(pos_it->aabb->obj, aabb->obj); } @@ -477,23 +477,23 @@ void SaPCollisionManager::registerObject(CollisionObject* obj) EndPoint* current = elist[coord]; // first insert the lo end point - if(current == NULL) // empty list + if(current == nullptr) // empty list { elist[coord] = curr->lo; - curr->lo->prev[coord] = curr->lo->next[coord] = NULL; + curr->lo->prev[coord] = curr->lo->next[coord] = nullptr; } else // otherwise, find the correct location in the list and insert { EndPoint* curr_lo = curr->lo; S curr_lo_val = curr_lo->getVal()[coord]; - while((current->getVal()[coord] < curr_lo_val) && (current->next[coord] != NULL)) + while((current->getVal()[coord] < curr_lo_val) && (current->next[coord] != nullptr)) current = current->next[coord]; if(current->getVal()[coord] >= curr_lo_val) { curr_lo->prev[coord] = current->prev[coord]; curr_lo->next[coord] = current; - if(current->prev[coord] == NULL) + if(current->prev[coord] == nullptr) elist[coord] = curr_lo; else current->prev[coord]->next[coord] = curr_lo; @@ -503,7 +503,7 @@ void SaPCollisionManager::registerObject(CollisionObject* obj) else { curr_lo->prev[coord] = current; - curr_lo->next[coord] = NULL; + curr_lo->next[coord] = nullptr; current->next[coord] = curr_lo; } } @@ -516,7 +516,7 @@ void SaPCollisionManager::registerObject(CollisionObject* obj) if(coord == 0) { - while((current->getVal()[coord] < curr_hi_val) && (current->next[coord] != NULL)) + while((current->getVal()[coord] < curr_hi_val) && (current->next[coord] != nullptr)) { if(current != curr->lo) if(current->aabb->cached.overlap(curr->cached)) @@ -527,7 +527,7 @@ void SaPCollisionManager::registerObject(CollisionObject* obj) } else { - while((current->getVal()[coord] < curr_hi_val) && (current->next[coord] != NULL)) + while((current->getVal()[coord] < curr_hi_val) && (current->next[coord] != nullptr)) current = current->next[coord]; } @@ -535,7 +535,7 @@ void SaPCollisionManager::registerObject(CollisionObject* obj) { curr_hi->prev[coord] = current->prev[coord]; curr_hi->next[coord] = current; - if(current->prev[coord] == NULL) + if(current->prev[coord] == nullptr) elist[coord] = curr_hi; else current->prev[coord]->next[coord] = curr_hi; @@ -545,7 +545,7 @@ void SaPCollisionManager::registerObject(CollisionObject* obj) else { curr_hi->prev[coord] = current; - curr_hi->next[coord] = NULL; + curr_hi->next[coord] = nullptr; current->next[coord] = curr_hi; } } @@ -602,10 +602,10 @@ void SaPCollisionManager::update_(SaPAABB* updated_aabb) if(direction == -1) { //first update the "lo" endpoint of the interval - if(current->lo->prev[coord] != NULL) + if(current->lo->prev[coord] != nullptr) { temp = current->lo; - while((temp != NULL) && (temp->getVal(coord) > new_min[coord])) + while((temp != nullptr) && (temp->getVal(coord) > new_min[coord])) { if(temp->minmax == 1) if(temp->aabb->cached.overlap(dummy.cached)) @@ -613,11 +613,11 @@ void SaPCollisionManager::update_(SaPAABB* updated_aabb) temp = temp->prev[coord]; } - if(temp == NULL) + if(temp == nullptr) { current->lo->prev[coord]->next[coord] = current->lo->next[coord]; current->lo->next[coord]->prev[coord] = current->lo->prev[coord]; - current->lo->prev[coord] = NULL; + current->lo->prev[coord] = nullptr; current->lo->next[coord] = elist[coord]; elist[coord]->prev[coord] = current->lo; elist[coord] = current->lo; @@ -645,11 +645,11 @@ void SaPCollisionManager::update_(SaPAABB* updated_aabb) } current->hi->prev[coord]->next[coord] = current->hi->next[coord]; - if(current->hi->next[coord] != NULL) + if(current->hi->next[coord] != nullptr) current->hi->next[coord]->prev[coord] = current->hi->prev[coord]; current->hi->prev[coord] = temp; current->hi->next[coord] = temp->next[coord]; - if(temp->next[coord] != NULL) + if(temp->next[coord] != nullptr) temp->next[coord]->prev[coord] = current->hi; temp->next[coord] = current->hi; @@ -658,10 +658,10 @@ void SaPCollisionManager::update_(SaPAABB* updated_aabb) else if(direction == 1) { //here, we first update the "hi" endpoint. - if(current->hi->next[coord] != NULL) + if(current->hi->next[coord] != nullptr) { temp = current->hi; - while((temp->next[coord] != NULL) && (temp->getVal(coord) < new_max[coord])) + while((temp->next[coord] != nullptr) && (temp->getVal(coord) < new_max[coord])) { if(temp->minmax == 0) if(temp->aabb->cached.overlap(dummy.cached)) @@ -674,7 +674,7 @@ void SaPCollisionManager::update_(SaPAABB* updated_aabb) current->hi->prev[coord]->next[coord] = current->hi->next[coord]; current->hi->next[coord]->prev[coord] = current->hi->prev[coord]; current->hi->prev[coord] = temp; - current->hi->next[coord] = NULL; + current->hi->next[coord] = nullptr; temp->next[coord] = current->hi; } else @@ -700,14 +700,14 @@ void SaPCollisionManager::update_(SaPAABB* updated_aabb) temp = temp->next[coord]; } - if(current->lo->prev[coord] != NULL) + if(current->lo->prev[coord] != nullptr) current->lo->prev[coord]->next[coord] = current->lo->next[coord]; else elist[coord] = current->lo->next[coord]; current->lo->next[coord]->prev[coord] = current->lo->prev[coord]; current->lo->prev[coord] = temp->prev[coord]; current->lo->next[coord] = temp; - if(temp->prev[coord] != NULL) + if(temp->prev[coord] != nullptr) temp->prev[coord]->next[coord] = current->lo; else elist[coord] = current->lo; @@ -763,15 +763,15 @@ void SaPCollisionManager::clear() delete (*it)->hi; delete (*it)->lo; delete *it; - *it = NULL; + *it = nullptr; } AABB_arr.clear(); overlap_pairs.clear(); - elist[0] = NULL; - elist[1] = NULL; - elist[2] = NULL; + elist[0] = nullptr; + elist[1] = nullptr; + elist[2] = nullptr; velist[0].clear(); velist[1].clear(); @@ -814,7 +814,7 @@ bool SaPCollisionManager::collide_(CollisionObject* obj, void* cdata, Coll std::bind(static_cast(&EndPoint::getVal), std::placeholders::_1, axis), std::bind(static_cast(&EndPoint::getVal), std::placeholders::_2, axis))); - EndPoint* end_pos = NULL; + EndPoint* end_pos = nullptr; if(res_it != velist[axis].end()) end_pos = *res_it; @@ -884,7 +884,7 @@ bool SaPCollisionManager::distance_(CollisionObject* obj, void* cdata, Dis std::bind(static_cast(&EndPoint::getVal), std::placeholders::_1, axis), std::bind(static_cast(&EndPoint::getVal), std::placeholders::_2, axis))); - EndPoint* end_pos = NULL; + EndPoint* end_pos = nullptr; if(res_it != velist[axis].end()) end_pos = *res_it; diff --git a/include/fcl/broadphase/broadphase_dynamic_AABB_tree.h b/include/fcl/broadphase/broadphase_dynamic_AABB_tree.h index 2e2649368..755375aaa 100644 --- a/include/fcl/broadphase/broadphase_dynamic_AABB_tree.h +++ b/include/fcl/broadphase/broadphase_dynamic_AABB_tree.h @@ -218,9 +218,9 @@ bool collisionRecurse_( } else { - if(collisionRecurse_(root1->children[0], tree2, NULL, root2_bv, tf2, cdata, callback)) + if(collisionRecurse_(root1->children[0], tree2, nullptr, root2_bv, tf2, cdata, callback)) return true; - if(collisionRecurse_(root1->children[1], tree2, NULL, root2_bv, tf2, cdata, callback)) + if(collisionRecurse_(root1->children[1], tree2, nullptr, root2_bv, tf2, cdata, callback)) return true; } @@ -283,7 +283,7 @@ bool collisionRecurse_( { AABB child_bv; computeChildBV(root2_bv, i, child_bv); - if(collisionRecurse_(root1, tree2, NULL, child_bv, tf2, cdata, callback)) + if(collisionRecurse_(root1, tree2, nullptr, child_bv, tf2, cdata, callback)) return true; } } @@ -328,9 +328,9 @@ bool collisionRecurse_( } else { - if(collisionRecurse_(root1->children[0], tree2, NULL, root2_bv, translation2, cdata, callback)) + if(collisionRecurse_(root1->children[0], tree2, nullptr, root2_bv, translation2, cdata, callback)) return true; - if(collisionRecurse_(root1->children[1], tree2, NULL, root2_bv, translation2, cdata, callback)) + if(collisionRecurse_(root1->children[1], tree2, nullptr, root2_bv, translation2, cdata, callback)) return true; } @@ -389,7 +389,7 @@ bool collisionRecurse_( { AABB child_bv; computeChildBV(root2_bv, i, child_bv); - if(collisionRecurse_(root1, tree2, NULL, child_bv, translation2, cdata, callback)) + if(collisionRecurse_(root1, tree2, nullptr, child_bv, translation2, cdata, callback)) return true; } } @@ -852,8 +852,8 @@ void DynamicAABBTreeCollisionManager::registerObjects(const std::vectorbv = other_objs[i]->getAABB(); - node->parent = NULL; - node->children[1] = NULL; + node->parent = nullptr; + node->children[1] = nullptr; node->data = other_objs[i]; table[other_objs[i]] = node; leaves[i] = node; diff --git a/include/fcl/broadphase/broadphase_dynamic_AABB_tree_array.h b/include/fcl/broadphase/broadphase_dynamic_AABB_tree_array.h index 555a520d0..9a1ac19d1 100644 --- a/include/fcl/broadphase/broadphase_dynamic_AABB_tree_array.h +++ b/include/fcl/broadphase/broadphase_dynamic_AABB_tree_array.h @@ -219,9 +219,9 @@ bool collisionRecurse_( } else { - if(collisionRecurse_(nodes1, root1->children[0], tree2, NULL, root2_bv, tf2, cdata, callback)) + if(collisionRecurse_(nodes1, root1->children[0], tree2, nullptr, root2_bv, tf2, cdata, callback)) return true; - if(collisionRecurse_(nodes1, root1->children[1], tree2, NULL, root2_bv, tf2, cdata, callback)) + if(collisionRecurse_(nodes1, root1->children[1], tree2, nullptr, root2_bv, tf2, cdata, callback)) return true; } @@ -283,7 +283,7 @@ bool collisionRecurse_( { AABB child_bv; computeChildBV(root2_bv, i, child_bv); - if(collisionRecurse_(nodes1, root1_id, tree2, NULL, child_bv, tf2, cdata, callback)) + if(collisionRecurse_(nodes1, root1_id, tree2, nullptr, child_bv, tf2, cdata, callback)) return true; } } @@ -331,9 +331,9 @@ bool collisionRecurse_( } else { - if(collisionRecurse_(nodes1, root1->children[0], tree2, NULL, root2_bv, translation2, cdata, callback)) + if(collisionRecurse_(nodes1, root1->children[0], tree2, nullptr, root2_bv, translation2, cdata, callback)) return true; - if(collisionRecurse_(nodes1, root1->children[1], tree2, NULL, root2_bv, translation2, cdata, callback)) + if(collisionRecurse_(nodes1, root1->children[1], tree2, nullptr, root2_bv, translation2, cdata, callback)) return true; } @@ -391,7 +391,7 @@ bool collisionRecurse_( { AABB child_bv; computeChildBV(root2_bv, i, child_bv); - if(collisionRecurse_(nodes1, root1_id, tree2, NULL, child_bv, translation2, cdata, callback)) + if(collisionRecurse_(nodes1, root1_id, tree2, nullptr, child_bv, translation2, cdata, callback)) return true; } } diff --git a/include/fcl/broadphase/broadphase_interval_tree.h b/include/fcl/broadphase/broadphase_interval_tree.h index 9182b7445..96468d94c 100644 --- a/include/fcl/broadphase/broadphase_interval_tree.h +++ b/include/fcl/broadphase/broadphase_interval_tree.h @@ -54,7 +54,7 @@ class IntervalTreeCollisionManager : public BroadPhaseCollisionManager IntervalTreeCollisionManager() : setup_(false) { for(int i = 0; i < 3; ++i) - interval_trees[i] = NULL; + interval_trees[i] = nullptr; } ~IntervalTreeCollisionManager() @@ -444,9 +444,9 @@ void IntervalTreeCollisionManager::clear() endpoints[1].clear(); endpoints[2].clear(); - delete interval_trees[0]; interval_trees[0] = NULL; - delete interval_trees[1]; interval_trees[1] = NULL; - delete interval_trees[2]; interval_trees[2] = NULL; + delete interval_trees[0]; interval_trees[0] = nullptr; + delete interval_trees[1]; interval_trees[1] = nullptr; + delete interval_trees[2]; interval_trees[2] = nullptr; for(int i = 0; i < 3; ++i) { diff --git a/include/fcl/broadphase/hierarchy_tree.h b/include/fcl/broadphase/hierarchy_tree.h index 7d2503a68..4501017f1 100644 --- a/include/fcl/broadphase/hierarchy_tree.h +++ b/include/fcl/broadphase/hierarchy_tree.h @@ -60,7 +60,7 @@ struct NodeBase NodeBase* parent; /// @brief whether is a leaf - bool isLeaf() const { return (children[1] == NULL); } + bool isLeaf() const { return (children[1] == nullptr); } /// @brief whether is internal node bool isInternal() const { return !isLeaf(); } @@ -77,9 +77,9 @@ struct NodeBase NodeBase() { - parent = NULL; - children[0] = NULL; - children[1] = NULL; + parent = nullptr; + children[0] = nullptr; + children[1] = nullptr; } }; @@ -619,9 +619,9 @@ const size_t HierarchyTree::NULL_NODE; template HierarchyTree::HierarchyTree(int bu_threshold_, int topdown_level_) { - root_node = NULL; + root_node = nullptr; n_leaves = 0; - free_node = NULL; + free_node = nullptr; max_lookahead_level = -1; opath = 0; bu_threshold = bu_threshold_; @@ -659,7 +659,7 @@ void HierarchyTree::init(std::vector& leaves, int level) template typename HierarchyTree::NodeType* HierarchyTree::insert(const BV& bv, void* data) { - NodeType* leaf = createNode(NULL, bv, data); + NodeType* leaf = createNode(nullptr, bv, data); insertLeaf(root_node, leaf); ++n_leaves; return leaf; @@ -680,7 +680,7 @@ void HierarchyTree::clear() recurseDeleteNode(root_node); n_leaves = 0; delete free_node; - free_node = NULL; + free_node = nullptr; max_lookahead_level = -1; opath = 0; } @@ -688,7 +688,7 @@ void HierarchyTree::clear() template bool HierarchyTree::empty() const { - return (NULL == root_node); + return (nullptr == root_node); } template @@ -898,7 +898,7 @@ void HierarchyTree::bottomup(const NodeVecIterator lbeg, const NodeVecIterat } NodeType* n[2] = {*min_it1, *min_it2}; - NodeType* p = createNode(NULL, n[0]->bv, n[1]->bv, NULL); + NodeType* p = createNode(nullptr, n[0]->bv, n[1]->bv, nullptr); p->children[0] = n[0]; p->children[1] = n[1]; n[0]->parent = p; @@ -973,7 +973,7 @@ typename HierarchyTree::NodeType* HierarchyTree::topdown_0(const NodeVec NodeVecIterator lcenter = lbeg + num_leaves / 2; std::nth_element(lbeg, lcenter, lend, std::bind(&nodeBaseLess, std::placeholders::_1, std::placeholders::_2, std::ref(best_axis))); - NodeType* node = createNode(NULL, vol, NULL); + NodeType* node = createNode(nullptr, vol, nullptr); node->children[0] = topdown_0(lbeg, lcenter); node->children[1] = topdown_0(lcenter, lend); node->children[0]->parent = node; @@ -1044,7 +1044,7 @@ typename HierarchyTree::NodeType* HierarchyTree::topdown_1(const NodeVec } } - NodeType* node = createNode(NULL, vol, NULL); + NodeType* node = createNode(nullptr, vol, nullptr); node->children[0] = topdown_1(lbeg, lcenter); node->children[1] = topdown_1(lcenter, lend); node->children[0]->parent = node; @@ -1174,7 +1174,7 @@ typename HierarchyTree::NodeType* HierarchyTree::mortonRecurse_0(const N NodeType* child1 = mortonRecurse_0(lbeg, lcenter, split1, bits - 1); NodeType* child2 = mortonRecurse_0(lcenter, lend, split2, bits - 1); - NodeType* node = createNode(NULL, NULL); + NodeType* node = createNode(nullptr, nullptr); node->children[0] = child1; node->children[1] = child2; child1->parent = node; @@ -1221,7 +1221,7 @@ typename HierarchyTree::NodeType* HierarchyTree::mortonRecurse_1(const N NodeType* child1 = mortonRecurse_1(lbeg, lcenter, split1, bits - 1); NodeType* child2 = mortonRecurse_1(lcenter, lend, split2, bits - 1); - NodeType* node = createNode(NULL, NULL); + NodeType* node = createNode(nullptr, nullptr); node->children[0] = child1; node->children[1] = child2; child1->parent = node; @@ -1233,7 +1233,7 @@ typename HierarchyTree::NodeType* HierarchyTree::mortonRecurse_1(const N { NodeType* child1 = mortonRecurse_1(lbeg, lbeg + num_leaves / 2, 0, bits - 1); NodeType* child2 = mortonRecurse_1(lbeg + num_leaves / 2, lend, 0, bits - 1); - NodeType* node = createNode(NULL, NULL); + NodeType* node = createNode(nullptr, nullptr); node->children[0] = child1; node->children[1] = child2; child1->parent = node; @@ -1253,7 +1253,7 @@ typename HierarchyTree::NodeType* HierarchyTree::mortonRecurse_2(const N { NodeType* child1 = mortonRecurse_2(lbeg, lbeg + num_leaves / 2); NodeType* child2 = mortonRecurse_2(lbeg + num_leaves / 2, lend); - NodeType* node = createNode(NULL, NULL); + NodeType* node = createNode(nullptr, nullptr); node->children[0] = child1; node->children[1] = child2; child1->parent = node; @@ -1316,7 +1316,7 @@ void HierarchyTree::insertLeaf(NodeType* root, NodeType* leaf) if(!root_node) { root_node = leaf; - leaf->parent = NULL; + leaf->parent = nullptr; } else { @@ -1330,7 +1330,7 @@ void HierarchyTree::insertLeaf(NodeType* root, NodeType* leaf) } NodeType* prev = root->parent; - NodeType* node = createNode(prev, leaf->bv, root->bv, NULL); + NodeType* node = createNode(prev, leaf->bv, root->bv, nullptr); if(prev) { prev->children[indexOf(root)] = node; @@ -1343,7 +1343,7 @@ void HierarchyTree::insertLeaf(NodeType* root, NodeType* leaf) else break; node = prev; - } while (NULL != (prev = node->parent)); + } while (nullptr != (prev = node->parent)); } else { @@ -1359,8 +1359,8 @@ typename HierarchyTree::NodeType* HierarchyTree::removeLeaf(NodeType* le { if(leaf == root_node) { - root_node = NULL; - return NULL; + root_node = nullptr; + return nullptr; } else { @@ -1388,7 +1388,7 @@ typename HierarchyTree::NodeType* HierarchyTree::removeLeaf(NodeType* le else { root_node = sibling; - sibling->parent = NULL; + sibling->parent = nullptr; deleteNode(parent); return root_node; } @@ -1414,7 +1414,7 @@ void HierarchyTree::fetchLeaves(NodeType* root, std::vector& leav template size_t HierarchyTree::indexOf(NodeType* node) { - // node cannot be NULL + // node cannot be nullptr return (node->parent->children[1] == node); } @@ -1443,11 +1443,11 @@ typename HierarchyTree::NodeType* HierarchyTree::createNode(NodeType* pa template typename HierarchyTree::NodeType* HierarchyTree::createNode(NodeType* parent, void* data) { - NodeType* node = NULL; + NodeType* node = nullptr; if(free_node) { node = free_node; - free_node = NULL; + free_node = nullptr; } else node = new NodeType(); @@ -1476,7 +1476,7 @@ void HierarchyTree::recurseDeleteNode(NodeType* node) recurseDeleteNode(node->children[1]); } - if(node == root_node) root_node = NULL; + if(node == root_node) root_node = nullptr; deleteNode(node); } @@ -1999,7 +1999,7 @@ void HierarchyTree::bottomup(size_t* lbeg, size_t* lend) size_t* lcur_end = lend; while(lbeg < lcur_end - 1) { - size_t* min_it1 = NULL, *min_it2 = NULL; + size_t* min_it1 = nullptr, *min_it2 = nullptr; S min_size = std::numeric_limits::max(); for(size_t* it1 = lbeg; it1 < lcur_end; ++it1) { @@ -2015,7 +2015,7 @@ void HierarchyTree::bottomup(size_t* lbeg, size_t* lend) } } - size_t p = createNode(NULL_NODE, nodes[*min_it1].bv, nodes[*min_it2].bv, NULL); + size_t p = createNode(NULL_NODE, nodes[*min_it1].bv, nodes[*min_it2].bv, nullptr); nodes[p].children[0] = *min_it1; nodes[p].children[1] = *min_it2; nodes[*min_it1].parent = p; @@ -2065,7 +2065,7 @@ size_t HierarchyTree::topdown_0(size_t* lbeg, size_t* lend) size_t* lcenter = lbeg + num_leaves / 2; std::nth_element(lbeg, lcenter, lend, comp); - size_t node = createNode(NULL_NODE, vol, NULL); + size_t node = createNode(NULL_NODE, vol, nullptr); nodes[node].children[0] = topdown_0(lbeg, lcenter); nodes[node].children[1] = topdown_0(lcenter, lend); nodes[nodes[node].children[0]].parent = node; @@ -2135,7 +2135,7 @@ size_t HierarchyTree::topdown_1(size_t* lbeg, size_t* lend) } } - size_t node = createNode(NULL_NODE, vol, NULL); + size_t node = createNode(NULL_NODE, vol, nullptr); nodes[node].children[0] = topdown_1(lbeg, lcenter); nodes[node].children[1] = topdown_1(lcenter, lend); nodes[nodes[node].children[0]].parent = node; @@ -2181,7 +2181,7 @@ size_t HierarchyTree::mortonRecurse_0(size_t* lbeg, size_t* lend, const FCL_ size_t child1 = mortonRecurse_0(lbeg, lcenter, split1, bits - 1); size_t child2 = mortonRecurse_0(lcenter, lend, split2, bits - 1); - size_t node = createNode(NULL_NODE, NULL); + size_t node = createNode(NULL_NODE, nullptr); nodes[node].children[0] = child1; nodes[node].children[1] = child2; nodes[child1].parent = node; @@ -2229,7 +2229,7 @@ size_t HierarchyTree::mortonRecurse_1(size_t* lbeg, size_t* lend, const FCL_ size_t child1 = mortonRecurse_1(lbeg, lcenter, split1, bits - 1); size_t child2 = mortonRecurse_1(lcenter, lend, split2, bits - 1); - size_t node = createNode(NULL_NODE, NULL); + size_t node = createNode(NULL_NODE, nullptr); nodes[node].children[0] = child1; nodes[node].children[1] = child2; nodes[child1].parent = node; @@ -2241,7 +2241,7 @@ size_t HierarchyTree::mortonRecurse_1(size_t* lbeg, size_t* lend, const FCL_ { size_t child1 = mortonRecurse_1(lbeg, lbeg + num_leaves / 2, 0, bits - 1); size_t child2 = mortonRecurse_1(lbeg + num_leaves / 2, lend, 0, bits - 1); - size_t node = createNode(NULL_NODE, NULL); + size_t node = createNode(NULL_NODE, nullptr); nodes[node].children[0] = child1; nodes[node].children[1] = child2; nodes[child1].parent = node; @@ -2261,7 +2261,7 @@ size_t HierarchyTree::mortonRecurse_2(size_t* lbeg, size_t* lend) { size_t child1 = mortonRecurse_2(lbeg, lbeg + num_leaves / 2); size_t child2 = mortonRecurse_2(lbeg + num_leaves / 2, lend); - size_t node = createNode(NULL_NODE, NULL); + size_t node = createNode(NULL_NODE, nullptr); nodes[node].children[0] = child1; nodes[node].children[1] = child2; nodes[child1].parent = node; @@ -2292,7 +2292,7 @@ void HierarchyTree::insertLeaf(size_t root, size_t leaf) } size_t prev = nodes[root].parent; - size_t node = createNode(prev, nodes[leaf].bv, nodes[root].bv, NULL); + size_t node = createNode(prev, nodes[leaf].bv, nodes[root].bv, nullptr); if(prev != NULL_NODE) { nodes[prev].children[indexOf(root)] = node; diff --git a/include/fcl/broadphase/interval_tree.h b/include/fcl/broadphase/interval_tree.h index cd4e757a9..1cc49f6fd 100644 --- a/include/fcl/broadphase/interval_tree.h +++ b/include/fcl/broadphase/interval_tree.h @@ -199,19 +199,19 @@ IntervalTree::IntervalTree() nil->left = nil->right = nil->parent = nil; nil->red = false; nil->key = nil->high = nil->max_high = -std::numeric_limits::max(); - nil->stored_interval = NULL; + nil->stored_interval = nullptr; root = new IntervalTreeNode; root->parent = root->left = root->right = nil; root->key = root->high = root->max_high = std::numeric_limits::max(); root->red = false; - root->stored_interval = NULL; + root->stored_interval = nullptr; /// the following are used for the query function recursion_node_stack_size = 128; recursion_node_stack = (it_recursion_node*)malloc(recursion_node_stack_size*sizeof(it_recursion_node)); recursion_node_stack_top = 1; - recursion_node_stack[0].start_node = NULL; + recursion_node_stack[0].start_node = nullptr; } IntervalTree::~IntervalTree() @@ -449,11 +449,11 @@ void IntervalTreeNode::print(IntervalTreeNode* nil, IntervalTreeNode* root) cons stored_interval->print(); std::cout << ", k = " << key << ", h = " << high << ", mH = " << max_high; std::cout << " l->key = "; - if(left == nil) std::cout << "NULL"; else std::cout << left->key; + if(left == nil) std::cout << "nullptr"; else std::cout << left->key; std::cout << " r->key = "; - if(right == nil) std::cout << "NULL"; else std::cout << right->key; + if(right == nil) std::cout << "nullptr"; else std::cout << right->key; std::cout << " p->key = "; - if(parent == root) std::cout << "NULL"; else std::cout << parent->key; + if(parent == root) std::cout << "nullptr"; else std::cout << parent->key; std::cout << " red = " << (int)red << std::endl; } @@ -661,7 +661,7 @@ std::deque IntervalTree::query(double low, double high) { recursion_node_stack_size *= 2; recursion_node_stack = (it_recursion_node *)realloc(recursion_node_stack, recursion_node_stack_size * sizeof(it_recursion_node)); - if(recursion_node_stack == NULL) + if(recursion_node_stack == nullptr) exit(1); } recursion_node_stack[recursion_node_stack_top].start_node = x; diff --git a/include/fcl/ccd/conservative_advancement.h b/include/fcl/ccd/conservative_advancement.h index 3c8c3f988..b298fd9a5 100644 --- a/include/fcl/ccd/conservative_advancement.h +++ b/include/fcl/ccd/conservative_advancement.h @@ -117,7 +117,7 @@ bool conservativeAdvancement(const BVHModel& o1, node.delta_t = 1; node.min_distance = std::numeric_limits::max(); - distanceRecurse(&node, 0, 0, NULL); + distanceRecurse(&node, 0, 0, nullptr); if(node.delta_t <= node.t_err) { @@ -197,7 +197,7 @@ bool conservativeAdvancementMeshOriented(const BVHModel& o1, node.delta_t = 1; node.min_distance = std::numeric_limits::max(); - distanceRecurse(&node, 0, 0, NULL); + distanceRecurse(&node, 0, 0, nullptr); if(node.delta_t <= node.t_err) { @@ -268,7 +268,7 @@ bool conservativeAdvancement(const Shape1& o1, node.delta_t = 1; node.min_distance = std::numeric_limits::max(); - distanceRecurse(&node, 0, 0, NULL); + distanceRecurse(&node, 0, 0, nullptr); if(node.delta_t <= node.t_err) { @@ -333,7 +333,7 @@ bool conservativeAdvancement(const BVHModel& o1, node.delta_t = 1; node.min_distance = std::numeric_limits::max(); - distanceRecurse(&node, 0, 0, NULL); + distanceRecurse(&node, 0, 0, nullptr); if(node.delta_t <= node.t_err) { @@ -408,7 +408,7 @@ bool conservativeAdvancementMeshShapeOriented(const BVHModel& o1, node.delta_t = 1; node.min_distance = std::numeric_limits::max(); - distanceRecurse(&node, 0, 0, NULL); + distanceRecurse(&node, 0, 0, nullptr); if(node.delta_t <= node.t_err) { @@ -505,7 +505,7 @@ bool conservativeAdvancement(const Shape& o1, node.delta_t = 1; node.min_distance = std::numeric_limits::max(); - distanceRecurse(&node, 0, 0, NULL); + distanceRecurse(&node, 0, 0, nullptr); if(node.delta_t <= node.t_err) { @@ -579,7 +579,7 @@ bool conservativeAdvancementShapeMeshOriented(const Shape& o1, node.delta_t = 1; node.min_distance = std::numeric_limits::max(); - distanceRecurse(&node, 0, 0, NULL); + distanceRecurse(&node, 0, 0, nullptr); if(node.delta_t <= node.t_err) { @@ -791,7 +791,7 @@ ConservativeAdvancementFunctionMatrix::ConservativeAdvancemen for(int i = 0; i < NODE_COUNT; ++i) { for(int j = 0; j < NODE_COUNT; ++j) - conservative_advancement_matrix[i][j] = NULL; + conservative_advancement_matrix[i][j] = nullptr; } diff --git a/include/fcl/collision_data.h b/include/fcl/collision_data.h index ba4800b72..a638a81c5 100644 --- a/include/fcl/collision_data.h +++ b/include/fcl/collision_data.h @@ -454,8 +454,8 @@ bool comparePenDepth(const ContactPoint& _cp1, const ContactPoint& _cp2) //============================================================================== template Contact::Contact() - : o1(NULL), - o2(NULL), + : o1(nullptr), + o2(nullptr), b1(NONE), b2(NONE) { @@ -666,8 +666,8 @@ bool DistanceRequest::isSatisfied( template DistanceResult::DistanceResult(S min_distance_) : min_distance(min_distance_), - o1(NULL), - o2(NULL), + o1(nullptr), + o2(nullptr), b1(NONE), b2(NONE) { @@ -725,8 +725,8 @@ template void DistanceResult::clear() { min_distance = std::numeric_limits::max(); - o1 = NULL; - o2 = NULL; + o1 = nullptr; + o2 = nullptr; b1 = NONE; b2 = NONE; } diff --git a/include/fcl/collision_func_matrix.h b/include/fcl/collision_func_matrix.h index a92d463b7..cf6c1cbd9 100644 --- a/include/fcl/collision_func_matrix.h +++ b/include/fcl/collision_func_matrix.h @@ -683,7 +683,7 @@ CollisionFunctionMatrix::CollisionFunctionMatrix() for(int i = 0; i < NODE_COUNT; ++i) { for(int j = 0; j < NODE_COUNT; ++j) - collision_matrix[i][j] = NULL; + collision_matrix[i][j] = nullptr; } collision_matrix[GEOM_BOX][GEOM_BOX] = &ShapeShapeCollide, Box, NarrowPhaseSolver>; diff --git a/include/fcl/collision_node.h b/include/fcl/collision_node.h index d1eec1195..2e310bdf9 100644 --- a/include/fcl/collision_node.h +++ b/include/fcl/collision_node.h @@ -51,23 +51,23 @@ namespace fcl /// @brief collision on collision traversal node; can use front list to accelerate template -void collide(CollisionTraversalNodeBase* node, BVHFrontList* front_list = NULL); +void collide(CollisionTraversalNodeBase* node, BVHFrontList* front_list = nullptr); /// @brief self collision on collision traversal node; can use front list to accelerate template -void selfCollide(CollisionTraversalNodeBase* node, BVHFrontList* front_list = NULL); +void selfCollide(CollisionTraversalNodeBase* node, BVHFrontList* front_list = nullptr); /// @brief distance computation on distance traversal node; can use front list to accelerate template -void distance(DistanceTraversalNodeBase* node, BVHFrontList* front_list = NULL, int qsize = 2); +void distance(DistanceTraversalNodeBase* node, BVHFrontList* front_list = nullptr, int qsize = 2); /// @brief special collision on OBBd traversal node template -void collide2(MeshCollisionTraversalNodeOBB* node, BVHFrontList* front_list = NULL); +void collide2(MeshCollisionTraversalNodeOBB* node, BVHFrontList* front_list = nullptr); /// @brief special collision on RSSd traversal node template -void collide2(MeshCollisionTraversalNodeRSS* node, BVHFrontList* front_list = NULL); +void collide2(MeshCollisionTraversalNodeRSS* node, BVHFrontList* front_list = nullptr); //============================================================================// // // diff --git a/include/fcl/distance_func_matrix.h b/include/fcl/distance_func_matrix.h index f400eccc2..87addc0b3 100644 --- a/include/fcl/distance_func_matrix.h +++ b/include/fcl/distance_func_matrix.h @@ -486,7 +486,7 @@ DistanceFunctionMatrix::DistanceFunctionMatrix() for(int i = 0; i < NODE_COUNT; ++i) { for(int j = 0; j < NODE_COUNT; ++j) - distance_matrix[i][j] = NULL; + distance_matrix[i][j] = nullptr; } distance_matrix[GEOM_BOX][GEOM_BOX] = &ShapeShapeDistance, Box, NarrowPhaseSolver>; diff --git a/include/fcl/intersect.h b/include/fcl/intersect.h index 5f5860b5e..198efac05 100644 --- a/include/fcl/intersect.h +++ b/include/fcl/intersect.h @@ -115,10 +115,10 @@ class Intersect /// @brief CD intersect between two triangles [P1, P2, P3] and [Q1, Q2, Q3] static bool intersect_Triangle(const Vector3& P1, const Vector3& P2, const Vector3& P3, const Vector3& Q1, const Vector3& Q2, const Vector3& Q3, - Vector3* contact_points = NULL, - unsigned int* num_contact_points = NULL, - S* penetration_depth = NULL, - Vector3* normal = NULL); + Vector3* contact_points = nullptr, + unsigned int* num_contact_points = nullptr, + S* penetration_depth = nullptr, + Vector3* normal = nullptr); static bool intersect_Triangle( const Vector3& P1, @@ -129,10 +129,10 @@ class Intersect const Vector3& Q3, const Matrix3& R, const Vector3& T, - Vector3* contact_points = NULL, - unsigned int* num_contact_points = NULL, - S* penetration_depth = NULL, - Vector3* normal = NULL); + Vector3* contact_points = nullptr, + unsigned int* num_contact_points = nullptr, + S* penetration_depth = nullptr, + Vector3* normal = nullptr); static bool intersect_Triangle( const Vector3& P1, @@ -142,10 +142,10 @@ class Intersect const Vector3& Q2, const Vector3& Q3, const Transform3& tf, - Vector3* contact_points = NULL, - unsigned int* num_contact_points = NULL, - S* penetration_depth = NULL, - Vector3* normal = NULL); + Vector3* contact_points = nullptr, + unsigned int* num_contact_points = nullptr, + S* penetration_depth = nullptr, + Vector3* normal = nullptr); private: @@ -160,7 +160,7 @@ class Intersect /// @brief Solve the cubic function using Newton method, also satisfies the interval restriction static bool solveCubicWithIntervalNewton(const Vector3& a0, const Vector3& b0, const Vector3& c0, const Vector3& d0, const Vector3& va, const Vector3& vb, const Vector3& vc, const Vector3& vd, - S& l, S& r, bool bVF, S coeffs[], Vector3* data = NULL); + S& l, S& r, bool bVF, S coeffs[], Vector3* data = nullptr); /// @brief Check whether one point p is within triangle [a, b, c] static bool insideTriangle(const Vector3& a, const Vector3& b, const Vector3& c, const Vector3&p); @@ -184,7 +184,7 @@ class Intersect /// @brief Check whether a root for EE intersection is valid (i.e. within the two edges intersected at the given time static bool checkRootValidity_EE(const Vector3& a0, const Vector3& b0, const Vector3& c0, const Vector3& d0, const Vector3& va, const Vector3& vb, const Vector3& vc, const Vector3& vd, - S t, Vector3* q_i = NULL); + S t, Vector3* q_i = nullptr); /// @brief Check whether a root for VE intersection is valid static bool checkRootValidity_VE(const Vector3& a0, const Vector3& b0, const Vector3& p0, diff --git a/include/fcl/narrowphase/detail/gjk.h b/include/fcl/narrowphase/detail/gjk.h index 9473af23c..25b339156 100644 --- a/include/fcl/narrowphase/detail/gjk.h +++ b/include/fcl/narrowphase/detail/gjk.h @@ -236,10 +236,10 @@ struct EPA { SimplexF* root; size_t count; - SimplexList() : root(NULL), count(0) {} + SimplexList() : root(nullptr), count(0) {} void append(SimplexF* face) { - face->l[0] = NULL; + face->l[0] = nullptr; face->l[1] = root; if(root) root->l[0] = face; root = face; @@ -266,7 +266,7 @@ struct EPA SimplexF* cf; // current face in the horizon SimplexF* ff; // first face in the horizon size_t nf; // number of faces in the horizon - SimplexHorizon() : cf(NULL), ff(NULL), nf(0) {} + SimplexHorizon() : cf(nullptr), ff(nullptr), nf(0) {} }; private: @@ -484,7 +484,7 @@ void GJK::initialize() status = Failed; current = 0; distance = 0.0; - simplex = NULL; + simplex = nullptr; } //============================================================================== @@ -800,11 +800,11 @@ typename EPA::SimplexF* EPA::newFace( hull.remove(face); stock.append(face); - return NULL; + return nullptr; } status = stock.root ? OutOfVertices : OutOfFaces; - return NULL; + return nullptr; } //============================================================================== diff --git a/include/fcl/narrowphase/detail/gjk_libccd.h b/include/fcl/narrowphase/detail/gjk_libccd.h index 0ec313a8a..27ffc09d9 100644 --- a/include/fcl/narrowphase/detail/gjk_libccd.h +++ b/include/fcl/narrowphase/detail/gjk_libccd.h @@ -63,15 +63,15 @@ class GJKInitializer { public: /// @brief Get GJK support function - static GJKSupportFunction getSupportFunction() { return NULL; } + static GJKSupportFunction getSupportFunction() { return nullptr; } /// @brief Get GJK center function - static GJKCenterFunction getCenterFunction() { return NULL; } + static GJKCenterFunction getCenterFunction() { return nullptr; } /// @brief Get GJK object from a shape /// Notice that only local transformation is applied. /// Gloal transformation are considered later - static void* createGJKObject(const T& /* s */, const Transform3& /*tf*/) { return NULL; } + static void* createGJKObject(const T& /* s */, const Transform3& /*tf*/) { return nullptr; } /// @brief Delete GJK object static void deleteGJKObject(void* o) {} @@ -350,7 +350,7 @@ static int doSimplex3(ccd_simplex_t *simplex, ccd_vec3_t *dir) C = ccdSimplexPoint(simplex, 0); // check touching contact - dist = ccdVec3PointTriDist2(ccd_vec3_origin, &A->v, &B->v, &C->v, NULL); + dist = ccdVec3PointTriDist2(ccd_vec3_origin, &A->v, &B->v, &C->v, nullptr); if (ccdIsZero(dist)){ return 1; } @@ -435,23 +435,23 @@ static int doSimplex4(ccd_simplex_t *simplex, ccd_vec3_t *dir) // check if tetrahedron is really tetrahedron (has volume > 0) // if it is not simplex can't be expanded and thus no intersection is // found - dist = ccdVec3PointTriDist2(&A->v, &B->v, &C->v, &D->v, NULL); + dist = ccdVec3PointTriDist2(&A->v, &B->v, &C->v, &D->v, nullptr); if (ccdIsZero(dist)){ return -1; } // check if origin lies on some of tetrahedron's face - if so objects // intersect - dist = ccdVec3PointTriDist2(ccd_vec3_origin, &A->v, &B->v, &C->v, NULL); + dist = ccdVec3PointTriDist2(ccd_vec3_origin, &A->v, &B->v, &C->v, nullptr); if (ccdIsZero(dist)) return 1; - dist = ccdVec3PointTriDist2(ccd_vec3_origin, &A->v, &C->v, &D->v, NULL); + dist = ccdVec3PointTriDist2(ccd_vec3_origin, &A->v, &C->v, &D->v, nullptr); if (ccdIsZero(dist)) return 1; - dist = ccdVec3PointTriDist2(ccd_vec3_origin, &A->v, &B->v, &D->v, NULL); + dist = ccdVec3PointTriDist2(ccd_vec3_origin, &A->v, &B->v, &D->v, nullptr); if (ccdIsZero(dist)) return 1; - dist = ccdVec3PointTriDist2(ccd_vec3_origin, &B->v, &C->v, &D->v, NULL); + dist = ccdVec3PointTriDist2(ccd_vec3_origin, &B->v, &C->v, &D->v, nullptr); if (ccdIsZero(dist)) return 1; diff --git a/include/fcl/narrowphase/gjk_solver_indep.h b/include/fcl/narrowphase/gjk_solver_indep.h index 65c9003fd..f381f4ba8 100755 --- a/include/fcl/narrowphase/gjk_solver_indep.h +++ b/include/fcl/narrowphase/gjk_solver_indep.h @@ -73,7 +73,7 @@ struct GJKSolver_indep const Transform3& tf1, const Shape2& s2, const Transform3& tf2, - std::vector>* contacts = NULL) const; + std::vector>* contacts = nullptr) const; /// @brief intersection checking between one shape and a triangle template @@ -83,9 +83,9 @@ struct GJKSolver_indep const Vector3& P1, const Vector3& P2, const Vector3& P3, - Vector3* contact_points = NULL, - S* penetration_depth = NULL, - Vector3* normal = NULL) const; + Vector3* contact_points = nullptr, + S* penetration_depth = nullptr, + Vector3* normal = nullptr) const; //// @brief intersection checking between one shape and a triangle with transformation template @@ -96,9 +96,9 @@ struct GJKSolver_indep const Vector3& P2, const Vector3& P3, const Transform3& tf2, - Vector3* contact_points = NULL, - S* penetration_depth = NULL, - Vector3* normal = NULL) const; + Vector3* contact_points = nullptr, + S* penetration_depth = nullptr, + Vector3* normal = nullptr) const; /// @brief distance computation between two shapes template @@ -107,9 +107,9 @@ struct GJKSolver_indep const Transform3& tf1, const Shape2& s2, const Transform3& tf2, - S* distance = NULL, - Vector3* p1 = NULL, - Vector3* p2 = NULL) const; + S* distance = nullptr, + Vector3* p1 = nullptr, + Vector3* p2 = nullptr) const; /// @brief distance computation between one shape and a triangle template @@ -119,9 +119,9 @@ struct GJKSolver_indep const Vector3& P1, const Vector3& P2, const Vector3& P3, - S* distance = NULL, - Vector3* p1 = NULL, - Vector3* p2 = NULL) const; + S* distance = nullptr, + Vector3* p1 = nullptr, + Vector3* p2 = nullptr) const; /// @brief distance computation between one shape and a triangle with transformation template @@ -132,9 +132,9 @@ struct GJKSolver_indep const Vector3& P2, const Vector3& P3, const Transform3& tf2, - S* distance = NULL, - Vector3* p1 = NULL, - Vector3* p2 = NULL) const; + S* distance = nullptr, + Vector3* p1 = nullptr, + Vector3* p2 = nullptr) const; /// @brief default setting for GJK algorithm GJKSolver_indep(); @@ -211,7 +211,7 @@ bool GJKSolver_indep::shapeIntersect(const Shape1& s1, const Transform3& t } else { - res = shapeIntersect(s1, tf1, s2, tf2, NULL); + res = shapeIntersect(s1, tf1, s2, tf2, nullptr); } return res; diff --git a/include/fcl/narrowphase/gjk_solver_libccd.h b/include/fcl/narrowphase/gjk_solver_libccd.h index f2c3fb601..f3822a2fa 100755 --- a/include/fcl/narrowphase/gjk_solver_libccd.h +++ b/include/fcl/narrowphase/gjk_solver_libccd.h @@ -73,7 +73,7 @@ struct GJKSolver_libccd const Transform3& tf1, const Shape2& s2, const Transform3& tf2, - std::vector>* contacts = NULL) const; + std::vector>* contacts = nullptr) const; /// @brief intersection checking between one shape and a triangle template @@ -83,9 +83,9 @@ struct GJKSolver_libccd const Vector3& P1, const Vector3& P2, const Vector3& P3, - Vector3* contact_points = NULL, - S* penetration_depth = NULL, - Vector3* normal = NULL) const; + Vector3* contact_points = nullptr, + S* penetration_depth = nullptr, + Vector3* normal = nullptr) const; //// @brief intersection checking between one shape and a triangle with transformation template @@ -96,9 +96,9 @@ struct GJKSolver_libccd const Vector3& P2, const Vector3& P3, const Transform3& tf2, - Vector3* contact_points = NULL, - S* penetration_depth = NULL, - Vector3* normal = NULL) const; + Vector3* contact_points = nullptr, + S* penetration_depth = nullptr, + Vector3* normal = nullptr) const; /// @brief distance computation between two shapes template @@ -107,9 +107,9 @@ struct GJKSolver_libccd const Transform3& tf1, const Shape2& s2, const Transform3& tf2, - S* dist = NULL, - Vector3* p1 = NULL, - Vector3* p2 = NULL) const; + S* dist = nullptr, + Vector3* p1 = nullptr, + Vector3* p2 = nullptr) const; /// @brief distance computation between one shape and a triangle template @@ -119,9 +119,9 @@ struct GJKSolver_libccd const Vector3& P1, const Vector3& P2, const Vector3& P3, - S* dist = NULL, - Vector3* p1 = NULL, - Vector3* p2 = NULL) const; + S* dist = nullptr, + Vector3* p1 = nullptr, + Vector3* p2 = nullptr) const; /// @brief distance computation between one shape and a triangle with transformation template @@ -132,9 +132,9 @@ struct GJKSolver_libccd const Vector3& P2, const Vector3& P3, const Transform3& tf2, - S* dist = NULL, - Vector3* p1 = NULL, - Vector3* p2 = NULL) const; + S* dist = nullptr, + Vector3* p1 = nullptr, + Vector3* p2 = nullptr) const; /// @brief default setting for GJK algorithm GJKSolver_libccd(); @@ -203,7 +203,7 @@ bool GJKSolver_libccd::shapeIntersect( } else { - res = shapeIntersect(s1, tf1, s2, tf2, NULL); + res = shapeIntersect(s1, tf1, s2, tf2, nullptr); } return res; @@ -253,9 +253,9 @@ struct ShapeIntersectLibccdImpl details::GJKInitializer::getCenterFunction(), gjkSolver.max_collision_iterations, gjkSolver.collision_tolerance, - NULL, - NULL, - NULL); + nullptr, + nullptr, + nullptr); } details::GJKInitializer::deleteGJKObject(o1); diff --git a/include/fcl/shape/convex.h b/include/fcl/shape/convex.h index cb1950862..8ee322eae 100644 --- a/include/fcl/shape/convex.h +++ b/include/fcl/shape/convex.h @@ -138,7 +138,7 @@ Convex::Convex( points = points; num_points = num_points_; polygons = polygons_; - edges = NULL; + edges = nullptr; Vector3 sum = Vector3::Zero(); for(int i = 0; i < num_points; ++i) diff --git a/include/fcl/traversal/collision/bvh_collision_traversal_node.h b/include/fcl/traversal/collision/bvh_collision_traversal_node.h index a98b1abfd..62862718f 100644 --- a/include/fcl/traversal/collision/bvh_collision_traversal_node.h +++ b/include/fcl/traversal/collision/bvh_collision_traversal_node.h @@ -102,8 +102,8 @@ template BVHCollisionTraversalNode::BVHCollisionTraversalNode() : CollisionTraversalNodeBase() { - model1 = NULL; - model2 = NULL; + model1 = nullptr; + model2 = nullptr; num_bv_tests = 0; num_leaf_tests = 0; diff --git a/include/fcl/traversal/collision/bvh_shape_collision_traversal_node.h b/include/fcl/traversal/collision/bvh_shape_collision_traversal_node.h index 86baca1d2..2455524e8 100644 --- a/include/fcl/traversal/collision/bvh_shape_collision_traversal_node.h +++ b/include/fcl/traversal/collision/bvh_shape_collision_traversal_node.h @@ -88,8 +88,8 @@ template BVHShapeCollisionTraversalNode::BVHShapeCollisionTraversalNode() : CollisionTraversalNodeBase() { - model1 = NULL; - model2 = NULL; + model1 = nullptr; + model2 = nullptr; num_bv_tests = 0; num_leaf_tests = 0; diff --git a/include/fcl/traversal/collision/collision_traversal_node_base.h b/include/fcl/traversal/collision/collision_traversal_node_base.h index 5e95ebdd5..6f6c27497 100644 --- a/include/fcl/traversal/collision/collision_traversal_node_base.h +++ b/include/fcl/traversal/collision/collision_traversal_node_base.h @@ -87,7 +87,7 @@ using CollisionTraversalNodeBased = CollisionTraversalNodeBase; //============================================================================== template CollisionTraversalNodeBase::CollisionTraversalNodeBase() - : result(NULL), enable_statistics(false) + : result(nullptr), enable_statistics(false) { // Do nothing } diff --git a/include/fcl/traversal/collision/mesh_collision_traversal_node.h b/include/fcl/traversal/collision/mesh_collision_traversal_node.h index ea18c3e47..0d5498b25 100644 --- a/include/fcl/traversal/collision/mesh_collision_traversal_node.h +++ b/include/fcl/traversal/collision/mesh_collision_traversal_node.h @@ -287,10 +287,10 @@ template MeshCollisionTraversalNode::MeshCollisionTraversalNode() : BVHCollisionTraversalNode() { - vertices1 = NULL; - vertices2 = NULL; - tri_indices1 = NULL; - tri_indices2 = NULL; + vertices1 = nullptr; + vertices2 = nullptr; + tri_indices1 = nullptr; + tri_indices2 = nullptr; } //============================================================================== diff --git a/include/fcl/traversal/collision/mesh_continuous_collision_traversal_node.h b/include/fcl/traversal/collision/mesh_continuous_collision_traversal_node.h index b676782fd..2dd7c9f3c 100644 --- a/include/fcl/traversal/collision/mesh_continuous_collision_traversal_node.h +++ b/include/fcl/traversal/collision/mesh_continuous_collision_traversal_node.h @@ -134,12 +134,12 @@ template MeshContinuousCollisionTraversalNode::MeshContinuousCollisionTraversalNode() : BVHCollisionTraversalNode() { - vertices1 = NULL; - vertices2 = NULL; - tri_indices1 = NULL; - tri_indices2 = NULL; - prev_vertices1 = NULL; - prev_vertices2 = NULL; + vertices1 = nullptr; + vertices2 = nullptr; + tri_indices1 = nullptr; + tri_indices2 = nullptr; + prev_vertices1 = nullptr; + prev_vertices2 = nullptr; num_vf_tests = 0; num_ee_tests = 0; diff --git a/include/fcl/traversal/collision/mesh_shape_collision_traversal_node.h b/include/fcl/traversal/collision/mesh_shape_collision_traversal_node.h index 479f411e5..d703a944b 100644 --- a/include/fcl/traversal/collision/mesh_shape_collision_traversal_node.h +++ b/include/fcl/traversal/collision/mesh_shape_collision_traversal_node.h @@ -228,10 +228,10 @@ template MeshShapeCollisionTraversalNode::MeshShapeCollisionTraversalNode() : BVHShapeCollisionTraversalNode() { - vertices = NULL; - tri_indices = NULL; + vertices = nullptr; + tri_indices = nullptr; - nsolver = NULL; + nsolver = nullptr; } //============================================================================== @@ -255,7 +255,7 @@ void MeshShapeCollisionTraversalNode::leafTesting( if(!this->request.enable_contact) { - if(nsolver->shapeTriangleIntersect(*(this->model2), this->tf2, p1, p2, p3, NULL, NULL, NULL)) + if(nsolver->shapeTriangleIntersect(*(this->model2), this->tf2, p1, p2, p3, nullptr, nullptr, nullptr)) { is_intersect = true; if(this->request.num_max_contacts > this->result->numContacts()) @@ -287,7 +287,7 @@ void MeshShapeCollisionTraversalNode::leafTesting( } if((!this->model1->isFree() && !this->model2->isFree()) && this->request.enable_cost) { - if(nsolver->shapeTriangleIntersect(*(this->model2), this->tf2, p1, p2, p3, NULL, NULL, NULL)) + if(nsolver->shapeTriangleIntersect(*(this->model2), this->tf2, p1, p2, p3, nullptr, nullptr, nullptr)) { AABB overlap_part; AABB shape_aabb; @@ -398,7 +398,7 @@ void meshShapeCollisionOrientedNodeLeafTesting( if(!request.enable_contact) // only interested in collision or not { - if(nsolver->shapeTriangleIntersect(model2, tf2, p1, p2, p3, tf1, NULL, NULL, NULL)) + if(nsolver->shapeTriangleIntersect(model2, tf2, p1, p2, p3, tf1, nullptr, nullptr, nullptr)) { is_intersect = true; if(request.num_max_contacts > result.numContacts()) @@ -430,7 +430,7 @@ void meshShapeCollisionOrientedNodeLeafTesting( } else if((!model1->isFree() || model2.isFree()) && request.enable_cost) { - if(nsolver->shapeTriangleIntersect(model2, tf2, p1, p2, p3, tf1, NULL, NULL, NULL)) + if(nsolver->shapeTriangleIntersect(model2, tf2, p1, p2, p3, tf1, nullptr, nullptr, nullptr)) { AABB overlap_part; AABB shape_aabb; diff --git a/include/fcl/traversal/collision/shape_bvh_collision_traversal_node.h b/include/fcl/traversal/collision/shape_bvh_collision_traversal_node.h index 4f06a78cc..572d6ffad 100644 --- a/include/fcl/traversal/collision/shape_bvh_collision_traversal_node.h +++ b/include/fcl/traversal/collision/shape_bvh_collision_traversal_node.h @@ -91,8 +91,8 @@ template ShapeBVHCollisionTraversalNode::ShapeBVHCollisionTraversalNode() : CollisionTraversalNodeBase() { - model1 = NULL; - model2 = NULL; + model1 = nullptr; + model2 = nullptr; num_bv_tests = 0; num_leaf_tests = 0; diff --git a/include/fcl/traversal/collision/shape_collision_traversal_node.h b/include/fcl/traversal/collision/shape_collision_traversal_node.h index 039a66d63..1db6bf49f 100644 --- a/include/fcl/traversal/collision/shape_collision_traversal_node.h +++ b/include/fcl/traversal/collision/shape_collision_traversal_node.h @@ -94,10 +94,10 @@ ShapeCollisionTraversalNode:: ShapeCollisionTraversalNode() : CollisionTraversalNodeBase() { - model1 = NULL; - model2 = NULL; + model1 = nullptr; + model2 = nullptr; - nsolver = NULL; + nsolver = nullptr; } //============================================================================== @@ -145,7 +145,7 @@ leafTesting(int, int) const } else { - if(nsolver->shapeIntersect(*model1, this->tf1, *model2, this->tf2, NULL)) + if(nsolver->shapeIntersect(*model1, this->tf1, *model2, this->tf2, nullptr)) { is_collision = true; if(this->request.num_max_contacts > this->result->numContacts()) @@ -165,7 +165,7 @@ leafTesting(int, int) const } else if((!model1->isFree() && !model2->isFree()) && this->request.enable_cost) { - if(nsolver->shapeIntersect(*model1, this->tf1, *model2, this->tf2, NULL)) + if(nsolver->shapeIntersect(*model1, this->tf1, *model2, this->tf2, nullptr)) { AABB aabb1, aabb2; computeBV(*model1, this->tf1, aabb1); diff --git a/include/fcl/traversal/collision/shape_mesh_collision_traversal_node.h b/include/fcl/traversal/collision/shape_mesh_collision_traversal_node.h index d033d906a..d636246e2 100644 --- a/include/fcl/traversal/collision/shape_mesh_collision_traversal_node.h +++ b/include/fcl/traversal/collision/shape_mesh_collision_traversal_node.h @@ -198,10 +198,10 @@ template ShapeMeshCollisionTraversalNode::ShapeMeshCollisionTraversalNode() : ShapeBVHCollisionTraversalNode() { - vertices = NULL; - tri_indices = NULL; + vertices = nullptr; + tri_indices = nullptr; - nsolver = NULL; + nsolver = nullptr; } //============================================================================== @@ -227,7 +227,7 @@ void ShapeMeshCollisionTraversalNode::leafTesting( if(!this->request.enable_contact) { - if(nsolver->shapeTriangleIntersect(*(this->model1), this->tf1, p1, p2, p3, NULL, NULL, NULL)) + if(nsolver->shapeTriangleIntersect(*(this->model1), this->tf1, p1, p2, p3, nullptr, nullptr, nullptr)) { is_intersect = true; if(this->request.num_max_contacts > this->result->numContacts()) @@ -259,7 +259,7 @@ void ShapeMeshCollisionTraversalNode::leafTesting( } else if((!this->model1->isFree() && !this->model2->isFree()) && this->request.enable_cost) { - if(nsolver->shapeTriangleIntersect(*(this->model1), this->tf1, p1, p2, p3, NULL, NULL, NULL)) + if(nsolver->shapeTriangleIntersect(*(this->model1), this->tf1, p1, p2, p3, nullptr, nullptr, nullptr)) { AABB overlap_part; AABB shape_aabb; diff --git a/include/fcl/traversal/distance/bvh_distance_traversal_node.h b/include/fcl/traversal/distance/bvh_distance_traversal_node.h index c5995fe80..154876a01 100644 --- a/include/fcl/traversal/distance/bvh_distance_traversal_node.h +++ b/include/fcl/traversal/distance/bvh_distance_traversal_node.h @@ -103,8 +103,8 @@ template BVHDistanceTraversalNode::BVHDistanceTraversalNode() : DistanceTraversalNodeBase() { - model1 = NULL; - model2 = NULL; + model1 = nullptr; + model2 = nullptr; num_bv_tests = 0; num_leaf_tests = 0; diff --git a/include/fcl/traversal/distance/bvh_shape_distance_traversal_node.h b/include/fcl/traversal/distance/bvh_shape_distance_traversal_node.h index b4da0011c..5c82439c5 100644 --- a/include/fcl/traversal/distance/bvh_shape_distance_traversal_node.h +++ b/include/fcl/traversal/distance/bvh_shape_distance_traversal_node.h @@ -87,8 +87,8 @@ template BVHShapeDistanceTraversalNode::BVHShapeDistanceTraversalNode() : DistanceTraversalNodeBase() { - model1 = NULL; - model2 = NULL; + model1 = nullptr; + model2 = nullptr; num_bv_tests = 0; num_leaf_tests = 0; diff --git a/include/fcl/traversal/distance/distance_traversal_node_base.h b/include/fcl/traversal/distance/distance_traversal_node_base.h index 6c5f1627b..44fbec693 100644 --- a/include/fcl/traversal/distance/distance_traversal_node_base.h +++ b/include/fcl/traversal/distance/distance_traversal_node_base.h @@ -84,7 +84,7 @@ class DistanceTraversalNodeBase : public TraversalNodeBase //============================================================================== template DistanceTraversalNodeBase::DistanceTraversalNodeBase() - : result(NULL), enable_statistics(false) + : result(nullptr), enable_statistics(false) { // Do nothing } diff --git a/include/fcl/traversal/distance/mesh_conservative_advancement_traversal_node.h b/include/fcl/traversal/distance/mesh_conservative_advancement_traversal_node.h index 5469e1d48..81f7921e3 100644 --- a/include/fcl/traversal/distance/mesh_conservative_advancement_traversal_node.h +++ b/include/fcl/traversal/distance/mesh_conservative_advancement_traversal_node.h @@ -271,8 +271,8 @@ MeshConservativeAdvancementTraversalNode(typename BV::S w_) w = w_; - motion1 = NULL; - motion2 = NULL; + motion1 = nullptr; + motion2 = nullptr; } //============================================================================== diff --git a/include/fcl/traversal/distance/mesh_distance_traversal_node.h b/include/fcl/traversal/distance/mesh_distance_traversal_node.h index f3532b738..f587fa951 100644 --- a/include/fcl/traversal/distance/mesh_distance_traversal_node.h +++ b/include/fcl/traversal/distance/mesh_distance_traversal_node.h @@ -295,10 +295,10 @@ void distancePostprocessOrientedNode( template MeshDistanceTraversalNode::MeshDistanceTraversalNode() : BVHDistanceTraversalNode() { - vertices1 = NULL; - vertices2 = NULL; - tri_indices1 = NULL; - tri_indices2 = NULL; + vertices1 = nullptr; + vertices2 = nullptr; + tri_indices1 = nullptr; + tri_indices2 = nullptr; rel_err = this->request.rel_err; abs_err = this->request.abs_err; diff --git a/include/fcl/traversal/distance/mesh_shape_conservative_advancement_traversal_node.h b/include/fcl/traversal/distance/mesh_shape_conservative_advancement_traversal_node.h index 5b2fc84cf..4b435c19e 100644 --- a/include/fcl/traversal/distance/mesh_shape_conservative_advancement_traversal_node.h +++ b/include/fcl/traversal/distance/mesh_shape_conservative_advancement_traversal_node.h @@ -386,8 +386,8 @@ MeshShapeConservativeAdvancementTraversalNode(S w_) : w = w_; - motion1 = NULL; - motion2 = NULL; + motion1 = nullptr; + motion2 = nullptr; } //============================================================================== diff --git a/include/fcl/traversal/distance/mesh_shape_distance_traversal_node.h b/include/fcl/traversal/distance/mesh_shape_distance_traversal_node.h index 7e8d9c06c..23bfb1a99 100644 --- a/include/fcl/traversal/distance/mesh_shape_distance_traversal_node.h +++ b/include/fcl/traversal/distance/mesh_shape_distance_traversal_node.h @@ -224,13 +224,13 @@ MeshShapeDistanceTraversalNode:: MeshShapeDistanceTraversalNode() : BVHShapeDistanceTraversalNode() { - vertices = NULL; - tri_indices = NULL; + vertices = nullptr; + tri_indices = nullptr; rel_err = 0; abs_err = 0; - nsolver = NULL; + nsolver = nullptr; } //============================================================================== diff --git a/include/fcl/traversal/distance/shape_bvh_distance_traversal_node.h b/include/fcl/traversal/distance/shape_bvh_distance_traversal_node.h index ecaf967a3..1997e0e27 100644 --- a/include/fcl/traversal/distance/shape_bvh_distance_traversal_node.h +++ b/include/fcl/traversal/distance/shape_bvh_distance_traversal_node.h @@ -88,8 +88,8 @@ template ShapeBVHDistanceTraversalNode::ShapeBVHDistanceTraversalNode() : DistanceTraversalNodeBase() { - model1 = NULL; - model2 = NULL; + model1 = nullptr; + model2 = nullptr; num_bv_tests = 0; num_leaf_tests = 0; diff --git a/include/fcl/traversal/distance/shape_conservative_advancement_traversal_node.h b/include/fcl/traversal/distance/shape_conservative_advancement_traversal_node.h index f05a92729..071ed771c 100644 --- a/include/fcl/traversal/distance/shape_conservative_advancement_traversal_node.h +++ b/include/fcl/traversal/distance/shape_conservative_advancement_traversal_node.h @@ -95,8 +95,8 @@ ShapeConservativeAdvancementTraversalNode() toc = 0; t_err = (S)0.0001; - motion1 = NULL; - motion2 = NULL; + motion1 = nullptr; + motion2 = nullptr; } //============================================================================== diff --git a/include/fcl/traversal/distance/shape_distance_traversal_node.h b/include/fcl/traversal/distance/shape_distance_traversal_node.h index f55fcc58f..2607c2b33 100644 --- a/include/fcl/traversal/distance/shape_distance_traversal_node.h +++ b/include/fcl/traversal/distance/shape_distance_traversal_node.h @@ -89,10 +89,10 @@ template ShapeDistanceTraversalNode:: ShapeDistanceTraversalNode() : DistanceTraversalNodeBase() { - model1 = NULL; - model2 = NULL; + model1 = nullptr; + model2 = nullptr; - nsolver = NULL; + nsolver = nullptr; } //============================================================================== diff --git a/include/fcl/traversal/distance/shape_mesh_conservative_advancement_traversal_node.h b/include/fcl/traversal/distance/shape_mesh_conservative_advancement_traversal_node.h index 95010a039..b52351fd9 100644 --- a/include/fcl/traversal/distance/shape_mesh_conservative_advancement_traversal_node.h +++ b/include/fcl/traversal/distance/shape_mesh_conservative_advancement_traversal_node.h @@ -171,8 +171,8 @@ ShapeMeshConservativeAdvancementTraversalNode(S w_) w = w_; - motion1 = NULL; - motion2 = NULL; + motion1 = nullptr; + motion2 = nullptr; } //============================================================================== diff --git a/include/fcl/traversal/distance/shape_mesh_distance_traversal_node.h b/include/fcl/traversal/distance/shape_mesh_distance_traversal_node.h index ae6a6f87f..413b84833 100644 --- a/include/fcl/traversal/distance/shape_mesh_distance_traversal_node.h +++ b/include/fcl/traversal/distance/shape_mesh_distance_traversal_node.h @@ -199,13 +199,13 @@ ShapeMeshDistanceTraversalNode:: ShapeMeshDistanceTraversalNode() : ShapeBVHDistanceTraversalNode() { - vertices = NULL; - tri_indices = NULL; + vertices = nullptr; + tri_indices = nullptr; rel_err = 0; abs_err = 0; - nsolver = NULL; + nsolver = nullptr; } //============================================================================== diff --git a/include/fcl/traversal/octree/collision/mesh_octree_collision_traversal_node.h b/include/fcl/traversal/octree/collision/mesh_octree_collision_traversal_node.h index cbde4cb0f..82874ea6c 100644 --- a/include/fcl/traversal/octree/collision/mesh_octree_collision_traversal_node.h +++ b/include/fcl/traversal/octree/collision/mesh_octree_collision_traversal_node.h @@ -100,10 +100,10 @@ template MeshOcTreeCollisionTraversalNode:: MeshOcTreeCollisionTraversalNode() { - model1 = NULL; - model2 = NULL; + model1 = nullptr; + model2 = nullptr; - otsolver = NULL; + otsolver = nullptr; } //============================================================================== diff --git a/include/fcl/traversal/octree/collision/octree_collision_traversal_node.h b/include/fcl/traversal/octree/collision/octree_collision_traversal_node.h index 111fec026..f3c5eeb6a 100644 --- a/include/fcl/traversal/octree/collision/octree_collision_traversal_node.h +++ b/include/fcl/traversal/octree/collision/octree_collision_traversal_node.h @@ -98,10 +98,10 @@ bool initialize( template OcTreeCollisionTraversalNode::OcTreeCollisionTraversalNode() { - model1 = NULL; - model2 = NULL; + model1 = nullptr; + model2 = nullptr; - otsolver = NULL; + otsolver = nullptr; } //============================================================================== diff --git a/include/fcl/traversal/octree/collision/octree_mesh_collision_traversal_node.h b/include/fcl/traversal/octree/collision/octree_mesh_collision_traversal_node.h index 98b622150..96052b2d2 100644 --- a/include/fcl/traversal/octree/collision/octree_mesh_collision_traversal_node.h +++ b/include/fcl/traversal/octree/collision/octree_mesh_collision_traversal_node.h @@ -100,10 +100,10 @@ template OcTreeMeshCollisionTraversalNode:: OcTreeMeshCollisionTraversalNode() { - model1 = NULL; - model2 = NULL; + model1 = nullptr; + model2 = nullptr; - otsolver = NULL; + otsolver = nullptr; } //============================================================================== diff --git a/include/fcl/traversal/octree/collision/octree_shape_collision_traversal_node.h b/include/fcl/traversal/octree/collision/octree_shape_collision_traversal_node.h index 902fc5581..9b9008a39 100644 --- a/include/fcl/traversal/octree/collision/octree_shape_collision_traversal_node.h +++ b/include/fcl/traversal/octree/collision/octree_shape_collision_traversal_node.h @@ -100,10 +100,10 @@ template OcTreeShapeCollisionTraversalNode:: OcTreeShapeCollisionTraversalNode() { - model1 = NULL; - model2 = NULL; + model1 = nullptr; + model2 = nullptr; - otsolver = NULL; + otsolver = nullptr; } //============================================================================== diff --git a/include/fcl/traversal/octree/collision/shape_octree_collision_traversal_node.h b/include/fcl/traversal/octree/collision/shape_octree_collision_traversal_node.h index cc46b34d2..0a4902e77 100644 --- a/include/fcl/traversal/octree/collision/shape_octree_collision_traversal_node.h +++ b/include/fcl/traversal/octree/collision/shape_octree_collision_traversal_node.h @@ -100,10 +100,10 @@ template ShapeOcTreeCollisionTraversalNode:: ShapeOcTreeCollisionTraversalNode() { - model1 = NULL; - model2 = NULL; + model1 = nullptr; + model2 = nullptr; - otsolver = NULL; + otsolver = nullptr; } //============================================================================== diff --git a/include/fcl/traversal/octree/distance/mesh_octree_distance_traversal_node.h b/include/fcl/traversal/octree/distance/mesh_octree_distance_traversal_node.h index 6ba791d3a..3e5b53433 100644 --- a/include/fcl/traversal/octree/distance/mesh_octree_distance_traversal_node.h +++ b/include/fcl/traversal/octree/distance/mesh_octree_distance_traversal_node.h @@ -97,10 +97,10 @@ template MeshOcTreeDistanceTraversalNode:: MeshOcTreeDistanceTraversalNode() { - model1 = NULL; - model2 = NULL; + model1 = nullptr; + model2 = nullptr; - otsolver = NULL; + otsolver = nullptr; } //============================================================================== diff --git a/include/fcl/traversal/octree/distance/octree_distance_traversal_node.h b/include/fcl/traversal/octree/distance/octree_distance_traversal_node.h index 53a6fa7de..e78b4fc1c 100644 --- a/include/fcl/traversal/octree/distance/octree_distance_traversal_node.h +++ b/include/fcl/traversal/octree/distance/octree_distance_traversal_node.h @@ -95,10 +95,10 @@ template OcTreeDistanceTraversalNode:: OcTreeDistanceTraversalNode() { - model1 = NULL; - model2 = NULL; + model1 = nullptr; + model2 = nullptr; - otsolver = NULL; + otsolver = nullptr; } //============================================================================== diff --git a/include/fcl/traversal/octree/distance/octree_mesh_distance_traversal_node.h b/include/fcl/traversal/octree/distance/octree_mesh_distance_traversal_node.h index 3b33efd31..7f5ab768a 100644 --- a/include/fcl/traversal/octree/distance/octree_mesh_distance_traversal_node.h +++ b/include/fcl/traversal/octree/distance/octree_mesh_distance_traversal_node.h @@ -97,10 +97,10 @@ template OcTreeMeshDistanceTraversalNode:: OcTreeMeshDistanceTraversalNode() { - model1 = NULL; - model2 = NULL; + model1 = nullptr; + model2 = nullptr; - otsolver = NULL; + otsolver = nullptr; } //============================================================================== diff --git a/include/fcl/traversal/octree/distance/octree_shape_distance_traversal_node.h b/include/fcl/traversal/octree/distance/octree_shape_distance_traversal_node.h index 8d2a8ff90..17231ee70 100644 --- a/include/fcl/traversal/octree/distance/octree_shape_distance_traversal_node.h +++ b/include/fcl/traversal/octree/distance/octree_shape_distance_traversal_node.h @@ -96,10 +96,10 @@ template OcTreeShapeDistanceTraversalNode:: OcTreeShapeDistanceTraversalNode() { - model1 = NULL; - model2 = NULL; + model1 = nullptr; + model2 = nullptr; - otsolver = NULL; + otsolver = nullptr; } //============================================================================== diff --git a/include/fcl/traversal/octree/distance/shape_octree_distance_traversal_node.h b/include/fcl/traversal/octree/distance/shape_octree_distance_traversal_node.h index 42abf8251..6a9713090 100644 --- a/include/fcl/traversal/octree/distance/shape_octree_distance_traversal_node.h +++ b/include/fcl/traversal/octree/distance/shape_octree_distance_traversal_node.h @@ -96,10 +96,10 @@ template ShapeOcTreeDistanceTraversalNode:: ShapeOcTreeDistanceTraversalNode() { - model1 = NULL; - model2 = NULL; + model1 = nullptr; + model2 = nullptr; - otsolver = NULL; + otsolver = nullptr; } //============================================================================== diff --git a/include/fcl/traversal/octree/octree_solver.h b/include/fcl/traversal/octree/octree_solver.h index 3ee1df113..934001c0b 100644 --- a/include/fcl/traversal/octree/octree_solver.h +++ b/include/fcl/traversal/octree/octree_solver.h @@ -182,10 +182,10 @@ template OcTreeSolver::OcTreeSolver( const NarrowPhaseSolver* solver_) : solver(solver_), - crequest(NULL), - drequest(NULL), - cresult(NULL), - dresult(NULL) + crequest(nullptr), + drequest(nullptr), + cresult(nullptr), + dresult(nullptr) { } @@ -471,7 +471,7 @@ bool OcTreeSolver::OcTreeShapeIntersectRecurse(const OcTree box_tf; constructBox(bv1, tf1, box, box_tf); - if(solver->shapeIntersect(box, box_tf, s, tf2, NULL)) + if(solver->shapeIntersect(box, box_tf, s, tf2, nullptr)) { AABB overlap_part; AABB aabb1, aabb2; @@ -499,7 +499,7 @@ bool OcTreeSolver::OcTreeShapeIntersectRecurse(const OcTreeenable_contact) { - if(solver->shapeIntersect(box, box_tf, s, tf2, NULL)) + if(solver->shapeIntersect(box, box_tf, s, tf2, nullptr)) { is_intersect = true; if(cresult->numContacts() < crequest->num_max_contacts) @@ -557,7 +557,7 @@ bool OcTreeSolver::OcTreeShapeIntersectRecurse(const OcTree box_tf; constructBox(bv1, tf1, box, box_tf); - if(solver->shapeIntersect(box, box_tf, s, tf2, NULL)) + if(solver->shapeIntersect(box, box_tf, s, tf2, nullptr)) { AABB overlap_part; AABB aabb1, aabb2; @@ -601,7 +601,7 @@ bool OcTreeSolver::OcTreeShapeIntersectRecurse(const OcTree child_bv; computeChildBV(bv1, i, child_bv); - if(OcTreeShapeIntersectRecurse(tree1, NULL, child_bv, s, obb2, tf1, tf2)) + if(OcTreeShapeIntersectRecurse(tree1, nullptr, child_bv, s, obb2, tf1, tf2)) return true; } } @@ -723,7 +723,7 @@ bool OcTreeSolver::OcTreeMeshIntersectRecurse(const OcTree const Vector3& p2 = tree2->vertices[tri_id[1]]; const Vector3& p3 = tree2->vertices[tri_id[2]]; - if(solver->shapeTriangleIntersect(box, box_tf, p1, p2, p3, tf2, NULL, NULL, NULL)) + if(solver->shapeTriangleIntersect(box, box_tf, p1, p2, p3, tf2, nullptr, nullptr, nullptr)) { AABB overlap_part; AABB aabb1; @@ -769,7 +769,7 @@ bool OcTreeSolver::OcTreeMeshIntersectRecurse(const OcTree bool is_intersect = false; if(!crequest->enable_contact) { - if(solver->shapeTriangleIntersect(box, box_tf, p1, p2, p3, tf2, NULL, NULL, NULL)) + if(solver->shapeTriangleIntersect(box, box_tf, p1, p2, p3, tf2, nullptr, nullptr, nullptr)) { is_intersect = true; if(cresult->numContacts() < crequest->num_max_contacts) @@ -822,7 +822,7 @@ bool OcTreeSolver::OcTreeMeshIntersectRecurse(const OcTree const Vector3& p2 = tree2->vertices[tri_id[1]]; const Vector3& p3 = tree2->vertices[tri_id[2]]; - if(solver->shapeTriangleIntersect(box, box_tf, p1, p2, p3, tf2, NULL, NULL, NULL)) + if(solver->shapeTriangleIntersect(box, box_tf, p1, p2, p3, tf2, nullptr, nullptr, nullptr)) { AABB overlap_part; AABB aabb1; @@ -870,7 +870,7 @@ else if(!tree2->isFree() && crequest->enable_cost) AABB child_bv; computeChildBV(bv1, i, child_bv); - if(OcTreeMeshIntersectRecurse(tree1, NULL, child_bv, tree2, root2, tf1, tf2)) + if(OcTreeMeshIntersectRecurse(tree1, nullptr, child_bv, tree2, root2, tf1, tf2)) return true; } } @@ -1013,21 +1013,21 @@ bool OcTreeSolver::OcTreeIntersectRecurse(const OcTree* tr const typename OcTree::OcTreeNode* child = tree2->getNodeChild(root2, i); AABB child_bv; computeChildBV(bv2, i, child_bv); - if(OcTreeIntersectRecurse(tree1, NULL, bv1, tree2, child, child_bv, tf1, tf2)) + if(OcTreeIntersectRecurse(tree1, nullptr, bv1, tree2, child, child_bv, tf1, tf2)) return true; } else { AABB child_bv; computeChildBV(bv2, i, child_bv); - if(OcTreeIntersectRecurse(tree1, NULL, bv1, tree2, NULL, child_bv, tf1, tf2)) + if(OcTreeIntersectRecurse(tree1, nullptr, bv1, tree2, nullptr, child_bv, tf1, tf2)) return true; } } } else { - if(OcTreeIntersectRecurse(tree1, NULL, bv1, tree2, NULL, bv2, tf1, tf2)) + if(OcTreeIntersectRecurse(tree1, nullptr, bv1, tree2, nullptr, bv2, tf1, tf2)) return true; } @@ -1044,21 +1044,21 @@ bool OcTreeSolver::OcTreeIntersectRecurse(const OcTree* tr const typename OcTree::OcTreeNode* child = tree1->getNodeChild(root1, i); AABB child_bv; computeChildBV(bv1, i, child_bv); - if(OcTreeIntersectRecurse(tree1, child, child_bv, tree2, NULL, bv2, tf1, tf2)) + if(OcTreeIntersectRecurse(tree1, child, child_bv, tree2, nullptr, bv2, tf1, tf2)) return true; } else { AABB child_bv; computeChildBV(bv1, i, child_bv); - if(OcTreeIntersectRecurse(tree1, NULL, child_bv, tree2, NULL, bv2, tf1, tf2)) + if(OcTreeIntersectRecurse(tree1, nullptr, child_bv, tree2, nullptr, bv2, tf1, tf2)) return true; } } } else { - if(OcTreeIntersectRecurse(tree1, NULL, bv1, tree2, NULL, bv2, tf1, tf2)) + if(OcTreeIntersectRecurse(tree1, nullptr, bv1, tree2, nullptr, bv2, tf1, tf2)) return true; } @@ -1192,7 +1192,7 @@ bool OcTreeSolver::OcTreeIntersectRecurse(const OcTree* tr AABB child_bv; computeChildBV(bv1, i, child_bv); - if(OcTreeIntersectRecurse(tree1, NULL, child_bv, + if(OcTreeIntersectRecurse(tree1, nullptr, child_bv, tree2, root2, bv2, tf1, tf2)) return true; @@ -1220,7 +1220,7 @@ bool OcTreeSolver::OcTreeIntersectRecurse(const OcTree* tr computeChildBV(bv2, i, child_bv); if(OcTreeIntersectRecurse(tree1, root1, bv1, - tree2, NULL, child_bv, + tree2, nullptr, child_bv, tf1, tf2)) return true; } diff --git a/test/test_fcl_broadphase_collision_1.cpp b/test/test_fcl_broadphase_collision_1.cpp index bcc3548c1..36b125217 100644 --- a/test/test_fcl_broadphase_collision_1.cpp +++ b/test/test_fcl_broadphase_collision_1.cpp @@ -73,7 +73,7 @@ struct GoogleDenseHashTable : public google::dense_hash_map, std::equal_to >() { - this->set_empty_key(NULL); + this->set_empty_key(nullptr); } }; #endif diff --git a/test/test_fcl_broadphase_collision_2.cpp b/test/test_fcl_broadphase_collision_2.cpp index b8dcb58ec..e08764e6f 100644 --- a/test/test_fcl_broadphase_collision_2.cpp +++ b/test/test_fcl_broadphase_collision_2.cpp @@ -68,7 +68,7 @@ struct GoogleDenseHashTable : public google::dense_hash_map, std::equal_to >() { - this->set_empty_key(NULL); + this->set_empty_key(nullptr); } }; #endif diff --git a/test/test_fcl_broadphase_distance.cpp b/test/test_fcl_broadphase_distance.cpp index a7e46832d..df29c1b2c 100644 --- a/test/test_fcl_broadphase_distance.cpp +++ b/test/test_fcl_broadphase_distance.cpp @@ -83,7 +83,7 @@ struct GoogleDenseHashTable : public google::dense_hash_map, std::equal_to >() { - this->set_empty_key(NULL); + this->set_empty_key(nullptr); } }; #endif diff --git a/test/test_fcl_collision.cpp b/test/test_fcl_collision.cpp index e71eed918..774e5fe65 100644 --- a/test/test_fcl_collision.cpp +++ b/test/test_fcl_collision.cpp @@ -125,7 +125,7 @@ void test_OBB_Box_test() GJKSolver_libccd solver; bool overlap_obb = obb1.overlap(obb2); - bool overlap_box = solver.shapeIntersect(box1, box1_tf, box2, box2_tf, NULL); + bool overlap_box = solver.shapeIntersect(box1, box1_tf, box2, box2_tf, nullptr); EXPECT_TRUE(overlap_obb == overlap_box); } @@ -165,7 +165,7 @@ void test_OBB_shape_test() computeBV(sphere, transforms[i], obb2); bool overlap_obb = obb1.overlap(obb2); - bool overlap_sphere = solver.shapeIntersect(box1, box1_tf, sphere, transforms[i], NULL); + bool overlap_sphere = solver.shapeIntersect(box1, box1_tf, sphere, transforms[i], nullptr); EXPECT_TRUE(overlap_obb >= overlap_sphere); } @@ -174,7 +174,7 @@ void test_OBB_shape_test() computeBV(ellipsoid, transforms[i], obb2); bool overlap_obb = obb1.overlap(obb2); - bool overlap_ellipsoid = solver.shapeIntersect(box1, box1_tf, ellipsoid, transforms[i], NULL); + bool overlap_ellipsoid = solver.shapeIntersect(box1, box1_tf, ellipsoid, transforms[i], nullptr); EXPECT_TRUE(overlap_obb >= overlap_ellipsoid); } @@ -183,7 +183,7 @@ void test_OBB_shape_test() computeBV(capsule, transforms[i], obb2); bool overlap_obb = obb1.overlap(obb2); - bool overlap_capsule = solver.shapeIntersect(box1, box1_tf, capsule, transforms[i], NULL); + bool overlap_capsule = solver.shapeIntersect(box1, box1_tf, capsule, transforms[i], nullptr); EXPECT_TRUE(overlap_obb >= overlap_capsule); } @@ -192,7 +192,7 @@ void test_OBB_shape_test() computeBV(cone, transforms[i], obb2); bool overlap_obb = obb1.overlap(obb2); - bool overlap_cone = solver.shapeIntersect(box1, box1_tf, cone, transforms[i], NULL); + bool overlap_cone = solver.shapeIntersect(box1, box1_tf, cone, transforms[i], nullptr); EXPECT_TRUE(overlap_obb >= overlap_cone); } @@ -201,7 +201,7 @@ void test_OBB_shape_test() computeBV(cylinder, transforms[i], obb2); bool overlap_obb = obb1.overlap(obb2); - bool overlap_cylinder = solver.shapeIntersect(box1, box1_tf, cylinder, transforms[i], NULL); + bool overlap_cylinder = solver.shapeIntersect(box1, box1_tf, cylinder, transforms[i], nullptr); EXPECT_TRUE(overlap_obb >= overlap_cylinder); } } diff --git a/test/test_fcl_distance.cpp b/test/test_fcl_distance.cpp index dd4710e95..37568c982 100644 --- a/test/test_fcl_distance.cpp +++ b/test/test_fcl_distance.cpp @@ -337,7 +337,7 @@ void distance_Test_Oriented(const Transform3& tf, node.enable_statistics = verbose; - distance(&node, NULL, qsize); + distance(&node, nullptr, qsize); // points are in local coordinate, to global coordinate Vector3 p1 = local_result.nearest_points[0]; @@ -393,7 +393,7 @@ void distance_Test(const Transform3& tf, node.enable_statistics = verbose; - distance(&node, NULL, qsize); + distance(&node, nullptr, qsize); distance_result.distance = local_result.min_distance; distance_result.p1 = local_result.nearest_points[0]; diff --git a/test/test_fcl_geometric_shapes.cpp b/test/test_fcl_geometric_shapes.cpp index a3f66c23c..187adabf2 100755 --- a/test/test_fcl_geometric_shapes.cpp +++ b/test/test_fcl_geometric_shapes.cpp @@ -437,11 +437,11 @@ void testShapeIntersection( // Check only whether they are colliding or not. if (solver_type == GST_LIBCCD) { - res = solver1().shapeIntersect(s1, tf1, s2, tf2, NULL); + res = solver1().shapeIntersect(s1, tf1, s2, tf2, nullptr); } else if (solver_type == GST_INDEP) { - res = solver2().shapeIntersect(s1, tf1, s2, tf2, NULL); + res = solver2().shapeIntersect(s1, tf1, s2, tf2, nullptr); } else { @@ -1184,27 +1184,27 @@ void test_shapeIntersection_spheretriangle() Vector3 normal; bool res; - res = solver1().shapeTriangleIntersect(s, Transform3::Identity(), t[0], t[1], t[2], NULL, NULL, NULL); + res = solver1().shapeTriangleIntersect(s, Transform3::Identity(), t[0], t[1], t[2], nullptr, nullptr, nullptr); EXPECT_TRUE(res); - res = solver1().shapeTriangleIntersect(s, transform, t[0], t[1], t[2], transform, NULL, NULL, NULL); + res = solver1().shapeTriangleIntersect(s, transform, t[0], t[1], t[2], transform, nullptr, nullptr, nullptr); EXPECT_TRUE(res); t[0] << 30, 0, 0; t[1] << 9.9, -20, 0; t[2] << 9.9, 20, 0; - res = solver1().shapeTriangleIntersect(s, Transform3::Identity(), t[0], t[1], t[2], NULL, NULL, NULL); + res = solver1().shapeTriangleIntersect(s, Transform3::Identity(), t[0], t[1], t[2], nullptr, nullptr, nullptr); EXPECT_TRUE(res); - res = solver1().shapeTriangleIntersect(s, transform, t[0], t[1], t[2], transform, NULL, NULL, NULL); + res = solver1().shapeTriangleIntersect(s, transform, t[0], t[1], t[2], transform, nullptr, nullptr, nullptr); EXPECT_TRUE(res); - res = solver1().shapeTriangleIntersect(s, Transform3::Identity(), t[0], t[1], t[2], NULL, NULL, &normal); + res = solver1().shapeTriangleIntersect(s, Transform3::Identity(), t[0], t[1], t[2], nullptr, nullptr, &normal); EXPECT_TRUE(res); EXPECT_TRUE(normal.isApprox(Vector3(1, 0, 0), 1e-9)); - res = solver1().shapeTriangleIntersect(s, transform, t[0], t[1], t[2], transform, NULL, NULL, &normal); + res = solver1().shapeTriangleIntersect(s, transform, t[0], t[1], t[2], transform, nullptr, nullptr, &normal); EXPECT_TRUE(res); EXPECT_TRUE(normal.isApprox(transform.linear() * Vector3(1, 0, 0), 1e-9)); } @@ -1232,27 +1232,27 @@ void test_shapeIntersection_halfspacetriangle() Vector3 normal; bool res; - res = solver1().shapeTriangleIntersect(hs, Transform3::Identity(), t[0], t[1], t[2], Transform3::Identity(), NULL, NULL, NULL); + res = solver1().shapeTriangleIntersect(hs, Transform3::Identity(), t[0], t[1], t[2], Transform3::Identity(), nullptr, nullptr, nullptr); EXPECT_TRUE(res); - res = solver1().shapeTriangleIntersect(hs, transform, t[0], t[1], t[2], transform, NULL, NULL, NULL); + res = solver1().shapeTriangleIntersect(hs, transform, t[0], t[1], t[2], transform, nullptr, nullptr, nullptr); EXPECT_TRUE(res); t[0] << 20, 0, 0; t[1] << 0, -20, 0; t[2] << 0, 20, 0; - res = solver1().shapeTriangleIntersect(hs, Transform3::Identity(), t[0], t[1], t[2], Transform3::Identity(), NULL, NULL, NULL); + res = solver1().shapeTriangleIntersect(hs, Transform3::Identity(), t[0], t[1], t[2], Transform3::Identity(), nullptr, nullptr, nullptr); EXPECT_TRUE(res); - res = solver1().shapeTriangleIntersect(hs, transform, t[0], t[1], t[2], transform, NULL, NULL, NULL); + res = solver1().shapeTriangleIntersect(hs, transform, t[0], t[1], t[2], transform, nullptr, nullptr, nullptr); EXPECT_TRUE(res); - res = solver1().shapeTriangleIntersect(hs, Transform3::Identity(), t[0], t[1], t[2], Transform3::Identity(), NULL, NULL, &normal); + res = solver1().shapeTriangleIntersect(hs, Transform3::Identity(), t[0], t[1], t[2], Transform3::Identity(), nullptr, nullptr, &normal); EXPECT_TRUE(res); EXPECT_TRUE(normal.isApprox(Vector3(1, 0, 0), 1e-9)); - res = solver1().shapeTriangleIntersect(hs, transform, t[0], t[1], t[2], transform, NULL, NULL, &normal); + res = solver1().shapeTriangleIntersect(hs, transform, t[0], t[1], t[2], transform, nullptr, nullptr, &normal); EXPECT_TRUE(res); EXPECT_TRUE(normal.isApprox(transform.linear() * Vector3(1, 0, 0), 1e-9)); } @@ -1280,27 +1280,27 @@ void test_shapeIntersection_planetriangle() Vector3 normal; bool res; - res = solver1().shapeTriangleIntersect(hs, Transform3::Identity(), t[0], t[1], t[2], Transform3::Identity(), NULL, NULL, NULL); + res = solver1().shapeTriangleIntersect(hs, Transform3::Identity(), t[0], t[1], t[2], Transform3::Identity(), nullptr, nullptr, nullptr); EXPECT_TRUE(res); - res = solver1().shapeTriangleIntersect(hs, transform, t[0], t[1], t[2], transform, NULL, NULL, NULL); + res = solver1().shapeTriangleIntersect(hs, transform, t[0], t[1], t[2], transform, nullptr, nullptr, nullptr); EXPECT_TRUE(res); t[0] << 20, 0, 0; t[1] << -0.1, -20, 0; t[2] << -0.1, 20, 0; - res = solver1().shapeTriangleIntersect(hs, Transform3::Identity(), t[0], t[1], t[2], Transform3::Identity(), NULL, NULL, NULL); + res = solver1().shapeTriangleIntersect(hs, Transform3::Identity(), t[0], t[1], t[2], Transform3::Identity(), nullptr, nullptr, nullptr); EXPECT_TRUE(res); - res = solver1().shapeTriangleIntersect(hs, transform, t[0], t[1], t[2], transform, NULL, NULL, NULL); + res = solver1().shapeTriangleIntersect(hs, transform, t[0], t[1], t[2], transform, nullptr, nullptr, nullptr); EXPECT_TRUE(res); - res = solver1().shapeTriangleIntersect(hs, Transform3::Identity(), t[0], t[1], t[2], Transform3::Identity(), NULL, NULL, &normal); + res = solver1().shapeTriangleIntersect(hs, Transform3::Identity(), t[0], t[1], t[2], Transform3::Identity(), nullptr, nullptr, &normal); EXPECT_TRUE(res); EXPECT_TRUE(normal.isApprox(Vector3(1, 0, 0), 1e-9)); - res = solver1().shapeTriangleIntersect(hs, transform, t[0], t[1], t[2], transform, NULL, NULL, &normal); + res = solver1().shapeTriangleIntersect(hs, transform, t[0], t[1], t[2], transform, nullptr, nullptr, &normal); EXPECT_TRUE(res); EXPECT_TRUE(normal.isApprox(transform.linear() * Vector3(1, 0, 0), 1e-9)); } @@ -4575,26 +4575,26 @@ void test_shapeIntersectionGJK_spheretriangle() Vector3 normal; bool res; - res = solver2().shapeTriangleIntersect(s, Transform3::Identity(), t[0], t[1], t[2], NULL, NULL, NULL); + res = solver2().shapeTriangleIntersect(s, Transform3::Identity(), t[0], t[1], t[2], nullptr, nullptr, nullptr); EXPECT_TRUE(res); - res = solver2().shapeTriangleIntersect(s, transform, t[0], t[1], t[2], transform, NULL, NULL, NULL); + res = solver2().shapeTriangleIntersect(s, transform, t[0], t[1], t[2], transform, nullptr, nullptr, nullptr); EXPECT_TRUE(res); t[0] << 30, 0, 0; t[1] << 9.9, -20, 0; t[2] << 9.9, 20, 0; - res = solver2().shapeTriangleIntersect(s, Transform3::Identity(), t[0], t[1], t[2], NULL, NULL, NULL); + res = solver2().shapeTriangleIntersect(s, Transform3::Identity(), t[0], t[1], t[2], nullptr, nullptr, nullptr); EXPECT_TRUE(res); - res = solver2().shapeTriangleIntersect(s, transform, t[0], t[1], t[2], transform, NULL, NULL, NULL); + res = solver2().shapeTriangleIntersect(s, transform, t[0], t[1], t[2], transform, nullptr, nullptr, nullptr); EXPECT_TRUE(res); - res = solver2().shapeTriangleIntersect(s, Transform3::Identity(), t[0], t[1], t[2], NULL, NULL, &normal); + res = solver2().shapeTriangleIntersect(s, Transform3::Identity(), t[0], t[1], t[2], nullptr, nullptr, &normal); EXPECT_TRUE(res); EXPECT_TRUE(normal.isApprox(Vector3(1, 0, 0), 1e-9)); - res = solver2().shapeTriangleIntersect(s, transform, t[0], t[1], t[2], transform, NULL, NULL, &normal); + res = solver2().shapeTriangleIntersect(s, transform, t[0], t[1], t[2], transform, nullptr, nullptr, &normal); EXPECT_TRUE(res); EXPECT_TRUE(normal.isApprox(transform.linear() * Vector3(1, 0, 0), 1e-9)); } @@ -4622,27 +4622,27 @@ void test_shapeIntersectionGJK_halfspacetriangle() Vector3 normal; bool res; - res = solver2().shapeTriangleIntersect(hs, Transform3::Identity(), t[0], t[1], t[2], Transform3::Identity(), NULL, NULL, NULL); + res = solver2().shapeTriangleIntersect(hs, Transform3::Identity(), t[0], t[1], t[2], Transform3::Identity(), nullptr, nullptr, nullptr); EXPECT_TRUE(res); - res = solver2().shapeTriangleIntersect(hs, transform, t[0], t[1], t[2], transform, NULL, NULL, NULL); + res = solver2().shapeTriangleIntersect(hs, transform, t[0], t[1], t[2], transform, nullptr, nullptr, nullptr); EXPECT_TRUE(res); t[0] << 20, 0, 0; t[1] << -0.1, -20, 0; t[2] << -0.1, 20, 0; - res = solver2().shapeTriangleIntersect(hs, Transform3::Identity(), t[0], t[1], t[2], Transform3::Identity(), NULL, NULL, NULL); + res = solver2().shapeTriangleIntersect(hs, Transform3::Identity(), t[0], t[1], t[2], Transform3::Identity(), nullptr, nullptr, nullptr); EXPECT_TRUE(res); - res = solver2().shapeTriangleIntersect(hs, transform, t[0], t[1], t[2], transform, NULL, NULL, NULL); + res = solver2().shapeTriangleIntersect(hs, transform, t[0], t[1], t[2], transform, nullptr, nullptr, nullptr); EXPECT_TRUE(res); - res = solver2().shapeTriangleIntersect(hs, Transform3::Identity(), t[0], t[1], t[2], Transform3::Identity(), NULL, NULL, &normal); + res = solver2().shapeTriangleIntersect(hs, Transform3::Identity(), t[0], t[1], t[2], Transform3::Identity(), nullptr, nullptr, &normal); EXPECT_TRUE(res); EXPECT_TRUE(normal.isApprox(Vector3(1, 0, 0), 1e-9)); - res = solver2().shapeTriangleIntersect(hs, transform, t[0], t[1], t[2], transform, NULL, NULL, &normal); + res = solver2().shapeTriangleIntersect(hs, transform, t[0], t[1], t[2], transform, nullptr, nullptr, &normal); EXPECT_TRUE(res); EXPECT_TRUE(normal.isApprox(transform.linear() * Vector3(1, 0, 0), 1e-9)); } @@ -4670,27 +4670,27 @@ void test_shapeIntersectionGJK_planetriangle() Vector3 normal; bool res; - res = solver1().shapeTriangleIntersect(hs, Transform3::Identity(), t[0], t[1], t[2], Transform3::Identity(), NULL, NULL, NULL); + res = solver1().shapeTriangleIntersect(hs, Transform3::Identity(), t[0], t[1], t[2], Transform3::Identity(), nullptr, nullptr, nullptr); EXPECT_TRUE(res); - res = solver1().shapeTriangleIntersect(hs, transform, t[0], t[1], t[2], transform, NULL, NULL, NULL); + res = solver1().shapeTriangleIntersect(hs, transform, t[0], t[1], t[2], transform, nullptr, nullptr, nullptr); EXPECT_TRUE(res); t[0] << 20, 0, 0; t[1] << -0.1, -20, 0; t[2] << -0.1, 20, 0; - res = solver2().shapeTriangleIntersect(hs, Transform3::Identity(), t[0], t[1], t[2], Transform3::Identity(), NULL, NULL, NULL); + res = solver2().shapeTriangleIntersect(hs, Transform3::Identity(), t[0], t[1], t[2], Transform3::Identity(), nullptr, nullptr, nullptr); EXPECT_TRUE(res); - res = solver2().shapeTriangleIntersect(hs, transform, t[0], t[1], t[2], transform, NULL, NULL, NULL); + res = solver2().shapeTriangleIntersect(hs, transform, t[0], t[1], t[2], transform, nullptr, nullptr, nullptr); EXPECT_TRUE(res); - res = solver2().shapeTriangleIntersect(hs, Transform3::Identity(), t[0], t[1], t[2], Transform3::Identity(), NULL, NULL, &normal); + res = solver2().shapeTriangleIntersect(hs, Transform3::Identity(), t[0], t[1], t[2], Transform3::Identity(), nullptr, nullptr, &normal); EXPECT_TRUE(res); EXPECT_TRUE(normal.isApprox(Vector3(1, 0, 0), 1e-9)); - res = solver2().shapeTriangleIntersect(hs, transform, t[0], t[1], t[2], transform, NULL, NULL, &normal); + res = solver2().shapeTriangleIntersect(hs, transform, t[0], t[1], t[2], transform, nullptr, nullptr, &normal); EXPECT_TRUE(res); EXPECT_TRUE(normal.isApprox(transform.linear() * Vector3(1, 0, 0), 1e-9)); } diff --git a/test/test_fcl_sphere_capsule.cpp b/test/test_fcl_sphere_capsule.cpp index 53f29ba7d..42aef6d36 100644 --- a/test/test_fcl_sphere_capsule.cpp +++ b/test/test_fcl_sphere_capsule.cpp @@ -57,7 +57,7 @@ void test_Sphere_Capsule_Intersect_test_separated_z() Capsule capsule (50, 200.); Transform3 capsule_transform(Translation3(Vector3(0., 0., 200))); - EXPECT_TRUE (!solver.shapeIntersect(sphere1, sphere1_transform, capsule, capsule_transform, NULL)); + EXPECT_TRUE (!solver.shapeIntersect(sphere1, sphere1_transform, capsule, capsule_transform, nullptr)); } GTEST_TEST(FCL_SPHERE_CAPSULE, Sphere_Capsule_Intersect_test_separated_z) @@ -78,7 +78,7 @@ void test_Sphere_Capsule_Intersect_test_separated_z_negative() Capsule capsule (50, 200.); Transform3 capsule_transform(Translation3(Vector3(0., 0., -200))); - EXPECT_TRUE (!solver.shapeIntersect(sphere1, sphere1_transform, capsule, capsule_transform, NULL)); + EXPECT_TRUE (!solver.shapeIntersect(sphere1, sphere1_transform, capsule, capsule_transform, nullptr)); } GTEST_TEST(FCL_SPHERE_CAPSULE, Sphere_Capsule_Intersect_test_separated_z_negative) @@ -99,7 +99,7 @@ void test_Sphere_Capsule_Intersect_test_separated_x() Capsule capsule (50, 200.); Transform3 capsule_transform(Translation3(Vector3(150., 0., 0.))); - EXPECT_TRUE (!solver.shapeIntersect(sphere1, sphere1_transform, capsule, capsule_transform, NULL)); + EXPECT_TRUE (!solver.shapeIntersect(sphere1, sphere1_transform, capsule, capsule_transform, nullptr)); } GTEST_TEST(FCL_SPHERE_CAPSULE, Sphere_Capsule_Intersect_test_separated_x) @@ -127,7 +127,7 @@ void test_Sphere_Capsule_Intersect_test_separated_capsule_rotated() capsule_transform.linear() = rotation; capsule_transform.translation() = Vector3(150., 0., 0.); - EXPECT_TRUE (!solver.shapeIntersect(sphere1, sphere1_transform, capsule, capsule_transform, NULL)); + EXPECT_TRUE (!solver.shapeIntersect(sphere1, sphere1_transform, capsule, capsule_transform, nullptr)); } GTEST_TEST(FCL_SPHERE_CAPSULE, Sphere_Capsule_Intersect_test_separated_capsule_rotated) diff --git a/test/test_fcl_utility.cpp b/test/test_fcl_utility.cpp index 655752c9d..1c51f1c31 100644 --- a/test/test_fcl_utility.cpp +++ b/test/test_fcl_utility.cpp @@ -74,7 +74,7 @@ void Timer::start() #ifdef _WIN32 QueryPerformanceCounter(&startCount); #else - gettimeofday(&startCount, NULL); + gettimeofday(&startCount, nullptr); #endif } @@ -86,7 +86,7 @@ void Timer::stop() #ifdef _WIN32 QueryPerformanceCounter(&endCount); #else - gettimeofday(&endCount, NULL); + gettimeofday(&endCount, nullptr); #endif } @@ -101,7 +101,7 @@ double Timer::getElapsedTimeInMicroSec() endTimeInMicroSec = endCount.QuadPart * (1000000.0 / frequency.QuadPart); #else if(!stopped) - gettimeofday(&endCount, NULL); + gettimeofday(&endCount, nullptr); startTimeInMicroSec = (startCount.tv_sec * 1000000.0) + startCount.tv_usec; endTimeInMicroSec = (endCount.tv_sec * 1000000.0) + endCount.tv_usec; diff --git a/test/test_fcl_utility.h b/test/test_fcl_utility.h index 4c36c729c..000f7102f 100644 --- a/test/test_fcl_utility.h +++ b/test/test_fcl_utility.h @@ -275,22 +275,22 @@ void loadOBJFile(const char* filename, std::vector>& points, std::vec { if(first_token[1] == 'n') { - strtok(NULL, "\t "); - strtok(NULL, "\t "); - strtok(NULL, "\t "); + strtok(nullptr, "\t "); + strtok(nullptr, "\t "); + strtok(nullptr, "\t "); has_normal = true; } else if(first_token[1] == 't') { - strtok(NULL, "\t "); - strtok(NULL, "\t "); + strtok(nullptr, "\t "); + strtok(nullptr, "\t "); has_texture = true; } else { - S x = (S)atof(strtok(NULL, "\t ")); - S y = (S)atof(strtok(NULL, "\t ")); - S z = (S)atof(strtok(NULL, "\t ")); + S x = (S)atof(strtok(nullptr, "\t ")); + S y = (S)atof(strtok(nullptr, "\t ")); + S z = (S)atof(strtok(nullptr, "\t ")); Vector3 p(x, y, z); points.push_back(p); } @@ -301,7 +301,7 @@ void loadOBJFile(const char* filename, std::vector>& points, std::vec Triangle tri; char* data[30]; int n = 0; - while((data[n] = strtok(NULL, "\t \r\n")) != NULL) + while((data[n] = strtok(nullptr, "\t \r\n")) != nullptr) { if(strlen(data[n])) n++; From 946b71d2bfe5b007d4b1d901b707ff205e569100 Mon Sep 17 00:00:00 2001 From: Jeongseok Lee Date: Sat, 13 Aug 2016 07:17:40 -0400 Subject: [PATCH 09/10] Fix path to libccd and Eigen for Appveyor --- .appveyor.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index ffd0dfa8f..e75d122e1 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -25,6 +25,8 @@ configuration: before_build: - cmd: if "%platform%"=="Win32" set CMAKE_GENERATOR_NAME=Visual Studio 14 2015 - cmd: if "%platform%"=="x64" set CMAKE_GENERATOR_NAME=Visual Studio 14 2015 Win64 + - cmd: if "%platform%"=="Win32" set PROGRAM_FILES_PATH=Program Files (x86) + - cmd: if "%platform%"=="x64" set PROGRAM_FILES_PATH=Program Files - cmd: if not exist C:\"Program Files"\libccd\lib\ccd.lib ( curl -L -o libccd-2.0.tar.gz https://github.com/danfis/libccd/archive/v2.0.tar.gz && cmake -E tar zxf libccd-2.0.tar.gz && @@ -46,7 +48,7 @@ before_build: - cmd: set - cmd: mkdir build - cmd: cd build - - cmd: cmake -G "%CMAKE_GENERATOR_NAME%" -DCMAKE_BUILD_TYPE=%Configuration% -DCCD_INCLUDE_DIRS="C:\Program Files\libccd\include" -DCCD_LIBRARY="C:\Program Files\libccd\lib\ccd.lib" -DEIGEN3_INCLUDE_DIR="C:\Program Files\Eigen\include\eigen3" .. + - cmd: cmake -G "%CMAKE_GENERATOR_NAME%" -DCMAKE_BUILD_TYPE=%Configuration% -DCCD_INCLUDE_DIRS="C:\%PROGRAM_FILES_PATH%\libccd\include" -DCCD_LIBRARY="C:\%PROGRAM_FILES_PATH%\libccd\lib\ccd.lib" -DEIGEN3_INCLUDE_DIR="C:\%PROGRAM_FILES_PATH%\Eigen\include\eigen3" .. build: project: C:\projects\fcl\build\fcl.sln From 61850991b6feff58943331c6e1208cf6ca483155 Mon Sep 17 00:00:00 2001 From: Jeongseok Lee Date: Sat, 13 Aug 2016 14:36:55 -0400 Subject: [PATCH 10/10] Use emplace_back where applicable --- include/fcl/BVH/BVH_front.h | 2 +- include/fcl/narrowphase/detail/halfspace.h | 18 +++++++-------- include/fcl/narrowphase/detail/plane.h | 22 +++++++++---------- .../fcl/narrowphase/detail/sphere_capsule.h | 2 +- .../fcl/narrowphase/detail/sphere_sphere.h | 2 +- include/fcl/narrowphase/gjk_solver_indep.h | 2 +- include/fcl/narrowphase/gjk_solver_libccd.h | 2 +- test/test_fcl_utility.h | 3 +-- 8 files changed, 26 insertions(+), 27 deletions(-) diff --git a/include/fcl/BVH/BVH_front.h b/include/fcl/BVH/BVH_front.h index 081ed6153..7378212a1 100644 --- a/include/fcl/BVH/BVH_front.h +++ b/include/fcl/BVH/BVH_front.h @@ -83,7 +83,7 @@ inline BVHFrontNode::BVHFrontNode(int left_, int right_) //============================================================================== inline void updateFrontList(BVHFrontList* front_list, int b1, int b2) { - if(front_list) front_list->push_back(BVHFrontNode(b1, b2)); + if(front_list) front_list->emplace_back(b1, b2); } } // namespace fcl diff --git a/include/fcl/narrowphase/detail/halfspace.h b/include/fcl/narrowphase/detail/halfspace.h index e5913405b..35807fafa 100755 --- a/include/fcl/narrowphase/detail/halfspace.h +++ b/include/fcl/narrowphase/detail/halfspace.h @@ -180,7 +180,7 @@ bool sphereHalfspaceIntersect(const Sphere& s1, const Transform3& tf1, const Vector3 point = center - new_s2.n * s1.radius + new_s2.n * (depth * 0.5); const S penetration_depth = depth; - contacts->push_back(ContactPoint(normal, point, penetration_depth)); + contacts->emplace_back(normal, point, penetration_depth); } return true; @@ -222,7 +222,7 @@ bool ellipsoidHalfspaceIntersect(const Ellipsoid& s1, const Transform3& tf const Vector3 point = tf1 * point_in_halfspace_coords; // roughly speaking, a middle point of the intersecting volume const S penetration_depth = depth; - contacts->push_back(ContactPoint(normal, point, penetration_depth)); + contacts->emplace_back(normal, point, penetration_depth); } return true; @@ -315,7 +315,7 @@ bool boxHalfspaceIntersect(const Box& s1, const Transform3& tf1, const Vector3 point = p + new_s2.n * (depth * 0.5); const S penetration_depth = depth; - contacts->push_back(ContactPoint(normal, point, penetration_depth)); + contacts->emplace_back(normal, point, penetration_depth); } return true; @@ -348,7 +348,7 @@ bool capsuleHalfspaceIntersect(const Capsule& s1, const Transform3& tf1, const Vector3 point = T + new_s2.n * (0.5 * depth - s1.radius); const S penetration_depth = depth; - contacts->push_back(ContactPoint(normal, point, penetration_depth)); + contacts->emplace_back(normal, point, penetration_depth); } return true; @@ -368,7 +368,7 @@ bool capsuleHalfspaceIntersect(const Capsule& s1, const Transform3& tf1, const Vector3 point = p - new_s2.n * s1.radius + new_s2.n * (0.5 * depth); // deepest point const S penetration_depth = depth; - contacts->push_back(ContactPoint(normal, point, penetration_depth)); + contacts->emplace_back(normal, point, penetration_depth); } return true; @@ -401,7 +401,7 @@ bool cylinderHalfspaceIntersect(const Cylinder& s1, const Transform3& tf1, const Vector3 point = T + new_s2.n * (0.5 * depth - s1.radius); const S penetration_depth = depth; - contacts->push_back(ContactPoint(normal, point, penetration_depth)); + contacts->emplace_back(normal, point, penetration_depth); } return true; @@ -431,7 +431,7 @@ bool cylinderHalfspaceIntersect(const Cylinder& s1, const Transform3& tf1, const Vector3 point = p + new_s2.n * (0.5 * depth); const S penetration_depth = depth; - contacts->push_back(ContactPoint(normal, point, penetration_depth)); + contacts->emplace_back(normal, point, penetration_depth); } return true; @@ -466,7 +466,7 @@ bool coneHalfspaceIntersect(const Cone& s1, const Transform3& tf1, const Vector3 point = T - dir_z * (s1.lz * 0.5) + new_s2.n * (0.5 * depth - s1.radius); const S penetration_depth = depth; - contacts->push_back(ContactPoint(normal, point, penetration_depth)); + contacts->emplace_back(normal, point, penetration_depth); } return true; @@ -499,7 +499,7 @@ bool coneHalfspaceIntersect(const Cone& s1, const Transform3& tf1, const Vector3 normal = -new_s2.n; const Vector3 point = ((d1 < d2) ? p1 : p2) + new_s2.n * (0.5 * penetration_depth); - contacts->push_back(ContactPoint(normal, point, penetration_depth)); + contacts->emplace_back(normal, point, penetration_depth); } return true; diff --git a/include/fcl/narrowphase/detail/plane.h b/include/fcl/narrowphase/detail/plane.h index c9666045b..7de0bc36f 100755 --- a/include/fcl/narrowphase/detail/plane.h +++ b/include/fcl/narrowphase/detail/plane.h @@ -174,7 +174,7 @@ bool spherePlaneIntersect(const Sphere& s1, const Transform3& tf1, const Vector3 point = center - new_s2.n * signed_dist; const S penetration_depth = depth; - contacts->push_back(ContactPoint(normal, point, penetration_depth)); + contacts->emplace_back(normal, point, penetration_depth); } return true; @@ -218,7 +218,7 @@ bool ellipsoidPlaneIntersect(const Ellipsoid& s1, const Transform3& tf1, const Vector3 point = (signed_dist > 0) ? tf1 * point_in_plane_coords : tf1 * -point_in_plane_coords; // a middle point of the intersecting volume const S penetration_depth = depth; - contacts->push_back(ContactPoint(normal, point, penetration_depth)); + contacts->emplace_back(normal, point, penetration_depth); } return true; @@ -295,7 +295,7 @@ bool boxPlaneIntersect(const Box& s1, const Transform3& tf1, const Vector3 point = p - new_s2.n * new_s2.signedDistance(p); const S penetration_depth = depth; - contacts->push_back(ContactPoint(normal, point, penetration_depth)); + contacts->emplace_back(normal, point, penetration_depth); } return true; @@ -369,7 +369,7 @@ bool capsulePlaneIntersect(const Capsule& s1, const Transform3& tf1, const Vector3 point = p1 * (abs_d2 / (abs_d1 + abs_d2)) + p2 * (abs_d1 / (abs_d1 + abs_d2)); const S penetration_depth = abs_d1 + s1.radius; - contacts->push_back(ContactPoint(normal, point, penetration_depth)); + contacts->emplace_back(normal, point, penetration_depth); } } else @@ -380,7 +380,7 @@ bool capsulePlaneIntersect(const Capsule& s1, const Transform3& tf1, const Vector3 point = p1 * (abs_d2 / (abs_d1 + abs_d2)) + p2 * (abs_d1 / (abs_d1 + abs_d2)); const S penetration_depth = abs_d2 + s1.radius; - contacts->push_back(ContactPoint(normal, point, penetration_depth)); + contacts->emplace_back(normal, point, penetration_depth); } } return true; @@ -416,7 +416,7 @@ bool capsulePlaneIntersect(const Capsule& s1, const Transform3& tf1, point = c; } - contacts->push_back(ContactPoint(normal, point, penetration_depth)); + contacts->emplace_back(normal, point, penetration_depth); } return true; @@ -479,7 +479,7 @@ bool cylinderPlaneIntersect(const Cylinder& s1, const Transform3& tf1, const Vector3 point = T - new_s2.n * d; const S penetration_depth = depth; - contacts->push_back(ContactPoint(normal, point, penetration_depth)); + contacts->emplace_back(normal, point, penetration_depth); } return true; } @@ -527,7 +527,7 @@ bool cylinderPlaneIntersect(const Cylinder& s1, const Transform3& tf1, const Vector3 point = c2 - new_s2.n * d2; const S penetration_depth = abs_d2; - contacts->push_back(ContactPoint(normal, point, penetration_depth)); + contacts->emplace_back(normal, point, penetration_depth); } } else @@ -538,7 +538,7 @@ bool cylinderPlaneIntersect(const Cylinder& s1, const Transform3& tf1, const Vector3 point = c1 - new_s2.n * d1; const S penetration_depth = abs_d1; - contacts->push_back(ContactPoint(normal, point, penetration_depth)); + contacts->emplace_back(normal, point, penetration_depth); } } return true; @@ -578,7 +578,7 @@ bool conePlaneIntersect(const Cone& s1, const Transform3& tf1, const Vector3 point = T - dir_z * (0.5 * s1.lz) + dir_z * (0.5 * depth / s1.radius * s1.lz) - new_s2.n * d; const S penetration_depth = depth; - contacts->push_back(ContactPoint(normal, point, penetration_depth)); + contacts->emplace_back(normal, point, penetration_depth); } return true; @@ -666,7 +666,7 @@ bool conePlaneIntersect(const Cone& s1, const Transform3& tf1, point = (t1 + t2) * 0.5; } - contacts->push_back(ContactPoint(normal, point, penetration_depth)); + contacts->emplace_back(normal, point, penetration_depth); } return true; diff --git a/include/fcl/narrowphase/detail/sphere_capsule.h b/include/fcl/narrowphase/detail/sphere_capsule.h index fe4c0c72a..55aa7f7c5 100755 --- a/include/fcl/narrowphase/detail/sphere_capsule.h +++ b/include/fcl/narrowphase/detail/sphere_capsule.h @@ -117,7 +117,7 @@ bool sphereCapsuleIntersect(const Sphere& s1, const Transform3& tf1, const Vector3 point = tf2 * (segment_point + local_normal * distance); const S penetration_depth = -distance; - contacts->push_back(ContactPoint(normal, point, penetration_depth)); + contacts->emplace_back(normal, point, penetration_depth); } return true; diff --git a/include/fcl/narrowphase/detail/sphere_sphere.h b/include/fcl/narrowphase/detail/sphere_sphere.h index fa8428973..40c5faa23 100755 --- a/include/fcl/narrowphase/detail/sphere_sphere.h +++ b/include/fcl/narrowphase/detail/sphere_sphere.h @@ -80,7 +80,7 @@ bool sphereSphereIntersect(const Sphere& s1, const Transform3& tf1, const Vector3 normal = len > 0 ? (diff / len).eval() : diff; const Vector3 point = tf1.translation() + diff * s1.radius / (s1.radius + s2.radius); const S penetration_depth = s1.radius + s2.radius - len; - contacts->push_back(ContactPoint(normal, point, penetration_depth)); + contacts->emplace_back(normal, point, penetration_depth); } return true; diff --git a/include/fcl/narrowphase/gjk_solver_indep.h b/include/fcl/narrowphase/gjk_solver_indep.h index f381f4ba8..fc9d0c6ba 100755 --- a/include/fcl/narrowphase/gjk_solver_indep.h +++ b/include/fcl/narrowphase/gjk_solver_indep.h @@ -260,7 +260,7 @@ struct ShapeIntersectIndepImpl Vector3 normal = epa.normal; Vector3 point = tf1 * (w0 - epa.normal*(epa.depth *0.5)); S depth = -epa.depth; - contacts->push_back(ContactPoint(normal, point, depth)); + contacts->emplace_back(normal, point, depth); } return true; } diff --git a/include/fcl/narrowphase/gjk_solver_libccd.h b/include/fcl/narrowphase/gjk_solver_libccd.h index f3822a2fa..2951c4eba 100755 --- a/include/fcl/narrowphase/gjk_solver_libccd.h +++ b/include/fcl/narrowphase/gjk_solver_libccd.h @@ -240,7 +240,7 @@ struct ShapeIntersectLibccdImpl &point, &depth, &normal); - contacts->push_back(ContactPoint(normal, point, depth)); + contacts->emplace_back(normal, point, depth); } else { diff --git a/test/test_fcl_utility.h b/test/test_fcl_utility.h index 000f7102f..80eaa31dc 100644 --- a/test/test_fcl_utility.h +++ b/test/test_fcl_utility.h @@ -291,8 +291,7 @@ void loadOBJFile(const char* filename, std::vector>& points, std::vec S x = (S)atof(strtok(nullptr, "\t ")); S y = (S)atof(strtok(nullptr, "\t ")); S z = (S)atof(strtok(nullptr, "\t ")); - Vector3 p(x, y, z); - points.push_back(p); + points.emplace_back(x, y, z); } } break;