Skip to content

Commit

Permalink
Merge pull request #517 from jamiesnape/upstream-debian-patches
Browse files Browse the repository at this point in the history
Upstream patches applied during Debian packaging of 0.6.1
  • Loading branch information
sherm1 authored Dec 31, 2020
2 parents da07e5b + c3ed3f6 commit b2a749f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 22 deletions.
16 changes: 9 additions & 7 deletions include/fcl/broadphase/detail/hierarchy_tree_array-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@

#include "fcl/common/unused.h"

#include <algorithm>

namespace fcl
{

Expand Down Expand Up @@ -109,7 +111,7 @@ void HierarchyTree<BV>::init_0(NodeType* leaves, int n_leaves_)
n_leaves = n_leaves_;
root_node = NULL_NODE;
nodes = new NodeType[n_leaves * 2];
memcpy(nodes, leaves, sizeof(NodeType) * n_leaves);
std::copy(leaves, leaves + n_leaves, nodes);
freelist = n_leaves;
n_nodes = n_leaves;
n_nodes_alloc = 2 * n_leaves;
Expand Down Expand Up @@ -137,7 +139,7 @@ void HierarchyTree<BV>::init_1(NodeType* leaves, int n_leaves_)
n_leaves = n_leaves_;
root_node = NULL_NODE;
nodes = new NodeType[n_leaves * 2];
memcpy(nodes, leaves, sizeof(NodeType) * n_leaves);
std::copy(leaves, leaves + n_leaves, nodes);
freelist = n_leaves;
n_nodes = n_leaves;
n_nodes_alloc = 2 * n_leaves;
Expand Down Expand Up @@ -181,7 +183,7 @@ void HierarchyTree<BV>::init_2(NodeType* leaves, int n_leaves_)
n_leaves = n_leaves_;
root_node = NULL_NODE;
nodes = new NodeType[n_leaves * 2];
memcpy(nodes, leaves, sizeof(NodeType) * n_leaves);
std::copy(leaves, leaves + n_leaves, nodes);
freelist = n_leaves;
n_nodes = n_leaves;
n_nodes_alloc = 2 * n_leaves;
Expand Down Expand Up @@ -225,7 +227,7 @@ void HierarchyTree<BV>::init_3(NodeType* leaves, int n_leaves_)
n_leaves = n_leaves_;
root_node = NULL_NODE;
nodes = new NodeType[n_leaves * 2];
memcpy(nodes, leaves, sizeof(NodeType) * n_leaves);
std::copy(leaves, leaves + n_leaves, nodes);
freelist = n_leaves;
n_nodes = n_leaves;
n_nodes_alloc = 2 * n_leaves;
Expand Down Expand Up @@ -385,7 +387,7 @@ void HierarchyTree<BV>::balanceBottomup()
NodeType* leaves_ = leaves;
extractLeaves(root_node, leaves_);
root_node = NULL_NODE;
memcpy(nodes, leaves, sizeof(NodeType) * n_leaves);
std::copy(leaves, leaves + n_leaves, nodes);
freelist = n_leaves;
n_nodes = n_leaves;
for(size_t i = n_leaves; i < n_nodes_alloc; ++i)
Expand Down Expand Up @@ -414,7 +416,7 @@ void HierarchyTree<BV>::balanceTopdown()
NodeType* leaves_ = leaves;
extractLeaves(root_node, leaves_);
root_node = NULL_NODE;
memcpy(nodes, leaves, sizeof(NodeType) * n_leaves);
std::copy(leaves, leaves + n_leaves, nodes);
freelist = n_leaves;
n_nodes = n_leaves;
for(size_t i = n_leaves; i < n_nodes_alloc; ++i)
Expand Down Expand Up @@ -946,7 +948,7 @@ size_t HierarchyTree<BV>::allocateNode()
NodeType* old_nodes = nodes;
n_nodes_alloc *= 2;
nodes = new NodeType[n_nodes_alloc];
memcpy(nodes, old_nodes, n_nodes * sizeof(NodeType));
std::copy(old_nodes, old_nodes + n_nodes, nodes);
delete [] old_nodes;

for(size_t i = n_nodes; i < n_nodes_alloc - 1; ++i)
Expand Down
2 changes: 1 addition & 1 deletion include/fcl/broadphase/detail/interval_tree-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ std::deque<SimpleInterval<S>*> IntervalTree<S>::query(S low, S high)
recursion_node_stack_size *= 2;
recursion_node_stack = (it_recursion_node<S> *)realloc(recursion_node_stack, recursion_node_stack_size * sizeof(it_recursion_node<S>));
if(recursion_node_stack == nullptr)
exit(1);
abort();
}
recursion_node_stack[recursion_node_stack_top].start_node = x;
recursion_node_stack[recursion_node_stack_top].try_right_branch = false;
Expand Down
27 changes: 14 additions & 13 deletions include/fcl/geometry/bvh/BVH_model-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

#include "fcl/geometry/bvh/BVH_model.h"
#include <new>
#include <algorithm>

namespace fcl
{
Expand Down Expand Up @@ -92,23 +93,23 @@ BVHModel<BV>::BVHModel(const BVHModel<BV>& other)
if(other.vertices)
{
vertices = new Vector3<S>[num_vertices];
memcpy(vertices, other.vertices, sizeof(Vector3<S>) * num_vertices);
std::copy(other.vertices, other.vertices + num_vertices, vertices);
}
else
vertices = nullptr;

if(other.tri_indices)
{
tri_indices = new Triangle[num_tris];
memcpy(tri_indices, other.tri_indices, sizeof(Triangle) * num_tris);
std::copy(other.tri_indices, other.tri_indices + num_tris, tri_indices);
}
else
tri_indices = nullptr;

if(other.prev_vertices)
{
prev_vertices = new Vector3<S>[num_vertices];
memcpy(prev_vertices, other.prev_vertices, sizeof(Vector3<S>) * num_vertices);
std::copy(other.prev_vertices, other.prev_vertices + num_vertices, prev_vertices);
}
else
prev_vertices = nullptr;
Expand All @@ -129,7 +130,7 @@ BVHModel<BV>::BVHModel(const BVHModel<BV>& other)
}

primitive_indices = new unsigned int[num_primitives];
memcpy(primitive_indices, other.primitive_indices, sizeof(unsigned int) * num_primitives);
std::copy(other.primitive_indices, other.primitive_indices + num_primitives, primitive_indices);
}
else
primitive_indices = nullptr;
Expand All @@ -138,7 +139,7 @@ BVHModel<BV>::BVHModel(const BVHModel<BV>& other)
if(other.bvs)
{
bvs = new BVNode<BV>[num_bvs];
memcpy(bvs, other.bvs, sizeof(BVNode<BV>) * num_bvs);
std::copy(other.bvs, other.bvs + num_bvs, bvs);
}
else
bvs = nullptr;
Expand Down Expand Up @@ -270,7 +271,7 @@ int BVHModel<BV>::addVertex(const Vector3<S>& p)
return BVH_ERR_MODEL_OUT_OF_MEMORY;
}

memcpy(temp, vertices, sizeof(Vector3<S>) * num_vertices);
std::copy(vertices, vertices + num_vertices, temp);
delete [] vertices;
vertices = temp;
num_vertices_allocated *= 2;
Expand Down Expand Up @@ -301,7 +302,7 @@ int BVHModel<BV>::addTriangle(const Vector3<S>& p1, const Vector3<S>& p2, const
return BVH_ERR_MODEL_OUT_OF_MEMORY;
}

memcpy(temp, vertices, sizeof(Vector3<S>) * num_vertices);
std::copy(vertices, vertices + num_vertices, temp);
delete [] vertices;
vertices = temp;
num_vertices_allocated = num_vertices_allocated * 2 + 2;
Expand Down Expand Up @@ -329,7 +330,7 @@ int BVHModel<BV>::addTriangle(const Vector3<S>& p1, const Vector3<S>& p2, const
return BVH_ERR_MODEL_OUT_OF_MEMORY;
}

memcpy(temp, tri_indices, sizeof(Triangle) * num_tris);
std::copy(tri_indices, tri_indices + num_tris, temp);
delete [] tri_indices;
tri_indices = temp;
num_tris_allocated *= 2;
Expand Down Expand Up @@ -362,7 +363,7 @@ int BVHModel<BV>::addSubModel(const std::vector<Vector3<S>>& ps)
return BVH_ERR_MODEL_OUT_OF_MEMORY;
}

memcpy(temp, vertices, sizeof(Vector3<S>) * num_vertices);
std::copy(vertices, vertices + num_vertices, temp);
delete [] vertices;
vertices = temp;
num_vertices_allocated = num_vertices_allocated * 2 + num_vertices_to_add - 1;
Expand Down Expand Up @@ -398,7 +399,7 @@ int BVHModel<BV>::addSubModel(const std::vector<Vector3<S>>& ps, const std::vect
return BVH_ERR_MODEL_OUT_OF_MEMORY;
}

memcpy(temp, vertices, sizeof(Vector3<S>) * num_vertices);
std::copy(vertices, vertices + num_vertices, temp);
delete [] vertices;
vertices = temp;
num_vertices_allocated = num_vertices_allocated * 2 + num_vertices_to_add - 1;
Expand Down Expand Up @@ -428,7 +429,7 @@ int BVHModel<BV>::addSubModel(const std::vector<Vector3<S>>& ps, const std::vect
return BVH_ERR_MODEL_OUT_OF_MEMORY;
}

memcpy(temp, tri_indices, sizeof(Triangle) * num_tris);
std::copy(tri_indices, tri_indices + num_tris, temp);
delete [] tri_indices;
tri_indices = temp;
num_tris_allocated = num_tris_allocated * 2 + num_tris_to_add - 1;
Expand Down Expand Up @@ -468,7 +469,7 @@ int BVHModel<BV>::endModel()
std::cerr << "BVH Error! Out of memory for tri_indices array in endModel() call!" << std::endl;
return BVH_ERR_MODEL_OUT_OF_MEMORY;
}
memcpy(new_tris, tri_indices, sizeof(Triangle) * num_tris);
std::copy(tri_indices, tri_indices + num_tris, new_tris);
delete [] tri_indices;
tri_indices = new_tris;
num_tris_allocated = num_tris;
Expand All @@ -482,7 +483,7 @@ int BVHModel<BV>::endModel()
std::cerr << "BVH Error! Out of memory for vertices array in endModel() call!" << std::endl;
return BVH_ERR_MODEL_OUT_OF_MEMORY;
}
memcpy(new_vertices, vertices, sizeof(Vector3<S>) * num_vertices);
std::copy(vertices, vertices + num_vertices, new_vertices);
delete [] vertices;
vertices = new_vertices;
num_vertices_allocated = num_vertices;
Expand Down
2 changes: 1 addition & 1 deletion include/fcl/narrowphase/detail/gjk_solver_indep.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ struct FCL_EXPORT GJKSolver_indep
<< "\n epa max face num: " << solver.epa_max_face_num
<< "\n epa max vertex num: " << solver.epa_max_vertex_num
<< "\n epa max iterations: " << solver.epa_max_iterations
<< "\n enable cahced guess: " << solver.enable_cached_guess;
<< "\n enable cached guess: " << solver.enable_cached_guess;
if (solver.enable_cached_guess) out << solver.cached_guess.transpose();
return out;
}
Expand Down

0 comments on commit b2a749f

Please sign in to comment.