You are correct, of course... I shouldn't make posts when tired...
I've investigated further and the problem only occurs when I export files with hex representation for floats enabled. It occurs with any float custom property at any scope (world, body etc...)
There is no bug in the RUBE export. Please accept my apologies!
The error is in b2json.cpp from the sample loader. See my comment below...
Code: Select all
#define IMPLEMENT_READ_CUSTOM_PROPERTIES_FROM_JSON(b2Type)\
void b2dJson::readCustomPropertiesFromJson(b2Type* item, Json::Value value)\
{\
if ( ! item )\
return;\
if ( ! value.isMember("customProperties") )\
return;\
\
int i = 0;\
Json::Value propValue = value["customProperties"][i++];\
while ( !propValue.isNull() ) {\
string propertyName = propValue.get("name", "").asString();\
\
if ( propValue.isMember("int") ) {\
int val = propValue.get("int", 0).asInt();\
setCustomInt(item, propertyName, val);\
}\
if ( propValue.isMember("float") ) {\
//*** This is wrong.
float val = propValue.get("float", 0).asFloat();\
//*** it should be:-
float val = jsonTofloat("float", propValue);\
setCustomFloat(item, propertyName, val);\
}\
if ( propValue.isMember("string") ) {\
string val = propValue.get("string", 0).asString();\
setCustomString(item, propertyName, val);\
}\
if ( propValue.isMember("vec2") ) {\
b2Vec2 val = jsonToVec("vec2", propValue);\
setCustomVector(item, propertyName, val);\
}\
if ( propValue.isMember("bool") ) {\
bool val = propValue.get("bool", 0).asBool();\
setCustomBool(item, propertyName, val);\
}\
\
propValue = value["customProperties"][i++];\
}\
}
Many thanks once more!