Commit 341fcb88 authored by tkunz's avatar tkunz
Browse files

Made code build with Visual Studio 2010.

- In intersect.h/cpp: Replaced some STL functions with their boost counterparts because VS 2010 does not fully support C99/C++11.
- In test/test_fcl_utility.h: Added NOMINMAX definition in order to avoid name clashes on Windows.
- In test/test_fcl_math.cpp: Only include simd/math_simd_details.h if FCL_HAVE_SSE is set. Caused compilation errors on Windows because simd/math_simd_details.h includes GCC-specific instructions.
- In test/test_fcl_math.cpp: Converted the constant parameter of the sqrt function from int to double because Visual Studio was not able to deduct the correct version of the overloaded sqrt function.
- In narrowphase/narrowphase.h: Fixed some issues with template specialization. It looks like some parts of the code were not correctly replaced after some copy-and-paste. This caused specialized templated member functions to not be declared in the header file. Thus, Visual Studio used the generic version instead. But, since the cpp defines specialized versions, the linker complained about functions being defined twice. Don't know why it compiled with GCC.
- In BVH/BV_splitter.cpp: It seems like Visual Studio does not automatically compile a fully specialized version of a templated class even if a specialized member function is defined. Thus, needed to add statements to force a compilation of specialized class templates.
- In BVH/BVH_model.cpp: Fixed a bug that caused a segmentation fault somewhere else (probably platform-independent).
- In ccd/taylor_model.cpp: Fixed a typo that did not cause any trouble for me but might when checking assertions.

git-svn-id: https://kforge.ros.org/fcl/fcl_ros@194 253336fb-580f-4252-a368-f3cef5a2a82b
parent 66956272
......@@ -38,7 +38,7 @@
#define FCL_DATA_TYPES_H
#include <cstddef>
#include <inttypes.h>
#include <cstdint>
namespace fcl
{
......
This diff is collapsed.
......@@ -599,72 +599,72 @@ bool GJKSolver_indep::shapeIntersect<Box, Box>(const Box& s1, const Transform3f&
Vec3f* contact_points, FCL_REAL* penetration_depth, Vec3f* normal) const;
template<>
bool GJKSolver_libccd::shapeIntersect<Sphere, Halfspace>(const Sphere& s1, const Transform3f& tf1,
bool GJKSolver_indep::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;
template<>
bool GJKSolver_libccd::shapeIntersect<Box, Halfspace>(const Box& s1, const Transform3f& tf1,
bool GJKSolver_indep::shapeIntersect<Box, Halfspace>(const Box& s1, const Transform3f& tf1,
const Halfspace& s2, const Transform3f& tf2,
Vec3f* contact_points, FCL_REAL* penetration_depth, Vec3f* normal) const;
template<>
bool GJKSolver_libccd::shapeIntersect<Capsule, Halfspace>(const Capsule& s1, const Transform3f& tf1,
bool GJKSolver_indep::shapeIntersect<Capsule, Halfspace>(const Capsule& s1, const Transform3f& tf1,
const Halfspace& s2, const Transform3f& tf2,
Vec3f* contact_points, FCL_REAL* penetration_depth, Vec3f* normal) const;
template<>
bool GJKSolver_libccd::shapeIntersect<Cylinder, Halfspace>(const Cylinder& s1, const Transform3f& tf1,
bool GJKSolver_indep::shapeIntersect<Cylinder, Halfspace>(const Cylinder& s1, const Transform3f& tf1,
const Halfspace& s2, const Transform3f& tf2,
Vec3f* contact_points, FCL_REAL* penetration_depth, Vec3f* normal) const;
template<>
bool GJKSolver_libccd::shapeIntersect<Cone, Halfspace>(const Cone& s1, const Transform3f& tf1,
bool GJKSolver_indep::shapeIntersect<Cone, Halfspace>(const Cone& s1, const Transform3f& tf1,
const Halfspace& s2, const Transform3f& tf2,
Vec3f* contact_points, FCL_REAL* penetration_depth, Vec3f* normal) const;
template<>
bool GJKSolver_libccd::shapeIntersect<Halfspace, Halfspace>(const Halfspace& s1, const Transform3f& tf1,
bool GJKSolver_indep::shapeIntersect<Halfspace, Halfspace>(const Halfspace& s1, const Transform3f& tf1,
const Halfspace& s2, const Transform3f& tf2,
Vec3f* contact_points, FCL_REAL* penetration_depth, Vec3f* normal) const;
template<>
bool GJKSolver_libccd::shapeIntersect<Plane, Halfspace>(const Plane& s1, const Transform3f& tf1,
bool GJKSolver_indep::shapeIntersect<Plane, Halfspace>(const Plane& s1, const Transform3f& tf1,
const Halfspace& s2, const Transform3f& tf2,
Vec3f* contact_points, FCL_REAL* penetration_depth, Vec3f* normal) const;
template<>
bool GJKSolver_libccd::shapeIntersect<Sphere, Plane>(const Sphere& s1, const Transform3f& tf1,
bool GJKSolver_indep::shapeIntersect<Sphere, Plane>(const Sphere& s1, const Transform3f& tf1,
const Plane& s2, const Transform3f& tf2,
Vec3f* contact_points, FCL_REAL* penetration_depth, Vec3f* normal) const;
template<>
bool GJKSolver_libccd::shapeIntersect<Box, Plane>(const Box& s1, const Transform3f& tf1,
bool GJKSolver_indep::shapeIntersect<Box, Plane>(const Box& s1, const Transform3f& tf1,
const Plane& s2, const Transform3f& tf2,
Vec3f* contact_points, FCL_REAL* penetration_depth, Vec3f* normal) const;
template<>
bool GJKSolver_libccd::shapeIntersect<Capsule, Plane>(const Capsule& s1, const Transform3f& tf1,
bool GJKSolver_indep::shapeIntersect<Capsule, Plane>(const Capsule& s1, const Transform3f& tf1,
const Plane& s2, const Transform3f& tf2,
Vec3f* contact_points, FCL_REAL* penetration_depth, Vec3f* normal) const;
template<>
bool GJKSolver_libccd::shapeIntersect<Cylinder, Plane>(const Cylinder& s1, const Transform3f& tf1,
bool GJKSolver_indep::shapeIntersect<Cylinder, Plane>(const Cylinder& s1, const Transform3f& tf1,
const Plane& s2, const Transform3f& tf2,
Vec3f* contact_points, FCL_REAL* penetration_depth, Vec3f* normal) const;
template<>
bool GJKSolver_libccd::shapeIntersect<Cone, Plane>(const Cone& s1, const Transform3f& tf1,
bool GJKSolver_indep::shapeIntersect<Cone, Plane>(const Cone& s1, const Transform3f& tf1,
const Plane& s2, const Transform3f& tf2,
Vec3f* contact_points, FCL_REAL* penetration_depth, Vec3f* normal) const;
template<>
bool GJKSolver_libccd::shapeIntersect<Halfspace, Plane>(const Halfspace& s1, const Transform3f& tf1,
bool GJKSolver_indep::shapeIntersect<Halfspace, Plane>(const Halfspace& s1, const Transform3f& tf1,
const Plane& s2, const Transform3f& tf2,
Vec3f* contact_points, FCL_REAL* penetration_depth, Vec3f* normal) const;
template<>
bool GJKSolver_libccd::shapeIntersect<Plane, Plane>(const Plane& s1, const Transform3f& tf1,
bool GJKSolver_indep::shapeIntersect<Plane, Plane>(const Plane& s1, const Transform3f& tf1,
const Plane& s2, const Transform3f& tf2,
Vec3f* contact_points, FCL_REAL* penetration_depth, Vec3f* normal) const;
......@@ -679,11 +679,11 @@ bool GJKSolver_indep::shapeTriangleIntersect(const Sphere& s, const Transform3f&
const Vec3f& P1, const Vec3f& P2, const Vec3f& P3, const Transform3f& tf2, Vec3f* contact_points, FCL_REAL* penetration_depth, Vec3f* normal) const;
template<>
bool GJKSolver_libccd::shapeTriangleIntersect(const Halfspace& s, const Transform3f& tf1,
bool GJKSolver_indep::shapeTriangleIntersect(const Halfspace& s, const Transform3f& tf1,
const Vec3f& P1, const Vec3f& P2, const Vec3f& P3, const Transform3f& tf2, Vec3f* contact_points, FCL_REAL* penetration_depth, Vec3f* normal) const;
template<>
bool GJKSolver_libccd::shapeTriangleIntersect(const Plane& s, const Transform3f& tf1,
bool GJKSolver_indep::shapeTriangleIntersect(const Plane& s, const Transform3f& tf1,
const Vec3f& P1, const Vec3f& P2, const Vec3f& P3, const Transform3f& tf2, Vec3f* contact_points, FCL_REAL* penetration_depth, Vec3f* normal) const;
......
......@@ -234,6 +234,7 @@ int BVHModel<BV>::addTriangle(const Vec3f& p1, const Vec3f& p2, const Vec3f& p3)
}
tri_indices[num_tris].set(offset, offset + 1, offset + 2);
num_tris++;
return BVH_OK;
}
......
......@@ -279,4 +279,9 @@ bool BVSplitter<OBBRSS>::apply(const Vec3f& q) const
}
template class BVSplitter<RSS>;
template class BVSplitter<OBBRSS>;
template class BVSplitter<OBB>;
template class BVSplitter<kIOS>;
}
......@@ -109,7 +109,7 @@ TaylorModel TaylorModel::operator + (const TaylorModel& other) const
TaylorModel TaylorModel::operator - (const TaylorModel& other) const
{
assert(other.time_interval__ == time_interval_);
assert(other.time_interval_ == time_interval_);
return TaylorModel(coeffs_[0] - other.coeffs_[0], coeffs_[1] - other.coeffs_[1], coeffs_[2] - other.coeffs_[2], coeffs_[3] - other.coeffs_[3], r_ - other.r_, time_interval_);
}
TaylorModel& TaylorModel::operator += (const TaylorModel& other)
......
......@@ -38,6 +38,7 @@
#include <iostream>
#include <limits>
#include <vector>
#include <boost\math\special_functions\fpclassify.hpp>
namespace fcl
{
......@@ -1198,7 +1199,7 @@ void TriangleDistance::segPoints(const Vec3f& P, const Vec3f& A, const Vec3f& Q,
// clamp result so t is on the segment P,A
if((t < 0) || std::isnan(t)) t = 0; else if(t > 1) t = 1;
if((t < 0) || boost::math::isnan(t)) t = 0; else if(t > 1) t = 1;
// find u for point on ray Q,B closest to point at t
......@@ -1208,13 +1209,13 @@ void TriangleDistance::segPoints(const Vec3f& P, const Vec3f& A, const Vec3f& Q,
// closest points, otherwise, clamp u, recompute and
// clamp t
if((u <= 0) || std::isnan(u))
if((u <= 0) || boost::math::isnan(u))
{
Y = Q;
t = A_dot_T / A_dot_A;
if((t <= 0) || std::isnan(t))
if((t <= 0) || boost::math::isnan(t))
{
X = P;
VEC = Q - P;
......@@ -1237,7 +1238,7 @@ void TriangleDistance::segPoints(const Vec3f& P, const Vec3f& A, const Vec3f& Q,
t = (A_dot_B + A_dot_T) / A_dot_A;
if((t <= 0) || std::isnan(t))
if((t <= 0) || boost::math::isnan(t))
{
X = P;
VEC = Y - P;
......@@ -1259,7 +1260,7 @@ void TriangleDistance::segPoints(const Vec3f& P, const Vec3f& A, const Vec3f& Q,
{
Y = Q + B * u;
if((t <= 0) || std::isnan(t))
if((t <= 0) || boost::math::isnan(t))
{
X = P;
TMP = T.cross(B);
......
......@@ -36,7 +36,9 @@
#define BOOST_TEST_MODULE "FCL_MATH"
#include <boost/test/unit_test.hpp>
#include "fcl/simd/math_simd_details.h"
#if FCL_HAVE_SSE
#include "fcl/simd/math_simd_details.h"
#endif
#include "fcl/math/vec_3f.h"
#include "fcl/math/matrix_3f.h"
#include "fcl/broadphase/morton.h"
......@@ -94,8 +96,8 @@ BOOST_AUTO_TEST_CASE(vec_test_basic_vec32)
BOOST_CHECK(abs(v1.dot(v2) - 26) < 1e-5);
v1 = Vec3f32(3.0f, 4.0f, 5.0f);
BOOST_CHECK(abs(v1.sqrLength() - 50) < 1e-5);
BOOST_CHECK(abs(v1.length() - sqrt(50)) < 1e-5);
BOOST_CHECK(abs(v1.sqrLength() - 50.0) < 1e-5);
BOOST_CHECK(abs(v1.length() - sqrt(50.0)) < 1e-5);
BOOST_CHECK(normalize(v1).equal(v1 / v1.length()));
}
......@@ -149,8 +151,8 @@ BOOST_AUTO_TEST_CASE(vec_test_basic_vec64)
BOOST_CHECK(abs(v1.dot(v2) - 26) < 1e-5);
v1 = Vec3f64(3.0, 4.0, 5.0);
BOOST_CHECK(abs(v1.sqrLength() - 50) < 1e-5);
BOOST_CHECK(abs(v1.length() - sqrt(50)) < 1e-5);
BOOST_CHECK(abs(v1.sqrLength() - 50.0) < 1e-5);
BOOST_CHECK(abs(v1.length() - sqrt(50.0)) < 1e-5);
BOOST_CHECK(normalize(v1).equal(v1 / v1.length()));
......
......@@ -42,6 +42,7 @@
#include "fcl/collision_object.h"
#ifdef _WIN32
#define NOMINMAX // required to avoid compilation errors with Visual Studio 2010
#include <windows.h>
#else
#include <sys/time.h>
......
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