Need to speed up creation of fixtures

Topics: Developer Forum
Jan 24, 2013 at 8:11 AM

Hi!

Is there anyway to speed up creation of body+fixture when using FixtureFactory.AttachCompoundPolygon? I have a lot of fixtures (100-200) and the game performs well so it's not a performance issue while running. Generation time of 100 objects takes about 30 seconds and each object can take up to 100 ms to generate.

The problem is that I need to generate them at runtime within the game, 100 ms is to long since it will cause dropped frames.

Is there a way to thread this so I can create objects on another thread or simply create the objects faster?

I'm happy to add more info to this if required.

 

// AnkMannen

Jan 28, 2013 at 10:54 AM

It seems to be the positioning of objects that take most of the time. (Body.Position). Is there a faster way to do this if I for certain know that it will not collide with anything at repositioning?

Coordinator
Jan 29, 2013 at 2:00 AM

Try using Body.SetTransformIgnoreContacts() instead of Body.Position.

Jan 29, 2013 at 7:21 AM

Hi!

It did speed up a little bit. However, what is taking 95% of the CPU is InsertLeaf(...) while creating the fixtures. I know exactly what my structure looks like at the time of creation. Is there anyway (theoretically) to generate the aabb-tree faster, like say from a template? I feels like the reordering of leaf nodes is taking a lot of CPU. I'm just speculating since I'm not very good at dynamic trees. What I would like is just a comment to ensure that I'm looking into the thing.

Up to 100 fixtures generates in less than 10 ms. Then it's an exponentional function from that on.

Thanks

AnkMannen