diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c115cdf5..73cb0e54b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - The internal collision and distance functions of hpp-fcl now use `CollisionRequest::enable_contact` and `DistanceRequest::enable_signed_distance` to control whether or not penetration information should be computed. There are many scenarios where we don't need the penetration information and only want to know if objects are colliding and compute their distance only if they are disjoint. These flags allow the user to control the trade-off between performance vs. information of the library. - Fix convergence criterion of EPA; made GJK and EPA convergence criterion absolute + relative to scale to the shapes' dimensions; remove max face/vertices fields from EPA (these can be deduced from the max number of iterations) - Account for lateral borders in Height Fields model. +- Fix compilation error on recent APPLE compilers ([#539](https://github.com/humanoid-path-planner/hpp-fcl/pull/539)). - Fix printing of deprecated message ([#540](https://github.com/humanoid-path-planner/hpp-fcl/pull/540)). ## [2.4.1] - 2024-01-23 diff --git a/include/hpp/fcl/broadphase/detail/interval_tree.h b/include/hpp/fcl/broadphase/detail/interval_tree.h index 02ebfbbc2..bbcb1fec8 100644 --- a/include/hpp/fcl/broadphase/detail/interval_tree.h +++ b/include/hpp/fcl/broadphase/detail/interval_tree.h @@ -91,7 +91,7 @@ class HPP_FCL_DLLAPI IntervalTree { protected: IntervalTreeNode* root; - IntervalTreeNode* nil; + IntervalTreeNode* invalid_node; /// @brief left rotation of tree node void leftRotate(IntervalTreeNode* node); diff --git a/include/hpp/fcl/broadphase/detail/interval_tree_node.h b/include/hpp/fcl/broadphase/detail/interval_tree_node.h index e11702c99..e8a653c15 100644 --- a/include/hpp/fcl/broadphase/detail/interval_tree_node.h +++ b/include/hpp/fcl/broadphase/detail/interval_tree_node.h @@ -61,8 +61,8 @@ class HPP_FCL_DLLAPI IntervalTreeNode { ~IntervalTreeNode(); - /// @brief Print the interval node information: set left = nil and right = - /// root + /// @brief Print the interval node information: set left = invalid_node and + /// right = root void print(IntervalTreeNode* left, IntervalTreeNode* right) const; protected: diff --git a/src/broadphase/detail/interval_tree.cpp b/src/broadphase/detail/interval_tree.cpp index 7d5f3ebcd..567195988 100644 --- a/src/broadphase/detail/interval_tree.cpp +++ b/src/broadphase/detail/interval_tree.cpp @@ -48,15 +48,16 @@ namespace detail { //============================================================================== IntervalTree::IntervalTree() { - nil = new IntervalTreeNode; - nil->left = nil->right = nil->parent = nil; - nil->red = false; - nil->key = nil->high = nil->max_high = + invalid_node = new IntervalTreeNode; + invalid_node->left = invalid_node->right = invalid_node->parent = + invalid_node; + invalid_node->red = false; + invalid_node->key = invalid_node->high = invalid_node->max_high = -(std::numeric_limits::max)(); - nil->stored_interval = nullptr; + invalid_node->stored_interval = nullptr; root = new IntervalTreeNode; - root->parent = root->left = root->right = nil; + root->parent = root->left = root->right = invalid_node; root->key = root->high = root->max_high = (std::numeric_limits::max)(); root->red = false; @@ -75,11 +76,11 @@ IntervalTree::~IntervalTree() { IntervalTreeNode* x = root->left; std::deque nodes_to_free; - if (x != nil) { - if (x->left != nil) { + if (x != invalid_node) { + if (x->left != invalid_node) { nodes_to_free.push_back(x->left); } - if (x->right != nil) { + if (x->right != invalid_node) { nodes_to_free.push_back(x->right); } @@ -87,16 +88,16 @@ IntervalTree::~IntervalTree() { while (nodes_to_free.size() > 0) { x = nodes_to_free.back(); nodes_to_free.pop_back(); - if (x->left != nil) { + if (x->left != invalid_node) { nodes_to_free.push_back(x->left); } - if (x->right != nil) { + if (x->right != invalid_node) { nodes_to_free.push_back(x->right); } delete x; } } - delete nil; + delete invalid_node; delete root; free(recursion_node_stack); } @@ -108,7 +109,7 @@ void IntervalTree::leftRotate(IntervalTreeNode* x) { y = x->right; x->right = y->left; - if (y->left != nil) y->left->parent = x; + if (y->left != invalid_node) y->left->parent = x; y->parent = x->parent; @@ -132,7 +133,7 @@ void IntervalTree::rightRotate(IntervalTreeNode* y) { x = y->left; y->left = x->right; - if (nil != x->right) x->right->parent = y; + if (invalid_node != x->right) x->right->parent = y; x->parent = y->parent; if (y == y->parent->left) @@ -153,10 +154,10 @@ void IntervalTree::recursiveInsert(IntervalTreeNode* z) { IntervalTreeNode* x; IntervalTreeNode* y; - z->left = z->right = nil; + z->left = z->right = invalid_node; y = root; x = root->left; - while (x != nil) { + while (x != invalid_node) { y = x; if (x->key > z->key) x = x->left; @@ -234,8 +235,8 @@ IntervalTreeNode* IntervalTree::insert(SimpleInterval* new_interval) { IntervalTreeNode* IntervalTree::getSuccessor(IntervalTreeNode* x) const { IntervalTreeNode* y; - if (nil != (y = x->right)) { - while (y->left != nil) y = y->left; + if (invalid_node != (y = x->right)) { + while (y->left != invalid_node) y = y->left; return y; } else { y = x->parent; @@ -243,7 +244,7 @@ IntervalTreeNode* IntervalTree::getSuccessor(IntervalTreeNode* x) const { x = y; y = y->parent; } - if (y == root) return nil; + if (y == root) return invalid_node; return y; } } @@ -252,13 +253,13 @@ IntervalTreeNode* IntervalTree::getSuccessor(IntervalTreeNode* x) const { IntervalTreeNode* IntervalTree::getPredecessor(IntervalTreeNode* x) const { IntervalTreeNode* y; - if (nil != (y = x->left)) { - while (y->right != nil) y = y->right; + if (invalid_node != (y = x->left)) { + while (y->right != invalid_node) y = y->right; return y; } else { y = x->parent; while (x == y->left) { - if (y == root) return nil; + if (y == root) return invalid_node; x = y; y = y->parent; } @@ -268,9 +269,9 @@ IntervalTreeNode* IntervalTree::getPredecessor(IntervalTreeNode* x) const { //============================================================================== void IntervalTree::recursivePrint(IntervalTreeNode* x) const { - if (x != nil) { + if (x != invalid_node) { recursivePrint(x->left); - x->print(nil, root); + x->print(invalid_node, root); recursivePrint(x->right); } } @@ -346,16 +347,16 @@ void IntervalTree::deleteNode(SimpleInterval* ivl) { //============================================================================== IntervalTreeNode* IntervalTree::recursiveSearch(IntervalTreeNode* node, SimpleInterval* ivl) const { - if (node != nil) { + if (node != invalid_node) { if (node->stored_interval == ivl) return node; IntervalTreeNode* left = recursiveSearch(node->left, ivl); - if (left != nil) return left; + if (left != invalid_node) return left; IntervalTreeNode* right = recursiveSearch(node->right, ivl); - if (right != nil) return right; + if (right != invalid_node) return right; } - return nil; + return invalid_node; } //============================================================================== @@ -364,8 +365,10 @@ SimpleInterval* IntervalTree::deleteNode(IntervalTreeNode* z) { IntervalTreeNode* x; SimpleInterval* node_to_delete = z->stored_interval; - y = ((z->left == nil) || (z->right == nil)) ? z : getSuccessor(z); - x = (y->left == nil) ? y->right : y->left; + y = ((z->left == invalid_node) || (z->right == invalid_node)) + ? z + : getSuccessor(z); + x = (y->left == invalid_node) ? y->right : y->left; if (root == (x->parent = y->parent)) { root->left = x; } else { @@ -376,7 +379,7 @@ SimpleInterval* IntervalTree::deleteNode(IntervalTreeNode* z) { } } - /// @brief y should not be nil in this case + /// @brief y should not be invalid_node in this case /// y is the node to splice out and x is its child if (y != z) { y->max_high = -(std::numeric_limits::max)(); @@ -419,7 +422,7 @@ bool overlap(FCL_REAL a1, FCL_REAL a2, FCL_REAL b1, FCL_REAL b2) { std::deque IntervalTree::query(FCL_REAL low, FCL_REAL high) { std::deque result_stack; IntervalTreeNode* x = root->left; - bool run = (x != nil); + bool run = (x != invalid_node); current_parent = 0; @@ -445,14 +448,14 @@ std::deque IntervalTree::query(FCL_REAL low, FCL_REAL high) { } else x = x->right; - run = (x != nil); + run = (x != invalid_node); while ((!run) && (recursion_node_stack_top > 1)) { if (recursion_node_stack[--recursion_node_stack_top].try_right_branch) { x = recursion_node_stack[recursion_node_stack_top].start_node->right; current_parent = recursion_node_stack[recursion_node_stack_top].parent_index; recursion_node_stack[current_parent].try_right_branch = true; - run = (x != nil); + run = (x != invalid_node); } } } diff --git a/src/broadphase/detail/interval_tree_node.cpp b/src/broadphase/detail/interval_tree_node.cpp index b9771ae18..beb9e28d6 100644 --- a/src/broadphase/detail/interval_tree_node.cpp +++ b/src/broadphase/detail/interval_tree_node.cpp @@ -67,17 +67,17 @@ IntervalTreeNode::~IntervalTreeNode() { } //============================================================================== -void IntervalTreeNode::print(IntervalTreeNode* nil, +void IntervalTreeNode::print(IntervalTreeNode* invalid_node, IntervalTreeNode* root) const { stored_interval->print(); std::cout << ", k = " << key << ", h = " << high << ", mH = " << max_high; std::cout << " l->key = "; - if (left == nil) + if (left == invalid_node) std::cout << "nullptr"; else std::cout << left->key; std::cout << " r->key = "; - if (right == nil) + if (right == invalid_node) std::cout << "nullptr"; else std::cout << right->key;