Skip to content

Commit 84782a2

Browse files
committed
ODE: add to Linux build
1 parent 9a4697b commit 84782a2

File tree

7 files changed

+57
-17
lines changed

7 files changed

+57
-17
lines changed

Externals/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@ add_subdirectory(lzo)
44
add_subdirectory(cximage)
55
add_subdirectory(NVTT)
66
add_subdirectory(OPCODE)
7+
add_subdirectory(ode)
8+
#add_subdirectory(pugixml)
79
#add_subdirectory(gli)
810
#add_subdirectory(glew)

Externals/ode/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
project(ODE)
2+
3+
list(APPEND DIRS
4+
"ode/src"
5+
"include/ode"
6+
"contrib/msvc7/ode_default"
7+
)
8+
9+
add_dir("${DIRS}")
10+
11+
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/../../sdk/include )
12+
13+
add_definitions(-DdSINGLE -D_SECURE_SCL=0 -DLINUX -D_cdecl= -D__forceinline=inline)
14+
15+
add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}__SOURCES} ${${PROJECT_NAME}__INCLUDES})

Externals/ode/include/ode/common.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
#include <ode/config.h>
2727
#include <ode/error.h>
2828

29+
#ifdef LINUX
30+
#include <alloca.h>
31+
#endif
32+
2933
#ifdef __cplusplus
3034
extern "C" {
3135
#endif

Externals/ode/include/ode/config.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323

2424
/* per-machine configuration */
2525

26-
26+
#ifdef LINUX
27+
#include <stdint.h>
28+
#endif
2729

2830
#ifndef _ODE_CONFIG_H_
2931

Externals/ode/ode/src/error.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ static void printMessage (int num, const char *msg1, const char *msg2,
8282
// unix
8383

8484
#ifndef WIN32
85+
#include <stdlib.h>
8586

8687
extern "C" void dError (int num, const char *msg, ...)
8788
{

Externals/ode/ode/src/odemath.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <ode/common.h>
2424
#include <ode/odemath.h>
2525
#include <float.h>
26+
#include <cmath>
2627

2728
// this may be called for vectors `a' with extremely small magnitude, for
2829
// example the result of a cross product on two nearly perpendicular vectors.
@@ -51,7 +52,7 @@ void dNormalize3_slow (dVector3 a)
5152
a2 /= aa1;
5253
l = dRecipSqrt (a0*a0 + a2*a2 + 1);
5354
a[0] = a0*l;
54-
a[1] = (dReal)_copysign(l,a1);
55+
a[1] = (dReal)std::copysign(l,a1);
5556
a[2] = a2*l;
5657
}
5758
}
@@ -63,7 +64,7 @@ void dNormalize3_slow (dVector3 a)
6364
l = dRecipSqrt (a0*a0 + a1*a1 + 1);
6465
a[0] = a0*l;
6566
a[1] = a1*l;
66-
a[2] = (dReal)_copysign(l,a2);
67+
a[2] = (dReal)std::copysign(l,a2);
6768
}
6869
else { // aa0 is largest
6970
if (aa0 <= 0) {
@@ -76,7 +77,7 @@ void dNormalize3_slow (dVector3 a)
7677
a1 /= aa0;
7778
a2 /= aa0;
7879
l = dRecipSqrt (a1*a1 + a2*a2 + 1);
79-
a[0] = (dReal)_copysign(l,a0);
80+
a[0] = (dReal)std::copysign(l,a0);
8081
a[1] = a1*l;
8182
a[2] = a2*l;
8283
}

Externals/ode/ode/src/util.h

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525

2626
#include "objects.h"
2727
#include "float.h"
28+
#if defined(LINUX)
29+
#include <math.h>
30+
#endif
2831

2932
void dInternalHandleAutoDisabling (dxWorld *world, dReal stepsize);
3033
extern "C"
@@ -37,19 +40,31 @@ typedef void (*dstepper_fn_t) (dxWorld *world, dxBody * const *body, int nb,
3740

3841
void dxProcessIslands (dxWorld *world, dReal stepsize, dstepper_fn_t stepper);
3942

40-
inline bool dValid (const float x)
43+
inline bool dValid(const float x)
4144
{
42-
// check for: Signaling NaN, Quiet NaN, Negative infinity ( –INF), Positive infinity (+INF), Negative denormalized, Positive denormalized
43-
int cls = _fpclass (double(x));
44-
if (cls&(_FPCLASS_SNAN+_FPCLASS_QNAN+_FPCLASS_NINF+_FPCLASS_PINF+_FPCLASS_ND+_FPCLASS_PD))
45-
return false;
46-
47-
/* *****other cases are*****
48-
_FPCLASS_NN Negative normalized non-zero
49-
_FPCLASS_NZ Negative zero ( – 0)
50-
_FPCLASS_PZ Positive 0 (+0)
51-
_FPCLASS_PN Positive normalized non-zero
52-
*/
53-
return true;
45+
#ifdef MSVC
46+
// check for: Signaling NaN, Quiet NaN, Negative infinity ( �INF), Positive infinity (+INF), Negative denormalized, Positive denormalized
47+
int cls = _fpclass (double(x));
48+
if (cls&(_FPCLASS_SNAN+_FPCLASS_QNAN+_FPCLASS_NINF+_FPCLASS_PINF+_FPCLASS_ND+_FPCLASS_PD))
49+
return false;
50+
#elif defined(LINUX)
51+
int cls = fpclassify((double )x);
52+
switch (cls)
53+
{
54+
case FP_NAN:
55+
case FP_INFINITE:
56+
case FP_SUBNORMAL:
57+
return false;
58+
default:
59+
break;
60+
}
61+
#endif
62+
/* *****other cases are*****
63+
_FPCLASS_NN Negative normalized non-zero
64+
_FPCLASS_NZ Negative zero ( � 0)
65+
_FPCLASS_PZ Positive 0 (+0)
66+
_FPCLASS_PN Positive normalized non-zero
67+
*/
68+
return true;
5469
}
5570
#endif

0 commit comments

Comments
 (0)