Skip to content

Commit

Permalink
Port Externals/ode on Linux by eagleivg
Browse files Browse the repository at this point in the history
  • Loading branch information
q4a committed Oct 7, 2018
1 parent 6de5f04 commit 3fab5cc
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 18 deletions.
4 changes: 4 additions & 0 deletions Externals/ode/include/ode/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
#include <ode/error.h>
#include <math.h>

#ifdef LINUX
#include <alloca.h>
#endif

#ifdef __cplusplus
extern "C" {
#endif
Expand Down
4 changes: 3 additions & 1 deletion Externals/ode/include/ode/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@

/* per-machine configuration */


#ifdef LINUX
#include <stdint.h>
#endif

#ifndef _ODE_CONFIG_H_

Expand Down
2 changes: 1 addition & 1 deletion Externals/ode/ode/src/StepJointInternal.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef STEP_JOINT_INTERNAL_H
#define STEP_JOINT_INTERNAL_H
void dInternalStepJointContact (dxWorld * world, dxBody * body[2], dReal * GI[2], dReal * GinvI[2], dxJoint * joint, dxJoint::Info1 info, dxJoint::Info2 Jinfo, dReal stepsize);
#endif STEP_JOINT_INTERNAL_H
#endif // STEP_JOINT_INTERNAL_H
1 change: 1 addition & 0 deletions Externals/ode/ode/src/error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ static void printMessage (int num, const char *msg1, const char *msg2,
// unix

#ifndef WIN32
#include <stdlib.h>

extern "C" void dError (int num, const char *msg, ...)
{
Expand Down
7 changes: 4 additions & 3 deletions Externals/ode/ode/src/odemath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <ode/common.h>
#include <ode/odemath.h>
#include <float.h>
#include <cmath>

// this may be called for vectors `a' with extremely small magnitude, for
// example the result of a cross product on two nearly perpendicular vectors.
Expand Down Expand Up @@ -51,7 +52,7 @@ void dNormalize3_slow (dVector3 a)
a2 /= aa1;
l = dRecipSqrt (a0*a0 + a2*a2 + 1);
a[0] = a0*l;
a[1] = (dReal)_copysign(l,a1);
a[1] = (dReal)std::copysign(l,a1);
a[2] = a2*l;
}
}
Expand All @@ -63,7 +64,7 @@ void dNormalize3_slow (dVector3 a)
l = dRecipSqrt (a0*a0 + a1*a1 + 1);
a[0] = a0*l;
a[1] = a1*l;
a[2] = (dReal)_copysign(l,a2);
a[2] = (dReal)std::copysign(l,a2);
}
else { // aa0 is largest
if (aa0 <= 0) {
Expand All @@ -76,7 +77,7 @@ void dNormalize3_slow (dVector3 a)
a1 /= aa0;
a2 /= aa0;
l = dRecipSqrt (a1*a1 + a2*a2 + 1);
a[0] = (dReal)_copysign(l,a0);
a[0] = (dReal)std::copysign(l,a0);
a[1] = a1*l;
a[2] = a2*l;
}
Expand Down
41 changes: 28 additions & 13 deletions Externals/ode/ode/src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@

#include "objects.h"
#include "float.h"
#if defined(LINUX)
#include <cmath>
#endif

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

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

inline bool dValid (const float x)
inline bool dValid(const float x)
{
// check for: Signaling NaN, Quiet NaN, Negative infinity ( –INF), Positive infinity (+INF), Negative denormalized, Positive denormalized
int cls = _fpclass (double(x));
if (cls&(_FPCLASS_SNAN+_FPCLASS_QNAN+_FPCLASS_NINF+_FPCLASS_PINF+_FPCLASS_ND+_FPCLASS_PD))
return false;

/* *****other cases are*****
_FPCLASS_NN Negative normalized non-zero
_FPCLASS_NZ Negative zero ( – 0)
_FPCLASS_PZ Positive 0 (+0)
_FPCLASS_PN Positive normalized non-zero
*/
return true;
#ifdef MSVC
// check for: Signaling NaN, Quiet NaN, Negative infinity (-INF), Positive infinity (+INF), Negative denormalized, Positive denormalized
int cls = _fpclass (double(x));
if (cls&(_FPCLASS_SNAN+_FPCLASS_QNAN+_FPCLASS_NINF+_FPCLASS_PINF+_FPCLASS_ND+_FPCLASS_PD))
return false;
#elif defined(LINUX)
int cls = std::fpclassify((double )x);
switch (cls)
{
case FP_NAN:
case FP_INFINITE:
case FP_SUBNORMAL:
return false;
default:
break;
}
#endif
/* *****other cases are*****
_FPCLASS_NN Negative normalized non-zero
_FPCLASS_NZ Negative zero (-0)
_FPCLASS_PZ Positive 0 (+0)
_FPCLASS_PN Positive normalized non-zero
*/
return true;
}
#endif

0 comments on commit 3fab5cc

Please sign in to comment.