Skip to content

Commit 3fab5cc

Browse files
committed
Port Externals/ode on Linux by eagleivg
1 parent 6de5f04 commit 3fab5cc

File tree

6 files changed

+41
-18
lines changed

6 files changed

+41
-18
lines changed

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/error.h>
2727
#include <math.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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#ifndef STEP_JOINT_INTERNAL_H
22
#define STEP_JOINT_INTERNAL_H
33
void dInternalStepJointContact (dxWorld * world, dxBody * body[2], dReal * GI[2], dReal * GinvI[2], dxJoint * joint, dxJoint::Info1 info, dxJoint::Info2 Jinfo, dReal stepsize);
4-
#endif STEP_JOINT_INTERNAL_H
4+
#endif // STEP_JOINT_INTERNAL_H

Externals/ode/ode/src/error.cpp

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

8383
#ifndef WIN32
84+
#include <stdlib.h>
8485

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

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 <cmath>
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 = std::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)