Unverified Commit 2fe8311b authored by Justin Carpentier's avatar Justin Carpentier Committed by GitHub
Browse files

Merge pull request #249 from jcarpent/devel

Remove warnings and add missing noalias
parents ea9afdc2 1d1fb1d5
Pipeline #16895 passed with stage
in 66 minutes and 4 seconds
......@@ -78,10 +78,9 @@ public:
{
const Vec3f& center = bv1.center();
FCL_REAL r = (bv1.max_ - bv1.min_).norm() * 0.5;
Vec3f center2 = tf1.transform(center);
Vec3f delta(r, r, r);
bv2.min_ = center2 - delta;
bv2.max_ = center2 + delta;
const Vec3f center2 = tf1.transform(center);
bv2.min_ = center2 - Vec3f::Constant(r);
bv2.max_ = center2 + Vec3f::Constant(r);
}
};
......@@ -91,9 +90,9 @@ class Converter<AABB, OBB>
public:
static void convert(const AABB& bv1, const Transform3f& tf1, OBB& bv2)
{
bv2.To.noalias() = tf1.transform(bv1.center());
bv2.To = tf1.transform(bv1.center());
bv2.extent.noalias() = (bv1.max_ - bv1.min_) * 0.5;
bv2.axes.noalias() = tf1.getRotation();
bv2.axes = tf1.getRotation();
}
};
......@@ -103,8 +102,8 @@ class Converter<OBB, OBB>
public:
static void convert(const OBB& bv1, const Transform3f& tf1, OBB& bv2)
{
bv2.extent.noalias() = bv1.extent;
bv2.To.noalias() = tf1.transform(bv1.To);
bv2.extent = bv1.extent;
bv2.To = tf1.transform(bv1.To);
bv2.axes.noalias() = tf1.getRotation() * bv1.axes;
}
};
......@@ -125,8 +124,8 @@ class Converter<RSS, OBB>
public:
static void convert(const RSS& bv1, const Transform3f& tf1, OBB& bv2)
{
bv2.extent.noalias() = Vec3f(bv1.length[0] * 0.5 + bv1.radius, bv1.length[1] * 0.5 + bv1.radius, bv1.radius);
bv2.To.noalias() = tf1.transform(bv1.Tr);
bv2.extent = Vec3f(bv1.length[0] * 0.5 + bv1.radius, bv1.length[1] * 0.5 + bv1.radius, bv1.radius);
bv2.To = tf1.transform(bv1.Tr);
bv2.axes.noalias() = tf1.getRotation() * bv1.axes;
}
};
......@@ -140,10 +139,9 @@ public:
{
const Vec3f& center = bv1.center();
FCL_REAL r = Vec3f(bv1.width(), bv1.height(), bv1.depth()).norm() * 0.5;
Vec3f delta(r, r, r);
Vec3f center2 = tf1.transform(center);
bv2.min_ = center2 - delta;
bv2.max_ = center2 + delta;
const Vec3f center2 = tf1.transform(center);
bv2.min_ = center2 - Vec3f::Constant(r);
bv2.max_ = center2 + Vec3f::Constant(r);
}
};
......@@ -180,7 +178,7 @@ class Converter<RSS, RSS>
public:
static void convert(const RSS& bv1, const Transform3f& tf1, RSS& bv2)
{
bv2.Tr.noalias() = tf1.transform(bv1.Tr);
bv2.Tr = tf1.transform(bv1.Tr);
bv2.axes.noalias() = tf1.getRotation() * bv1.axes;
bv2.radius = bv1.radius;
......@@ -209,11 +207,11 @@ public:
/// Sort the AABB edges so that AABB extents are ordered.
FCL_REAL d[3] = {bv1.width(), bv1.height(), bv1.depth() };
std::size_t id[3] = {0, 1, 2};
Eigen::DenseIndex id[3] = {0, 1, 2};
for(std::size_t i = 1; i < 3; ++i)
for(Eigen::DenseIndex i = 1; i < 3; ++i)
{
for(std::size_t j = i; j > 0; --j)
for(Eigen::DenseIndex j = i; j > 0; --j)
{
if(d[j] > d[j-1])
{
......@@ -223,7 +221,7 @@ public:
d[j-1] = tmp;
}
{
std::size_t tmp = id[j];
Eigen::DenseIndex tmp = id[j];
id[j] = id[j-1];
id[j-1] = tmp;
}
......@@ -231,17 +229,17 @@ public:
}
}
Vec3f extent = (bv1.max_ - bv1.min_) * 0.5;
const Vec3f extent = (bv1.max_ - bv1.min_) * 0.5;
bv2.radius = extent[id[2]];
bv2.length[0] = (extent[id[0]] - bv2.radius) * 2;
bv2.length[1] = (extent[id[1]] - bv2.radius) * 2;
const Matrix3f& R = tf1.getRotation();
bool left_hand = (id[0] == (id[1] + 1) % 3);
if (left_hand) bv2.axes.col(0).noalias() = -R.col(id[0]);
else bv2.axes.col(0).noalias() = R.col(id[0]);
bv2.axes.col(1).noalias() = R.col(id[1]);
bv2.axes.col(2).noalias() = R.col(id[2]);
const bool left_hand = (id[0] == (id[1] + 1) % 3);
if (left_hand) bv2.axes.col(0) = -R.col(id[0]);
else bv2.axes.col(0) = R.col(id[0]);
bv2.axes.col(1) = R.col(id[1]);
bv2.axes.col(2) = R.col(id[2]);
}
};
......
......@@ -64,16 +64,16 @@ struct HPP_FCL_DLLAPI BVNodeBase
/// @brief The start id the primitive belonging to the current node. The index is referred to the primitive_indices in BVHModel and from that
/// we can obtain the primitive's index in original data indirectly.
int first_primitive;
unsigned int first_primitive;
/// @brief The number of primitives belonging to the current node
int num_primitives;
unsigned int num_primitives;
/// @brief Default constructor
BVNodeBase()
: first_child(0)
, first_primitive(-1)
, num_primitives(-1)
, first_primitive((std::numeric_limits<unsigned int>::max)()) // value we should help to raise an issue
, num_primitives(0)
{}
/// @brief Equality operator
......
......@@ -55,14 +55,15 @@ namespace fcl
struct HPP_FCL_DLLAPI BVHFrontNode
{
/// @brief The nodes to start in the future, i.e. the wave front of the traversal tree.
int left, right;
unsigned int left, right;
/// @brief The front node is not valid when collision is detected on the front node.
bool valid;
BVHFrontNode(int left_, int right_) : left(left_),
right(right_),
valid(true)
BVHFrontNode(unsigned int left_, unsigned int right_)
: left(left_)
, right(right_)
, valid(true)
{
}
};
......@@ -71,7 +72,7 @@ struct HPP_FCL_DLLAPI BVHFrontNode
typedef std::list<BVHFrontNode> BVHFrontList;
/// @brief Add new front node into the front list
inline void updateFrontList(BVHFrontList* front_list, int b1, int b2)
inline void updateFrontList(BVHFrontList* front_list, unsigned int b1, unsigned int b2)
{
if(front_list) front_list->push_back(BVHFrontNode(b1, b2));
}
......
......@@ -74,10 +74,10 @@ public:
Vec3f* prev_vertices;
/// @brief Number of triangles
int num_tris;
unsigned int num_tris;
/// @brief Number of points
int num_vertices;
unsigned int num_vertices;
/// @brief The state of BVH building process
BVHBuildState build_state;
......@@ -126,7 +126,7 @@ public:
void computeLocalAABB();
/// @brief Begin a new BVH model
int beginModel(int num_tris = 0, int num_vertices = 0);
int beginModel(unsigned int num_tris = 0, unsigned int num_vertices = 0);
/// @brief Add one point in the new BVH model
int addVertex(const Vec3f& p);
......@@ -209,7 +209,7 @@ public:
{
FCL_REAL vol = 0;
Vec3f com(0,0,0);
for(int i = 0; i < num_tris; ++i)
for(unsigned int i = 0; i < num_tris; ++i)
{
const Triangle& tri = tri_indices[i];
FCL_REAL d_six_vol = (vertices[tri[0]].cross(vertices[tri[1]])).dot(vertices[tri[2]]);
......@@ -223,7 +223,7 @@ public:
FCL_REAL computeVolume() const
{
FCL_REAL vol = 0;
for(int i = 0; i < num_tris; ++i)
for(unsigned int i = 0; i < num_tris; ++i)
{
const Triangle& tri = tri_indices[i];
FCL_REAL d_six_vol = (vertices[tri[0]].cross(vertices[tri[1]])).dot(vertices[tri[2]]);
......@@ -242,7 +242,7 @@ public:
1/120.0, 1/60.0, 1/120.0,
1/120.0, 1/120.0, 1/60.0;
for(int i = 0; i < num_tris; ++i)
for(unsigned int i = 0; i < num_tris; ++i)
{
const Triangle& tri = tri_indices[i];
const Vec3f& v1 = vertices[tri[0]];
......@@ -265,9 +265,9 @@ protected:
/// @brief Refit the bounding volume hierarchy
virtual int refitTree(bool bottomup) = 0;
int num_tris_allocated;
int num_vertices_allocated;
int num_vertex_updated; /// for ccd vertex update
unsigned int num_tris_allocated;
unsigned int num_vertices_allocated;
unsigned int num_vertex_updated; /// for ccd vertex update
};
/// @brief A class describing the bounding hierarchy of a mesh model or a point cloud model (which is viewed as a degraded version of mesh)
......@@ -307,7 +307,7 @@ public:
if(!res)
return false;
int other_num_primitives = 0;
unsigned int other_num_primitives = 0;
if(other.primitive_indices)
{
......@@ -324,7 +324,7 @@ public:
}
}
// int num_primitives = 0;
// unsigned int num_primitives = 0;
// if(primitive_indices)
// {
//
......@@ -353,7 +353,7 @@ public:
if(num_bvs != other.num_bvs)
return false;
for(int k = 0; k < num_bvs; ++k)
for(unsigned int k = 0; k < num_bvs; ++k)
{
if(bvs[k] != other.bvs[k])
return false;
......@@ -371,21 +371,21 @@ public:
/// @brief We provide getBV() and getNumBVs() because BVH may be compressed (in future), so we must provide some flexibility here
/// @brief Access the bv giving the its index
const BVNode<BV>& getBV(int id) const
const BVNode<BV>& getBV(unsigned int i) const
{
assert (id < num_bvs);
return bvs[id];
assert (i < num_bvs);
return bvs[i];
}
/// @brief Access the bv giving the its index
BVNode<BV>& getBV(int id)
BVNode<BV>& getBV(unsigned int i)
{
assert (id < num_bvs);
return bvs[id];
assert (i < num_bvs);
return bvs[i];
}
/// @brief Get the number of bv in the BVH
int getNumBVs() const
unsigned int getNumBVs() const
{
return num_bvs;
}
......@@ -408,14 +408,14 @@ protected:
void deleteBVs();
bool allocateBVs();
int num_bvs_allocated;
unsigned int num_bvs_allocated;
unsigned int* primitive_indices;
/// @brief Bounding volume hierarchy
BVNode<BV>* bvs;
/// @brief Number of BV nodes in bounding volume hierarchy
int num_bvs;
unsigned int num_bvs;
/// @brief Build the bounding volume hierarchy
int buildTree();
......@@ -430,7 +430,7 @@ protected:
int refitTree_bottomup();
/// @brief Recursive kernel for hierarchy construction
int recursiveBuildTree(int bv_id, int first_primitive, int num_primitives);
int recursiveBuildTree(int bv_id, unsigned int first_primitive, unsigned int num_primitives);
/// @brief Recursive kernel for bottomup refitting
int recursiveRefitTree_bottomup(int bv_id);
......
......@@ -48,6 +48,8 @@
#define HPP_FCL_PRETTY_FUNCTION __PRETTY_FUNCTION__
#endif
#define HPP_FCL_UNUSED_VARIABLE(var) (void)(var)
#define HPP_FCL_THROW_PRETTY(message,exception) \
{ \
std::stringstream ss; \
......
......@@ -101,7 +101,7 @@ public:
}
/// @brief Compute the fitting BV
virtual BV fit(unsigned int* primitive_indices, int num_primitives) = 0;
virtual BV fit(unsigned int* primitive_indices, unsigned int num_primitives) = 0;
/// @brief Clear the geometry primitive data
void clear()
......@@ -128,13 +128,13 @@ class HPP_FCL_DLLAPI BVFitter : public BVFitterTpl<BV>
public:
/// @brief Compute a bounding volume that fits a set of primitives (points or triangles).
/// The primitive data was set by set function and primitive_indices is the primitive index relative to the data
BV fit(unsigned int* primitive_indices, int num_primitives)
BV fit(unsigned int* primitive_indices, unsigned int num_primitives)
{
BV bv;
if(type == BVH_MODEL_TRIANGLES) /// The primitive is triangle
{
for(int i = 0; i < num_primitives; ++i)
for(unsigned int i = 0; i < num_primitives; ++i)
{
Triangle t = tri_indices[primitive_indices[i]];
bv += vertices[t[0]];
......@@ -151,7 +151,7 @@ public:
}
else if(type == BVH_MODEL_POINTCLOUD) /// The primitive is point
{
for(int i = 0; i < num_primitives; ++i)
for(unsigned int i = 0; i < num_primitives; ++i)
{
bv += vertices[primitive_indices[i]];
......@@ -179,7 +179,7 @@ class HPP_FCL_DLLAPI BVFitter<OBB> : public BVFitterTpl<OBB>
public:
/// @brief Compute a bounding volume that fits a set of primitives (points or triangles).
/// The primitive data was set by set function and primitive_indices is the primitive index relative to the data.
OBB fit(unsigned int* primitive_indices, int num_primitives);
OBB fit(unsigned int* primitive_indices, unsigned int num_primitives);
};
/// @brief Specification of BVFitter for RSS bounding volume
......@@ -189,7 +189,7 @@ class HPP_FCL_DLLAPI BVFitter<RSS> : public BVFitterTpl<RSS>
public:
/// @brief Compute a bounding volume that fits a set of primitives (points or triangles).
/// The primitive data was set by set function and primitive_indices is the primitive index relative to the data.
RSS fit(unsigned int* primitive_indices, int num_primitives);
RSS fit(unsigned int* primitive_indices, unsigned int num_primitives);
};
/// @brief Specification of BVFitter for kIOS bounding volume
......@@ -199,7 +199,7 @@ class HPP_FCL_DLLAPI BVFitter<kIOS> : public BVFitterTpl<kIOS>
public:
/// @brief Compute a bounding volume that fits a set of primitives (points or triangles).
/// The primitive data was set by set function and primitive_indices is the primitive index relative to the data.
kIOS fit(unsigned int* primitive_indices, int num_primitives);
kIOS fit(unsigned int* primitive_indices, unsigned int num_primitives);
};
/// @brief Specification of BVFitter for OBBRSS bounding volume
......@@ -209,7 +209,7 @@ class HPP_FCL_DLLAPI BVFitter<OBBRSS> : public BVFitterTpl<OBBRSS>
public:
/// @brief Compute a bounding volume that fits a set of primitives (points or triangles).
/// The primitive data was set by set function and primitive_indices is the primitive index relative to the data.
OBBRSS fit(unsigned int* primitive_indices, int num_primitives);
OBBRSS fit(unsigned int* primitive_indices, unsigned int num_primitives);
};
/// @brief Specification of BVFitter for AABB bounding volume
......@@ -219,7 +219,7 @@ class HPP_FCL_DLLAPI BVFitter<AABB> : public BVFitterTpl<AABB>
public:
/// @brief Compute a bounding volume that fits a set of primitives (points or triangles).
/// The primitive data was set by set function and primitive_indices is the primitive index relative to the data.
AABB fit(unsigned int* primitive_indices, int num_primitives);
AABB fit(unsigned int* primitive_indices, unsigned int num_primitives);
};
}
......
......@@ -63,25 +63,25 @@ public:
virtual void postprocess() {}
/// @brief Whether b is a leaf node in the first BVH tree
virtual bool isFirstNodeLeaf(int /*b*/) const { return true; }
virtual bool isFirstNodeLeaf(unsigned int /*b*/) const { return true; }
/// @brief Whether b is a leaf node in the second BVH tree
virtual bool isSecondNodeLeaf(int /*b*/) const { return true; }
virtual bool isSecondNodeLeaf(unsigned int /*b*/) const { return true; }
/// @brief Traverse the subtree of the node in the first tree first
virtual bool firstOverSecond(int /*b1*/, int /*b2*/) const { return true; }
virtual bool firstOverSecond(unsigned int /*b1*/, unsigned int /*b2*/) const { return true; }
/// @brief Get the left child of the node b in the first tree
virtual int getFirstLeftChild(int b) const { return b; }
virtual int getFirstLeftChild(unsigned int b) const { return (int)b; }
/// @brief Get the right child of the node b in the first tree
virtual int getFirstRightChild(int b) const { return b; }
virtual int getFirstRightChild(unsigned int b) const { return (int)b; }
/// @brief Get the left child of the node b in the second tree
virtual int getSecondLeftChild(int b) const { return b; }
virtual int getSecondLeftChild(unsigned int b) const { return (int)b; }
/// @brief Get the right child of the node b in the second tree
virtual int getSecondRightChild(int b) const { return b; }
virtual int getSecondRightChild(unsigned int b) const { return (int)b; }
/// @brief Whether store some statistics information during traversal
void enableStatistics(bool enable) { enable_statistics = enable; }
......@@ -110,16 +110,16 @@ public:
virtual ~CollisionTraversalNodeBase() {}
/// @brief BV test between b1 and b2
virtual bool BVDisjoints(int b1, int b2) const = 0;
virtual bool BVDisjoints(unsigned int b1, unsigned int b2) const = 0;
/// BV test between b1 and b2
/// @param b1, b2 Bounding volumes to test,
/// @retval sqrDistLowerBound square of a lower bound of the minimal
/// distance between bounding volumes.
virtual bool BVDisjoints(int b1, int b2, FCL_REAL& sqrDistLowerBound) const = 0;
virtual bool BVDisjoints(unsigned int b1, unsigned int b2, FCL_REAL& sqrDistLowerBound) const = 0;
/// @brief Leaf test between node b1 and b2, if they are both leafs
virtual void leafCollides(int /*b1*/, int /*b2*/, FCL_REAL& /*sqrDistLowerBound*/) const = 0;
virtual void leafCollides(unsigned int /*b1*/, unsigned int /*b2*/, FCL_REAL& /*sqrDistLowerBound*/) const = 0;
/// @brief Check whether the traversal can stop
bool canStop() const { return this->request.isSatisfied(*(this->result)); }
......@@ -149,13 +149,13 @@ public:
/// @brief BV test between b1 and b2
/// @return a lower bound of the distance between the two BV.
/// @note except for OBB, this method returns the distance.
virtual FCL_REAL BVDistanceLowerBound(int /*b1*/, int /*b2*/) const
virtual FCL_REAL BVDistanceLowerBound(unsigned int /*b1*/, unsigned int /*b2*/) const
{
return (std::numeric_limits<FCL_REAL>::max)();
}
/// @brief Leaf test between node b1 and b2, if they are both leafs
virtual void leafComputeDistance(int b1, int b2) const = 0;
virtual void leafComputeDistance(unsigned int b1, unsigned int b2) const = 0;
/// @brief Check whether the traversal can stop
virtual bool canStop(FCL_REAL /*c*/) const
......
......@@ -75,19 +75,19 @@ public:
}
/// @brief Whether the BV node in the first BVH tree is leaf
bool isFirstNodeLeaf(int b) const
bool isFirstNodeLeaf(unsigned int b) const
{
return model1->getBV(b).isLeaf();
}
/// @brief Obtain the left child of BV node in the first BVH
int getFirstLeftChild(int b) const
int getFirstLeftChild(unsigned int b) const
{
return model1->getBV(b).leftChild();
}
/// @brief Obtain the right child of BV node in the first BVH
int getFirstRightChild(int b) const
int getFirstRightChild(unsigned int b) const
{
return model1->getBV(b).rightChild();
}
......@@ -118,25 +118,25 @@ public:
}
/// @brief Alway extend the second model, which is a BVH model
bool firstOverSecond(int, int) const
bool firstOverSecond(unsigned int, unsigned int) const
{
return false;
}
/// @brief Whether the BV node in the second BVH tree is leaf
bool isSecondNodeLeaf(int b) const
bool isSecondNodeLeaf(unsigned int b) const
{
return model2->getBV(b).isLeaf();
}
/// @brief Obtain the left child of BV node in the second BVH
int getSecondLeftChild(int b) const
int getSecondLeftChild(unsigned int b) const
{
return model2->getBV(b).leftChild();
}
/// @brief Obtain the right child of BV node in the second BVH
int getSecondRightChild(int b) const
int getSecondRightChild(unsigned int b) const
{
return model2->getBV(b).rightChild();
}
......@@ -172,7 +172,7 @@ public:
}
/// @brief BV culling test in one BVTT node
bool BVDisjoints(int b1, int /*b2*/) const
bool BVDisjoints(unsigned int b1, unsigned int /*b2*/) const
{
if(this->enable_statistics) this->num_bv_tests++;
if (RTIsIdentity)
......@@ -186,7 +186,7 @@ public:
/// @retval sqrDistLowerBound square of a lower bound of the minimal
/// distance between bounding volumes.
/// @brief BV culling test in one BVTT node
bool BVDisjoints(int b1, int /*b2*/, FCL_REAL& sqrDistLowerBound) const
bool BVDisjoints(unsigned int b1, unsigned int /*b2*/, FCL_REAL& sqrDistLowerBound) const
{
if(this->enable_statistics) this->num_bv_tests++;
bool res;
......@@ -201,7 +201,7 @@ public:
}
/// @brief Intersection testing between leaves (one triangle and one shape)
void leafCollides(int b1, int /*b2*/, FCL_REAL& sqrDistLowerBound) const
void leafCollides(unsigned int b1, unsigned int /*b2*/, FCL_REAL& sqrDistLowerBound) const
{
if(this->enable_statistics) this->num_leaf_tests++;
const BVNode<BV>& node = this->model1->getBV(b1);
......@@ -280,7 +280,7 @@ public:
/// BV test between b1 and b2
/// @param b2 Bounding volumes to test,
bool BVDisjoints(int /*b1*/, int b2) const
bool BVDisjoints(unsigned int /*b1*/, unsigned int b2) const
{
if(this->enable_statistics) this->num_bv_tests++;
if (RTIsIdentity)
......@@ -293,7 +293,7 @@ public:
/// @param b2 Bounding volumes to test,
/// @retval sqrDistLowerBound square of a lower bound of the minimal
/// distance between bounding volumes.
bool BVDisjoints(int /*b1*/, int b2, FCL_REAL& sqrDistLowerBound) const
bool BVDisjoints(unsigned int /*b1*/, unsigned int b2, FCL_REAL& sqrDistLowerBound) const
{
if(this->enable_statistics) this->num_bv_tests++;
bool res;
......@@ -308,7 +308,7 @@ public:
}
/// @brief Intersection testing between leaves (one shape and one triangle)
void leafCollides(int /*b1*/, int b2, FCL_REAL& sqrDistLowerBound) const
void leafCollides(unsigned int /*b1*/, unsigned int b2, FCL_REAL& sqrDistLowerBound) const
{
if(this->enable_statistics) this->num_leaf_tests++;
const BVNode<BV>& node = this->model2->getBV(b2);
......@@ -387,25 +387,25 @@ public:
}
/// @brief Whether the BV node in the first BVH tree is leaf
bool isFirstNodeLeaf(int b) const
bool isFirstNodeLeaf(unsigned int b) const
{
return model1->getBV(b).isLeaf();
}
/// @brief Obtain the left child of BV node in the first BVH
int getFirstLeftChild(int b) const
int getFirstLeftChild(unsigned int b) const
{
return model1->getBV(b).leftChild();
}
/// @brief Obtain the right child of BV node in the first BVH
int getFirstRightChild(int b) const
int getFirstRightChild(unsigned int b) const
{
return model1->getBV(b).rightChild();
}
/// @brief BV culling test in one BVTT node
FCL_REAL BVDistanceLowerBound(int b1, int /*b2*/) const
FCL_REAL BVDistanceLowerBound(unsigned int b1, unsigned int /*b2*/) const
{
return model1->getBV(b1).bv.distance(model2_bv);
}
......@@ -435,25 +435,25 @@ public:
}
/// @brief Whether the BV n