Unverified Commit 45819b0d authored by Joseph Mirabel's avatar Joseph Mirabel Committed by GitHub
Browse files

Merge pull request #101 from jmirabel/refactoring

Bug fix in propagateBVHFrontListCollisionRecurse + unit-tests
parents 5fd04405 f8ab2efd
...@@ -422,7 +422,8 @@ int BVHModelBase::beginReplaceModel() ...@@ -422,7 +422,8 @@ int BVHModelBase::beginReplaceModel()
return BVH_ERR_BUILD_EMPTY_PREVIOUS_FRAME; return BVH_ERR_BUILD_EMPTY_PREVIOUS_FRAME;
} }
if(prev_vertices) delete [] prev_vertices; prev_vertices = NULL; if(prev_vertices) delete [] prev_vertices;
prev_vertices = NULL;
num_vertex_updated = 0; num_vertex_updated = 0;
......
...@@ -382,7 +382,7 @@ void propagateBVHFrontListCollisionRecurse ...@@ -382,7 +382,7 @@ void propagateBVHFrontListCollisionRecurse
front_iter->valid = false; front_iter->valid = false;
if(node->firstOverSecond(b1, b2)) { if(node->firstOverSecond(b1, b2)) {
int c1 = node->getFirstLeftChild(b1); int c1 = node->getFirstLeftChild(b1);
int c2 = node->getFirstRightChild(b2); int c2 = node->getFirstRightChild(b1);
collisionRecurse(node, c1, b2, front_list, sqrDistLowerBound1); collisionRecurse(node, c1, b2, front_list, sqrDistLowerBound1);
collisionRecurse(node, c2, b2, front_list, sqrDistLowerBound2); collisionRecurse(node, c2, b2, front_list, sqrDistLowerBound2);
......
...@@ -84,7 +84,11 @@ BOOST_AUTO_TEST_CASE(front_list) ...@@ -84,7 +84,11 @@ BOOST_AUTO_TEST_CASE(front_list)
std::vector<Transform3f> transforms2; // t1 std::vector<Transform3f> transforms2; // t1
FCL_REAL extents[] = {-3000, -3000, 0, 3000, 3000, 3000}; FCL_REAL extents[] = {-3000, -3000, 0, 3000, 3000, 3000};
FCL_REAL delta_trans[] = {1, 1, 1}; FCL_REAL delta_trans[] = {1, 1, 1};
std::size_t n = 10; #ifdef NDEBUG
std::size_t n = 20;
#else
std::size_t n = 5;
#endif
bool verbose = false; bool verbose = false;
generateRandomTransforms(extents, delta_trans, 0.005 * 2 * 3.1415, transforms, transforms2, n); generateRandomTransforms(extents, delta_trans, 0.005 * 2 * 3.1415, transforms, transforms2, n);
......
...@@ -339,51 +339,6 @@ void generateRandomTransforms(FCL_REAL extents[6], FCL_REAL delta_trans[3], FCL_ ...@@ -339,51 +339,6 @@ void generateRandomTransforms(FCL_REAL extents[6], FCL_REAL delta_trans[3], FCL_
} }
} }
void generateRandomTransform_ccd(FCL_REAL extents[6], std::vector<Transform3f>& transforms, std::vector<Transform3f>& transforms2, FCL_REAL delta_trans[3], FCL_REAL delta_rot, std::size_t n,
const std::vector<Vec3f>& /*vertices1*/, const std::vector<Triangle>& /*riangles1*/,
const std::vector<Vec3f>& /*vertices2*/, const std::vector<Triangle>& /*riangles2*/)
{
transforms.resize(n);
transforms2.resize(n);
for(std::size_t i = 0; i < n;)
{
FCL_REAL x = rand_interval(extents[0], extents[3]);
FCL_REAL y = rand_interval(extents[1], extents[4]);
FCL_REAL z = rand_interval(extents[2], extents[5]);
const FCL_REAL pi = 3.1415926;
FCL_REAL a = rand_interval(0, 2 * pi);
FCL_REAL b = rand_interval(0, 2 * pi);
FCL_REAL c = rand_interval(0, 2 * pi);
Matrix3f R;
eulerToMatrix(a, b, c, R);
Vec3f T(x, y, z);
Transform3f tf(R, T);
std::vector<std::pair<int, int> > results;
{
transforms[i] = tf;
FCL_REAL deltax = rand_interval(-delta_trans[0], delta_trans[0]);
FCL_REAL deltay = rand_interval(-delta_trans[1], delta_trans[1]);
FCL_REAL deltaz = rand_interval(-delta_trans[2], delta_trans[2]);
FCL_REAL deltaa = rand_interval(-delta_rot, delta_rot);
FCL_REAL deltab = rand_interval(-delta_rot, delta_rot);
FCL_REAL deltac = rand_interval(-delta_rot, delta_rot);
Matrix3f R2;
eulerToMatrix(a + deltaa, b + deltab, c + deltac, R2);
Vec3f T2(x + deltax, y + deltay, z + deltaz);
transforms2[i].setTransform(R2, T2);
++i;
}
}
}
bool defaultCollisionFunction(CollisionObject* o1, CollisionObject* o2, void* cdata_) bool defaultCollisionFunction(CollisionObject* o1, CollisionObject* o2, void* cdata_)
{ {
CollisionData* cdata = static_cast<CollisionData*>(cdata_); CollisionData* cdata = static_cast<CollisionData*>(cdata_);
......
...@@ -118,12 +118,6 @@ void generateRandomTransforms(FCL_REAL extents[6], std::vector<Transform3f>& tra ...@@ -118,12 +118,6 @@ void generateRandomTransforms(FCL_REAL extents[6], std::vector<Transform3f>& tra
/// @brief Generate n random transforms whose translations are constrained by extents. Also generate another transforms2 which have additional random translation & rotation to the transforms generated. /// @brief Generate n random transforms whose translations are constrained by extents. Also generate another transforms2 which have additional random translation & rotation to the transforms generated.
void generateRandomTransforms(FCL_REAL extents[6], FCL_REAL delta_trans[3], FCL_REAL delta_rot, std::vector<Transform3f>& transforms, std::vector<Transform3f>& transforms2, std::size_t n); void generateRandomTransforms(FCL_REAL extents[6], FCL_REAL delta_trans[3], FCL_REAL delta_rot, std::vector<Transform3f>& transforms, std::vector<Transform3f>& transforms2, std::size_t n);
/// @brief Generate n random tranforms and transform2 with addtional random translation/rotation. The transforms and transform2 are used as initial and goal configurations for the first mesh. The second mesh is in I. This is used for continuous collision detection checking.
void generateRandomTransforms_ccd(FCL_REAL extents[6], std::vector<Transform3f>& transforms, std::vector<Transform3f>& transforms2, FCL_REAL delta_trans[3], FCL_REAL delta_rot, std::size_t n,
const std::vector<Vec3f>& vertices1, const std::vector<Triangle>& triangles1,
const std::vector<Vec3f>& vertices2, const std::vector<Triangle>& triangles2);
/// @ brief Structure for minimum distance between two meshes and the corresponding nearest point pair /// @ brief Structure for minimum distance between two meshes and the corresponding nearest point pair
struct DistanceRes struct DistanceRes
{ {
......
brew update
# Add gepetto tap # Add gepetto tap
brew tap gepetto/homebrew-gepetto brew tap gepetto/homebrew-gepetto
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment