Commit 6b8b8a5b authored by Florent Lamiraux's avatar Florent Lamiraux
Browse files

Remoce dependency to libccd.

parent 840b91a0
......@@ -57,7 +57,6 @@ if (EIGEN3_FOUND)
endif (EIGEN3_FOUND)
# Required dependencies
add_required_dependency("ccd >= 1.4")
set(BOOST_COMPONENTS thread date_time filesystem system unit_test_framework)
search_for_boost()
# Optional dependencies
......@@ -90,8 +89,6 @@ SET(${PROJECT_NAME}_HEADERS
include/hpp/fcl/collision_data.h
include/hpp/fcl/profile.h
include/hpp/fcl/exception.h
include/hpp/fcl/ccd/simplex.h
include/hpp/fcl/ccd/support.h
include/hpp/fcl/deprecated.h
include/hpp/fcl/BV/kIOS.h
include/hpp/fcl/BV/BV.h
......@@ -103,7 +100,6 @@ SET(${PROJECT_NAME}_HEADERS
include/hpp/fcl/BV/kDOP.h
include/hpp/fcl/narrowphase/narrowphase.h
include/hpp/fcl/narrowphase/gjk.h
include/hpp/fcl/narrowphase/gjk_libccd.h
include/hpp/fcl/broadphase/interval_tree.h
include/hpp/fcl/broadphase/broadphase_spatialhash.h
include/hpp/fcl/broadphase/broadphase_dynamic_AABB_tree.h
......
/***
* libccd
* ---------------------------------
* Copyright (c)2010 Daniel Fiser <danfis@danfis.cz>
*
*
* This file is part of libccd.
*
* Distributed under the OSI-approved BSD License (the "License");
* see accompanying file BDS-LICENSE for details or see
* <http://www.opensource.org/licenses/bsd-license.php>.
*
* This software is distributed WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the License for more information.
*/
#ifndef __CCD_SIMPLEX_H__
#define __CCD_SIMPLEX_H__
#include <ccd/compiler.h>
#include "support.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
struct _ccd_simplex_t {
ccd_support_t ps[4];
int last; //!< index of last added point
};
typedef struct _ccd_simplex_t ccd_simplex_t;
_ccd_inline void ccdSimplexInit(ccd_simplex_t *s);
_ccd_inline int ccdSimplexSize(const ccd_simplex_t *s);
_ccd_inline const ccd_support_t *ccdSimplexLast(const ccd_simplex_t *s);
_ccd_inline const ccd_support_t *ccdSimplexPoint(const ccd_simplex_t *s, int idx);
_ccd_inline ccd_support_t *ccdSimplexPointW(ccd_simplex_t *s, int idx);
_ccd_inline void ccdSimplexAdd(ccd_simplex_t *s, const ccd_support_t *v);
_ccd_inline void ccdSimplexSet(ccd_simplex_t *s, size_t pos, const ccd_support_t *a);
_ccd_inline void ccdSimplexSetSize(ccd_simplex_t *s, int size);
_ccd_inline void ccdSimplexSwap(ccd_simplex_t *s, size_t pos1, size_t pos2);
/**** INLINES ****/
_ccd_inline void ccdSimplexInit(ccd_simplex_t *s)
{
s->last = -1;
}
_ccd_inline int ccdSimplexSize(const ccd_simplex_t *s)
{
return s->last + 1;
}
_ccd_inline const ccd_support_t *ccdSimplexLast(const ccd_simplex_t *s)
{
return ccdSimplexPoint(s, s->last);
}
_ccd_inline const ccd_support_t *ccdSimplexPoint(const ccd_simplex_t *s, int idx)
{
// here is no check on boundaries
return &s->ps[idx];
}
_ccd_inline ccd_support_t *ccdSimplexPointW(ccd_simplex_t *s, int idx)
{
return &s->ps[idx];
}
_ccd_inline void ccdSimplexAdd(ccd_simplex_t *s, const ccd_support_t *v)
{
// here is no check on boundaries in sake of speed
++s->last;
ccdSupportCopy(s->ps + s->last, v);
}
_ccd_inline void ccdSimplexSet(ccd_simplex_t *s, size_t pos, const ccd_support_t *a)
{
ccdSupportCopy(s->ps + pos, a);
}
_ccd_inline void ccdSimplexSetSize(ccd_simplex_t *s, int size)
{
s->last = size - 1;
}
_ccd_inline void ccdSimplexSwap(ccd_simplex_t *s, size_t pos1, size_t pos2)
{
ccd_support_t supp;
ccdSupportCopy(&supp, &s->ps[pos1]);
ccdSupportCopy(&s->ps[pos1], &s->ps[pos2]);
ccdSupportCopy(&s->ps[pos2], &supp);
}
#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */
#endif /* __CCD_SIMPLEX_H__ */
/***
* libccd
* ---------------------------------
* Copyright (c)2010 Daniel Fiser <danfis@danfis.cz>
*
*
* This file is part of libccd.
*
* Distributed under the OSI-approved BSD License (the "License");
* see accompanying file BDS-LICENSE for details or see
* <http://www.opensource.org/licenses/bsd-license.php>.
*
* This software is distributed WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the License for more information.
*/
#ifndef __CCD_SUPPORT_H__
#define __CCD_SUPPORT_H__
#include <ccd/ccd.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
struct _ccd_support_t {
ccd_vec3_t v; //!< Support point in minkowski sum
ccd_vec3_t v1; //!< Support point in obj1
ccd_vec3_t v2; //!< Support point in obj2
};
typedef struct _ccd_support_t ccd_support_t;
_ccd_inline void ccdSupportCopy(ccd_support_t *, const ccd_support_t *s);
/**
* Computes support point of obj1 and obj2 in direction dir.
* Support point is returned via supp.
*/
void __ccdSupport(const void *obj1, const void *obj2,
const ccd_vec3_t *dir, const ccd_t *ccd,
ccd_support_t *supp);
/**** INLINES ****/
_ccd_inline void ccdSupportCopy(ccd_support_t *d, const ccd_support_t *s)
{
*d = *s;
}
#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */
#endif /* __CCD_SUPPORT_H__ */
......@@ -54,7 +54,7 @@ namespace fcl
{
/// @brief Type of narrow phase GJK solver
enum GJKSolverType {GST_LIBCCD, GST_INDEP};
enum GJKSolverType {GST_INDEP};
/// @brief Contact information returned by collision
struct Contact
......@@ -228,7 +228,7 @@ struct CollisionRequest
size_t num_max_cost_sources_ = 1,
bool enable_cost_ = false,
bool use_approximate_cost_ = true,
GJKSolverType gjk_solver_type_ = GST_LIBCCD) :
GJKSolverType gjk_solver_type_ = GST_INDEP) :
num_max_contacts(num_max_contacts_),
enable_contact(enable_contact_),
enable_distance_lower_bound (enable_distance_lower_bound_),
......@@ -363,7 +363,7 @@ struct DistanceRequest
DistanceRequest(bool enable_nearest_points_ = false,
FCL_REAL rel_err_ = 0.0,
FCL_REAL abs_err_ = 0.0,
GJKSolverType gjk_solver_type_ = GST_LIBCCD) : enable_nearest_points(enable_nearest_points_),
GJKSolverType gjk_solver_type_ = GST_INDEP) : enable_nearest_points(enable_nearest_points_),
rel_err(rel_err_),
abs_err(abs_err_),
gjk_solver_type(gjk_solver_type_)
......@@ -496,7 +496,7 @@ struct PenetrationDepthRequest
NearestNeighbors<Transform3f>::DistanceFunction distance_func_,
KNNSolverType knn_solver_type_ = KNN_LINEAR,
PenetrationDepthType pd_type_ = PDT_TRANSLATIONAL,
GJKSolverType gjk_solver_type_ = GST_LIBCCD) : classifier(classifier_),
GJKSolverType gjk_solver_type_ = GST_INDEP) : classifier(classifier_),
distance_func(distance_func_),
knn_solver_type(knn_solver_type_),
pd_type(pd_type_),
......
/*
* Software License Agreement (BSD License)
*
* Copyright (c) 2011-2014, Willow Garage, Inc.
* Copyright (c) 2014-2015, Open Source Robotics Foundation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Open Source Robotics Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/** \author Jia Pan */
#ifndef FCL_GJK_LIBCCD_H
#define FCL_GJK_LIBCCD_H
#include <hpp/fcl/shape/geometric_shapes.h>
#include <hpp/fcl/math/transform.h>
#include <ccd/ccd.h>
#include <ccd/quat.h>
namespace fcl
{
namespace details
{
/// @brief callback function used by GJK algorithm
typedef void (*GJKSupportFunction)(const void* obj, const ccd_vec3_t* dir_, ccd_vec3_t* v);
typedef void (*GJKCenterFunction)(const void* obj, ccd_vec3_t* c);
/// @brief initialize GJK stuffs
template<typename T>
class GJKInitializer
{
public:
/// @brief Get GJK support function
static GJKSupportFunction getSupportFunction() { return NULL; }
/// @brief Get GJK center function
static GJKCenterFunction getCenterFunction() { return NULL; }
/// @brief Get GJK object from a shape
/// Notice that only local transformation is applied.
/// Gloal transformation are considered later
static void* createGJKObject(const T& /* s */, const Transform3f& /*tf*/) { return NULL; }
/// @brief Delete GJK object
static void deleteGJKObject(void* o) {}
};
/// @brief initialize GJK Cylinder
template<>
class GJKInitializer<Cylinder>
{
public:
static GJKSupportFunction getSupportFunction();
static GJKCenterFunction getCenterFunction();
static void* createGJKObject(const Cylinder& s, const Transform3f& tf);
static void deleteGJKObject(void* o);
};
/// @brief initialize GJK Sphere
template<>
class GJKInitializer<Sphere>
{
public:
static GJKSupportFunction getSupportFunction();
static GJKCenterFunction getCenterFunction();
static void* createGJKObject(const Sphere& s, const Transform3f& tf);
static void deleteGJKObject(void* o);
};
/// @brief initialize GJK Box
template<>
class GJKInitializer<Box>
{
public:
static GJKSupportFunction getSupportFunction();
static GJKCenterFunction getCenterFunction();
static void* createGJKObject(const Box& s, const Transform3f& tf);
static void deleteGJKObject(void* o);
};
/// @brief initialize GJK Capsule
template<>
class GJKInitializer<Capsule>
{
public:
static GJKSupportFunction getSupportFunction();
static GJKCenterFunction getCenterFunction();
static void* createGJKObject(const Capsule& s, const Transform3f& tf);
static void deleteGJKObject(void* o);
};
/// @brief initialize GJK Cone
template<>
class GJKInitializer<Cone>
{
public:
static GJKSupportFunction getSupportFunction();
static GJKCenterFunction getCenterFunction();
static void* createGJKObject(const Cone& s, const Transform3f& tf);
static void deleteGJKObject(void* o);
};
/// @brief initialize GJK Convex
template<>
class GJKInitializer<Convex>
{
public:
static GJKSupportFunction getSupportFunction();
static GJKCenterFunction getCenterFunction();
static void* createGJKObject(const Convex& s, const Transform3f& tf);
static void deleteGJKObject(void* o);
};
/// @brief initialize GJK Triangle
GJKSupportFunction triGetSupportFunction();
GJKCenterFunction triGetCenterFunction();
void* triCreateGJKObject(const Vec3f& P1, const Vec3f& P2, const Vec3f& P3);
void* triCreateGJKObject(const Vec3f& P1, const Vec3f& P2, const Vec3f& P3, const Transform3f& tf);
void triDeleteGJKObject(void* o);
/// @brief GJK collision algorithm
bool GJKCollide(void* obj1, ccd_support_fn supp1, ccd_center_fn cen1,
void* obj2, ccd_support_fn supp2, ccd_center_fn cen2,
unsigned int max_iterations, FCL_REAL tolerance,
Vec3f* contact_points, FCL_REAL* penetration_depth, Vec3f* normal);
/// Distance computation between objects using GJK algorithm
/// \param obj1, obj2 objects to compute the distance between,
/// \param supp1, supp2, support functions of each object,
/// \retval p1, p2 closest points on objects in global frame,
/// \retval dist distance between objects,
/// \return whether distance is non negative (no collision).
bool GJKDistance(void* obj1, ccd_support_fn supp1,
void* obj2, ccd_support_fn supp2,
unsigned int max_iterations, FCL_REAL tolerance,
FCL_REAL* dist, Vec3f* p1, Vec3f* p2);
} // details
}
#endif
This diff is collapsed.
......@@ -44,7 +44,6 @@ set(${LIBRARY_NAME}_SOURCES
BV/kDOP.cpp
BV/OBBRSS.cpp
BV/OBB.cpp
narrowphase/gjk_libccd.cpp
narrowphase/narrowphase.cpp
narrowphase/gjk.cpp
broadphase/broadphase_bruteforce.cpp
......@@ -89,7 +88,6 @@ add_library(${LIBRARY_NAME}
${${LIBRARY_NAME}_SOURCES}
)
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${Boost_LIBRARIES})
PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} ccd)
PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} assimp)
IF(OCTOMAP_FOUND)
PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} octomap)
......
......@@ -141,11 +141,6 @@ std::size_t collide(const CollisionObject* o1, const CollisionObject* o2,
{
switch(request.gjk_solver_type)
{
case GST_LIBCCD:
{
GJKSolver_libccd solver;
return collide<GJKSolver_libccd>(o1, o2, &solver, request, result);
}
case GST_INDEP:
{
GJKSolver_indep solver;
......@@ -162,11 +157,6 @@ std::size_t collide(const CollisionGeometry* o1, const Transform3f& tf1,
{
switch(request.gjk_solver_type)
{
case GST_LIBCCD:
{
GJKSolver_libccd solver;
return collide<GJKSolver_libccd>(o1, tf1, o2, tf2, &solver, request, result);
}
case GST_INDEP:
{
GJKSolver_indep solver;
......
......@@ -687,10 +687,5 @@ CollisionFunctionMatrix<NarrowPhaseSolver>::CollisionFunctionMatrix()
collision_matrix[BV_KDOP24][GEOM_OCTREE] = &BVHOcTreeCollide<KDOP<24>, NarrowPhaseSolver>;
#endif
}
template struct CollisionFunctionMatrix<GJKSolver_libccd>;
template struct CollisionFunctionMatrix<GJKSolver_indep>;
}
......@@ -121,11 +121,6 @@ FCL_REAL distance(const CollisionObject* o1, const CollisionObject* o2, const Di
{
switch(request.gjk_solver_type)
{
case GST_LIBCCD:
{
GJKSolver_libccd solver;
return distance<GJKSolver_libccd>(o1, o2, &solver, request, result);
}
case GST_INDEP:
{
GJKSolver_indep solver;
......@@ -142,11 +137,6 @@ FCL_REAL distance(const CollisionGeometry* o1, const Transform3f& tf1,
{
switch(request.gjk_solver_type)
{
case GST_LIBCCD:
{
GJKSolver_libccd solver;
return distance<GJKSolver_libccd>(o1, tf1, o2, tf2, &solver, request, result);
}
case GST_INDEP:
{
GJKSolver_indep solver;
......
......@@ -21,14 +21,13 @@
// One solution would be to make narrow phase solvers derive from an abstract
// class and specialize the template for this abstract class.
namespace fcl {
class GJKSolver_libccd;
class GJKSolver_indep;
template <>
FCL_REAL ShapeShapeDistance <Capsule, Capsule, GJKSolver_libccd>
FCL_REAL ShapeShapeDistance <Capsule, Capsule, GJKSolver_indep>
(const CollisionGeometry* o1, const Transform3f& tf1,
const CollisionGeometry* o2, const Transform3f& tf2,
const GJKSolver_libccd*, const DistanceRequest& request,
const GJKSolver_indep*, const DistanceRequest& request,
DistanceResult& result)
{
const Capsule* c1 = static_cast <const Capsule*> (o1);
......@@ -319,18 +318,6 @@ namespace fcl {
return result.min_distance;
}
template <>
FCL_REAL ShapeShapeDistance <Capsule, Capsule, GJKSolver_indep>
(const CollisionGeometry* o1, const Transform3f& tf1,
const CollisionGeometry* o2, const Transform3f& tf2,
const GJKSolver_indep*, const DistanceRequest& request,
DistanceResult& result)
{
GJKSolver_libccd* unused = 0x0;
return ShapeShapeDistance <Capsule, Capsule, GJKSolver_libccd>
(o1, tf1, o2, tf2, unused, request, result);
}
template <>
std::size_t ShapeShapeCollide <Capsule, Capsule, GJKSolver_indep>
(const CollisionGeometry* o1, const Transform3f& tf1,
......@@ -338,11 +325,11 @@ namespace fcl {
const GJKSolver_indep*, const CollisionRequest& request,
CollisionResult& result)
{
GJKSolver_libccd* unused = 0x0;
GJKSolver_indep* unused = 0x0;
DistanceResult distanceResult;
DistanceRequest distanceRequest (request.enable_contact);
FCL_REAL distance = ShapeShapeDistance <Capsule, Capsule, GJKSolver_libccd>
FCL_REAL distance = ShapeShapeDistance <Capsule, Capsule, GJKSolver_indep>
(o1, tf1, o2, tf2, unused, distanceRequest, distanceResult);
if (distance <= 0) {
......@@ -357,16 +344,4 @@ namespace fcl {
result.distance_lower_bound = distance;
return 0;
}
template<>
std::size_t ShapeShapeCollide <Capsule, Capsule, GJKSolver_libccd>
(const CollisionGeometry* o1, const Transform3f& tf1,
const CollisionGeometry* o2, const Transform3f& tf2,
const GJKSolver_libccd* nsolver, const CollisionRequest& request,
CollisionResult& result)
{
GJKSolver_indep* unused = 0x0;
return ShapeShapeCollide <Capsule, Capsule, GJKSolver_indep>
(o1, tf1, o2, tf2, unused, request, result);
}
} // namespace fcl
......@@ -492,9 +492,5 @@ DistanceFunctionMatrix<NarrowPhaseSolver>::DistanceFunctionMatrix()
}
template struct DistanceFunctionMatrix<GJKSolver_libccd>;
template struct DistanceFunctionMatrix<GJKSolver_indep>;
}
This diff is collapsed.
......@@ -2456,295 +2456,6 @@ bool planeIntersect(const Plane& s1, const Transform3f& tf1,
// | triangle |/////|////////|/////////|//////|//////////|///////|////////////| |
// +------------+-----+--------+---------+------+----------+-------+------------+----------+
template<>
bool GJKSolver_libccd::shapeIntersect<Sphere, Capsule>(const Sphere &s1, const Transform3f& tf1,
const Capsule &s2, const Transform3f& tf2,
Vec3f* contact_points, FCL_REAL* penetration_depth, Vec3f* normal) const
{
return details::sphereCapsuleIntersect(s1, tf1, s2, tf2, contact_points, penetration_depth, normal);
}
template<>
bool GJKSolver_libccd::shapeIntersect<Capsule, Sphere>(const Capsule &s1, const Transform3f& tf1,
const Sphere &s2, const Transform3f& tf2,
Vec3f* contact_points, FCL_REAL* penetration_depth, Vec3f* normal) const
{
const bool res = details::sphereCapsuleIntersect(s2, tf2, s1, tf1, contact_points, penetration_depth, normal);
if (normal) (*normal) *= -1.0;
return res;
}
template<>
bool GJKSolver_libccd::shapeIntersect<Sphere, Sphere>(const Sphere& s1, const Transform3f& tf1,
const Sphere& s2, const Transform3f& tf2,
Vec3f* contact_points, FCL_REAL* penetration_depth, Vec3f* normal) const
{
return details::sphereSphereIntersect(s1, tf1, s2, tf2, contact_points, penetration_depth, normal);
}
template<>
bool GJKSolver_libccd::shapeIntersect<Box, Box>(const Box& s1, const Transform3f& tf1,
const Box& s2, const Transform3f& tf2,
Vec3f* contact_points, FCL_REAL* penetration_depth, Vec3f* normal) const
{
return details::boxBoxIntersect(s1, tf1, s2, tf2, contact_points, penetration_depth, normal);
}
template<>
bool GJKSolver_libccd::shapeIntersect<Sphere, Halfspace>(const Sphere& s1, const Transform3f& tf1,
const Halfspace& s2, const Transform3f& tf2,
Vec3f* contact_points, FCL_REAL* penetration_depth, Vec3f* normal) const
{
return details::sphereHalfspaceIntersect(s1, tf1, s2, tf2, contact_points, penetration_depth, normal);
}
template<>
bool GJKSolver_libccd::shapeIntersect<Halfspace, Sphere>(const Halfspace& s1, const Transform3f& tf1,
const Sphere& s2, const Transform3f& tf2,
Vec3f* contact_points, FCL_REAL* penetration_depth, Vec3f* normal) const
{
const bool res = details::sphereHalfspaceIntersect(s2, tf2, s1, tf1, contact_points, penetration_depth, normal);
if (normal) (*normal) *= -1.0;
return res;
}