I am seeing weird issue using Rube with Android and completely work fine with iOS. I have a simple chain like below and output from j2b2Fixture method extracting the value from json differs in iOS and Android.
Looks like call to Value::asFloat method in Android not converting float correctly from json in jsoncpp.cpp or the json parsing is not working correctly.
Please see below code and screen below. I have also included RUBE file.
Does anyone know how to fix this issue?
Much Thanks!
I am using:
rube 1.6.0
box2d 2.3.0
cocos2d-x 3.2 c++
Android NDK r9d
Code: Select all
Rube
"chain" :
{
"vertices" :
{
"x" :
[
-0.5,
11.15591812133789,
25.68233299255371,
34.99306106567383,
40.65397644042969
],
"y" :
[
0.0,
-1.931770443916321,
2.137893199920654,
2.026164293289185,
7.202928543090820
]
}
}
iOS
cocos2d: x: -0.500000 x: 0.000000
cocos2d: x: 11.155918 y: -1.931770
cocos2d: x: 25.682333 y: 2.137893
cocos2d: x: 34.993061 y: 2.026164
cocos2d: x: 40.653976 y: 7.202929
Android
10-29 14:42:42.557: D/CCFileUtilsAndroid.cpp(25669): relative path = untitled2.json
10-29 14:42:42.557: D/cocos2d-x debug info(25669): x: -0.500000 y: 0.000000
10-29 14:42:42.557: D/cocos2d-x debug info(25669): x: 11.155918 y: -inf
10-29 14:42:42.557: D/cocos2d-x debug info(25669): x: -inf y: inf
10-29 14:42:42.557: D/cocos2d-x debug info(25669): x: inf y: 2.026164
10-29 14:42:42.557: D/cocos2d-x debug info(25669): x: 40.653976 y: 7.202929
EDITED -
Playing with this issue, if I edit the floating point precision in RUBE exported json file (see below) it works!
How can I export json file with smaller precision? Is this the correct fix?
Code: Select all
"x" :
[
-0.5,
11.15591812133789,
25.68233299255371,
34.99306106567383,
40.65397644042969
]
to
"x" :
[
-0.5,
11.155,
25.682,
34.993,
40.653
]
EDITED AGAIN -
I found the issue Reader::decodeDouble in jsoncpp.cpp not working correctly for Android. For example 'value' will be "-inf" for example below. Not sure why

Code: Select all
double value = 0;
sscanf( "25.68233299255371", "%lf", &value );
// value = -inf