This project has moved and is read-only. For the latest updates, please go here.

Constructing a Body without a World

Topics: Developer Forum, User Forum
Feb 12, 2011 at 2:07 AM

Hey guys, I'm finally making the transition from 2.x to 3.x and I'm wondering if you are ever likely to support the construction of a Body without a World?

My editor, content pipeline, and runtime types are all set up and ready to go, but they get loaded and instantiated in bulk and 'stream' in/out of the world as I require. If you don't plan this, that's fine, I can make the changes required; I'm just curious is all.

Feb 12, 2011 at 2:12 AM
Edited Feb 12, 2011 at 2:13 AM

As it is now, a body is not able to exists without a World. I would recommend you created definition classes that contains the properties of the bodies and then createe the bodies from that class when you need them. Just like Box2D does it.

To answer your question: It is unlikely that it will be implemented as the engine needs to stay close to Box2D for upgrading reasons.

Feb 12, 2011 at 2:21 AM

Thanks for the quick answer, I thought that might be the case.

I do essentially have definition classes, but in order to avoid allocations I want to prime the bodies/fixtures/shapes/joints and then just add them when I need them. If I can't have these without a World, could the 'Enabled' property on Body/Joint be a similar way of doing this do you think?

Feb 12, 2011 at 2:24 AM

Note that FPE 3.x no longer uses signed distance field as the narrow phase. It is very cheap to create bodies.

You could do the same thing with the Enabled property. Try it out and see if it fits your needs.

Feb 12, 2011 at 2:27 AM

Cheap, perhaps. But it will still be allocating, and my goal is zero allocations :)

I'll give it a go, thanks again.