Skip to content

Commit b2a749f

Browse files
authored
Merge pull request #517 from jamiesnape/upstream-debian-patches
Upstream patches applied during Debian packaging of 0.6.1
2 parents da07e5b + c3ed3f6 commit b2a749f

File tree

4 files changed

+25
-22
lines changed

4 files changed

+25
-22
lines changed

include/fcl/broadphase/detail/hierarchy_tree_array-inl.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242

4343
#include "fcl/common/unused.h"
4444

45+
#include <algorithm>
46+
4547
namespace fcl
4648
{
4749

@@ -109,7 +111,7 @@ void HierarchyTree<BV>::init_0(NodeType* leaves, int n_leaves_)
109111
n_leaves = n_leaves_;
110112
root_node = NULL_NODE;
111113
nodes = new NodeType[n_leaves * 2];
112-
memcpy(nodes, leaves, sizeof(NodeType) * n_leaves);
114+
std::copy(leaves, leaves + n_leaves, nodes);
113115
freelist = n_leaves;
114116
n_nodes = n_leaves;
115117
n_nodes_alloc = 2 * n_leaves;
@@ -137,7 +139,7 @@ void HierarchyTree<BV>::init_1(NodeType* leaves, int n_leaves_)
137139
n_leaves = n_leaves_;
138140
root_node = NULL_NODE;
139141
nodes = new NodeType[n_leaves * 2];
140-
memcpy(nodes, leaves, sizeof(NodeType) * n_leaves);
142+
std::copy(leaves, leaves + n_leaves, nodes);
141143
freelist = n_leaves;
142144
n_nodes = n_leaves;
143145
n_nodes_alloc = 2 * n_leaves;
@@ -181,7 +183,7 @@ void HierarchyTree<BV>::init_2(NodeType* leaves, int n_leaves_)
181183
n_leaves = n_leaves_;
182184
root_node = NULL_NODE;
183185
nodes = new NodeType[n_leaves * 2];
184-
memcpy(nodes, leaves, sizeof(NodeType) * n_leaves);
186+
std::copy(leaves, leaves + n_leaves, nodes);
185187
freelist = n_leaves;
186188
n_nodes = n_leaves;
187189
n_nodes_alloc = 2 * n_leaves;
@@ -225,7 +227,7 @@ void HierarchyTree<BV>::init_3(NodeType* leaves, int n_leaves_)
225227
n_leaves = n_leaves_;
226228
root_node = NULL_NODE;
227229
nodes = new NodeType[n_leaves * 2];
228-
memcpy(nodes, leaves, sizeof(NodeType) * n_leaves);
230+
std::copy(leaves, leaves + n_leaves, nodes);
229231
freelist = n_leaves;
230232
n_nodes = n_leaves;
231233
n_nodes_alloc = 2 * n_leaves;
@@ -385,7 +387,7 @@ void HierarchyTree<BV>::balanceBottomup()
385387
NodeType* leaves_ = leaves;
386388
extractLeaves(root_node, leaves_);
387389
root_node = NULL_NODE;
388-
memcpy(nodes, leaves, sizeof(NodeType) * n_leaves);
390+
std::copy(leaves, leaves + n_leaves, nodes);
389391
freelist = n_leaves;
390392
n_nodes = n_leaves;
391393
for(size_t i = n_leaves; i < n_nodes_alloc; ++i)
@@ -414,7 +416,7 @@ void HierarchyTree<BV>::balanceTopdown()
414416
NodeType* leaves_ = leaves;
415417
extractLeaves(root_node, leaves_);
416418
root_node = NULL_NODE;
417-
memcpy(nodes, leaves, sizeof(NodeType) * n_leaves);
419+
std::copy(leaves, leaves + n_leaves, nodes);
418420
freelist = n_leaves;
419421
n_nodes = n_leaves;
420422
for(size_t i = n_leaves; i < n_nodes_alloc; ++i)
@@ -946,7 +948,7 @@ size_t HierarchyTree<BV>::allocateNode()
946948
NodeType* old_nodes = nodes;
947949
n_nodes_alloc *= 2;
948950
nodes = new NodeType[n_nodes_alloc];
949-
memcpy(nodes, old_nodes, n_nodes * sizeof(NodeType));
951+
std::copy(old_nodes, old_nodes + n_nodes, nodes);
950952
delete [] old_nodes;
951953

952954
for(size_t i = n_nodes; i < n_nodes_alloc - 1; ++i)

include/fcl/broadphase/detail/interval_tree-inl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ std::deque<SimpleInterval<S>*> IntervalTree<S>::query(S low, S high)
531531
recursion_node_stack_size *= 2;
532532
recursion_node_stack = (it_recursion_node<S> *)realloc(recursion_node_stack, recursion_node_stack_size * sizeof(it_recursion_node<S>));
533533
if(recursion_node_stack == nullptr)
534-
exit(1);
534+
abort();
535535
}
536536
recursion_node_stack[recursion_node_stack_top].start_node = x;
537537
recursion_node_stack[recursion_node_stack_top].try_right_branch = false;

include/fcl/geometry/bvh/BVH_model-inl.h

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
#include "fcl/geometry/bvh/BVH_model.h"
4242
#include <new>
43+
#include <algorithm>
4344

4445
namespace fcl
4546
{
@@ -92,23 +93,23 @@ BVHModel<BV>::BVHModel(const BVHModel<BV>& other)
9293
if(other.vertices)
9394
{
9495
vertices = new Vector3<S>[num_vertices];
95-
memcpy(vertices, other.vertices, sizeof(Vector3<S>) * num_vertices);
96+
std::copy(other.vertices, other.vertices + num_vertices, vertices);
9697
}
9798
else
9899
vertices = nullptr;
99100

100101
if(other.tri_indices)
101102
{
102103
tri_indices = new Triangle[num_tris];
103-
memcpy(tri_indices, other.tri_indices, sizeof(Triangle) * num_tris);
104+
std::copy(other.tri_indices, other.tri_indices + num_tris, tri_indices);
104105
}
105106
else
106107
tri_indices = nullptr;
107108

108109
if(other.prev_vertices)
109110
{
110111
prev_vertices = new Vector3<S>[num_vertices];
111-
memcpy(prev_vertices, other.prev_vertices, sizeof(Vector3<S>) * num_vertices);
112+
std::copy(other.prev_vertices, other.prev_vertices + num_vertices, prev_vertices);
112113
}
113114
else
114115
prev_vertices = nullptr;
@@ -129,7 +130,7 @@ BVHModel<BV>::BVHModel(const BVHModel<BV>& other)
129130
}
130131

131132
primitive_indices = new unsigned int[num_primitives];
132-
memcpy(primitive_indices, other.primitive_indices, sizeof(unsigned int) * num_primitives);
133+
std::copy(other.primitive_indices, other.primitive_indices + num_primitives, primitive_indices);
133134
}
134135
else
135136
primitive_indices = nullptr;
@@ -138,7 +139,7 @@ BVHModel<BV>::BVHModel(const BVHModel<BV>& other)
138139
if(other.bvs)
139140
{
140141
bvs = new BVNode<BV>[num_bvs];
141-
memcpy(bvs, other.bvs, sizeof(BVNode<BV>) * num_bvs);
142+
std::copy(other.bvs, other.bvs + num_bvs, bvs);
142143
}
143144
else
144145
bvs = nullptr;
@@ -270,7 +271,7 @@ int BVHModel<BV>::addVertex(const Vector3<S>& p)
270271
return BVH_ERR_MODEL_OUT_OF_MEMORY;
271272
}
272273

273-
memcpy(temp, vertices, sizeof(Vector3<S>) * num_vertices);
274+
std::copy(vertices, vertices + num_vertices, temp);
274275
delete [] vertices;
275276
vertices = temp;
276277
num_vertices_allocated *= 2;
@@ -301,7 +302,7 @@ int BVHModel<BV>::addTriangle(const Vector3<S>& p1, const Vector3<S>& p2, const
301302
return BVH_ERR_MODEL_OUT_OF_MEMORY;
302303
}
303304

304-
memcpy(temp, vertices, sizeof(Vector3<S>) * num_vertices);
305+
std::copy(vertices, vertices + num_vertices, temp);
305306
delete [] vertices;
306307
vertices = temp;
307308
num_vertices_allocated = num_vertices_allocated * 2 + 2;
@@ -329,7 +330,7 @@ int BVHModel<BV>::addTriangle(const Vector3<S>& p1, const Vector3<S>& p2, const
329330
return BVH_ERR_MODEL_OUT_OF_MEMORY;
330331
}
331332

332-
memcpy(temp, tri_indices, sizeof(Triangle) * num_tris);
333+
std::copy(tri_indices, tri_indices + num_tris, temp);
333334
delete [] tri_indices;
334335
tri_indices = temp;
335336
num_tris_allocated *= 2;
@@ -362,7 +363,7 @@ int BVHModel<BV>::addSubModel(const std::vector<Vector3<S>>& ps)
362363
return BVH_ERR_MODEL_OUT_OF_MEMORY;
363364
}
364365

365-
memcpy(temp, vertices, sizeof(Vector3<S>) * num_vertices);
366+
std::copy(vertices, vertices + num_vertices, temp);
366367
delete [] vertices;
367368
vertices = temp;
368369
num_vertices_allocated = num_vertices_allocated * 2 + num_vertices_to_add - 1;
@@ -398,7 +399,7 @@ int BVHModel<BV>::addSubModel(const std::vector<Vector3<S>>& ps, const std::vect
398399
return BVH_ERR_MODEL_OUT_OF_MEMORY;
399400
}
400401

401-
memcpy(temp, vertices, sizeof(Vector3<S>) * num_vertices);
402+
std::copy(vertices, vertices + num_vertices, temp);
402403
delete [] vertices;
403404
vertices = temp;
404405
num_vertices_allocated = num_vertices_allocated * 2 + num_vertices_to_add - 1;
@@ -428,7 +429,7 @@ int BVHModel<BV>::addSubModel(const std::vector<Vector3<S>>& ps, const std::vect
428429
return BVH_ERR_MODEL_OUT_OF_MEMORY;
429430
}
430431

431-
memcpy(temp, tri_indices, sizeof(Triangle) * num_tris);
432+
std::copy(tri_indices, tri_indices + num_tris, temp);
432433
delete [] tri_indices;
433434
tri_indices = temp;
434435
num_tris_allocated = num_tris_allocated * 2 + num_tris_to_add - 1;
@@ -468,7 +469,7 @@ int BVHModel<BV>::endModel()
468469
std::cerr << "BVH Error! Out of memory for tri_indices array in endModel() call!" << std::endl;
469470
return BVH_ERR_MODEL_OUT_OF_MEMORY;
470471
}
471-
memcpy(new_tris, tri_indices, sizeof(Triangle) * num_tris);
472+
std::copy(tri_indices, tri_indices + num_tris, new_tris);
472473
delete [] tri_indices;
473474
tri_indices = new_tris;
474475
num_tris_allocated = num_tris;
@@ -482,7 +483,7 @@ int BVHModel<BV>::endModel()
482483
std::cerr << "BVH Error! Out of memory for vertices array in endModel() call!" << std::endl;
483484
return BVH_ERR_MODEL_OUT_OF_MEMORY;
484485
}
485-
memcpy(new_vertices, vertices, sizeof(Vector3<S>) * num_vertices);
486+
std::copy(vertices, vertices + num_vertices, new_vertices);
486487
delete [] vertices;
487488
vertices = new_vertices;
488489
num_vertices_allocated = num_vertices;

include/fcl/narrowphase/detail/gjk_solver_indep.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ struct FCL_EXPORT GJKSolver_indep
191191
<< "\n epa max face num: " << solver.epa_max_face_num
192192
<< "\n epa max vertex num: " << solver.epa_max_vertex_num
193193
<< "\n epa max iterations: " << solver.epa_max_iterations
194-
<< "\n enable cahced guess: " << solver.enable_cached_guess;
194+
<< "\n enable cached guess: " << solver.enable_cached_guess;
195195
if (solver.enable_cached_guess) out << solver.cached_guess.transpose();
196196
return out;
197197
}

0 commit comments

Comments
 (0)