Missing exported 'world' custom properties

Report problems here (or use the built-in feedback dialog in the editor)
Post Reply
Voptiplex
Posts: 35
Joined: Thu Nov 14, 2013 1:07 pm

Missing exported 'world' custom properties

Post by Voptiplex » Fri Dec 25, 2015 11:19 am

Hi,

I have saved a Json file with

Code: Select all

b2dJson::writeToFile(b2World* world, const char* filename)
and noticed that custom properties belonging to the world are not saved.

I therefore changed:

Code: Select all

Json::Value b2dJson::b2j(b2World* world)
{
    Json::Value customPropertyValue = writeCustomPropertiesToJson(NULL);
}

to (adding world pointer)

Json::Value b2dJson::b2j(b2World* world)
{
    Json::Value customPropertyValue = writeCustomPropertiesToJson(world);
}
and now it seems to work.

Is that change correct and are there some additional changes missing ?

Thanks,
Thomas

iforce2d
Site Admin
Posts: 860
Joined: Sat Dec 22, 2012 7:20 pm

Re: Missing exported 'world' custom properties

Post by iforce2d » Sat Dec 26, 2015 8:44 am

Perhaps I may not have mentioned it anywhere, but I have arranged it so that passing NULL as the item for the custom property to be attached to will cause it to become a 'global' custom property. I think if you try setting the property like this it should be saved correctly:

setCustomInt( NULL, "myint", 123 );

Voptiplex
Posts: 35
Joined: Thu Nov 14, 2013 1:07 pm

Re: Missing exported 'world' custom properties

Post by Voptiplex » Sat Dec 26, 2015 10:02 am

Ok, I will try passing a NULL from my SW to see if the code writes values to Json.

But I have several 'world' custom properties set in Rube which I would like to preserve in Json.
And with passing writeCustomPropertiesToJson(world) these values set in Rube get written to Json as well.

So is the intention that I have to write to Json the custom values from Rube in my software 'by hand' with
setCustomInt( NULL, "myint", 123 ); ?

Happy XMAS,
Thomas

Voptiplex
Posts: 35
Joined: Thu Nov 14, 2013 1:07 pm

Re: Missing exported 'world' custom properties

Post by Voptiplex » Sun Dec 27, 2015 5:08 pm

Hi,

I have tried passing a NULL to setCustomInt(), but then the code does not compile. The compiler complains about ambiguous function and the compiler can not decide which function to use.
If I pass a b2world pointer to setCustomInt(), and as explained above, pass a b2world pointer to writeCustomPropertiesToJson() everything works ok.

I guess I do not get how to use the functions.
As it works OK with the current code, shall I just leave it as it is ?

Thanks for your help,
Thomas

iforce2d
Site Admin
Posts: 860
Joined: Sat Dec 22, 2012 7:20 pm

Re: Missing exported 'world' custom properties

Post by iforce2d » Sun Jan 03, 2016 2:22 pm

Yeah I guess if it's working ok you should leave it :)
You might be able to pass

(b2World*)NULL

as the parameter to get around the compiler error.

Post Reply