I have found a strange problem when using Box2D on the iPhone. For reference, I am using the version that adds in b2EdgeShapes. The program runs fine with the Thumb instruction set, although a little bit slow. When I switch to ARM, the contacts between polygons and edge shapes stop working properly. As a test, I switched the b2EdgeShapes to b2Polygons using convex decomposition, and the problem persists. Basically, rectangular objects sitting on my terrain start shaking around and eventually smash all the way through the terrain.
Using the -mno-thumb compiler flag for each file rather than a global "Compile for Thumb" project setting, I have isolated the problem to the source file b2ContactSolver.cpp. I am really surprised that anything in that source file could really be dependent on the instruction set.
Random Notes:
The only change I made in Box2D when porting to the iPhone was in b2Math.h. I put in the std::isfinite line because finite did not appear to be defined.
Could there be some functions in files like b2Math.h that are used in b2ContactSolver.cpp, and no other source files? Also, I see definition checks like TARGET_FLOAT32_IS_FIXED and _MSC_VER in b2Math.h and wonder if any definitions depend on the instruction set (i.e. Thumb vs. ARM).
Edit:
This should totally have gone in the bug forum. Sorry about that.
Using the -mno-thumb compiler flag for each file rather than a global "Compile for Thumb" project setting, I have isolated the problem to the source file b2ContactSolver.cpp. I am really surprised that anything in that source file could really be dependent on the instruction set.
Random Notes:
The only change I made in Box2D when porting to the iPhone was in b2Math.h. I put in the std::isfinite line because finite did not appear to be defined.
Code:
/// This function is used to ensure that a floating point number is
/// not a NaN or infinity.
inline bool b2IsValid(float32 x)
{
#ifdef _MSC_VER
return _finite(x) != 0;
#else
// return finite(x) != 0;
return std::isfinite(x)!=0;
#endif
}
/// not a NaN or infinity.
inline bool b2IsValid(float32 x)
{
#ifdef _MSC_VER
return _finite(x) != 0;
#else
// return finite(x) != 0;
return std::isfinite(x)!=0;
#endif
}
Could there be some functions in files like b2Math.h that are used in b2ContactSolver.cpp, and no other source files? Also, I see definition checks like TARGET_FLOAT32_IS_FIXED and _MSC_VER in b2Math.h and wonder if any definitions depend on the instruction set (i.e. Thumb vs. ARM).
Edit:
This should totally have gone in the bug forum. Sorry about that.