Compound AddBody Function Removed?

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Danthekilla
Posts: 136
Joined: Sun Jan 17, 2010 11:35 am

Compound AddBody Function Removed?

Post by Danthekilla »

Hey does anyone have an implimentation for CompoundBody.AddBody() and RemoveBody()?

It seems to have been re-written since .15 etc... and is something that we need quite badly...

Looking over the old code it seems fairly simple how it was doing it, but the CompoundBody code is VERY different now and I can't quite get a grip on how I can impliment it.

My understanding that the CB has an internal partitioning system (quad tree?) and this would need to be rebuilt as well as the new Center Of Grav and Mass etc...


Any Ideas?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Compound AddBody Function Removed?

Post by Norbo »

For the most part, it's best to consider the CompoundShape to be immutable. Adding a completely uninvolved piece to a CompoundBody entity would mean changing the shape that the entity uses, which could be shared between multiple entities, requiring reinitialization and shape->collidable links, and so on- a very complicated situation that is avoided entirely if the shape cannot change. (Old versions 'managed' this complexity by infecting a number of other systems with compound-related logic. It was an intractable mess to maintain.)

The CompoundCollidable, on the other hand, is partially mutable. By using the CompoundHelper, a CompoundCollidable can use a subset of the shapes in a CompoundShape. If this is sufficient, then it's the fastest approach at the moment. It's fairly feature-limited at this point (splits, removals, create partial, and semi-soon 'repairs'), so it probably won't be able to do exactly what you want.

In the general case, the most direct way to add or remove pieces is to just recreate the compound. There are some optimizations that can be made if the performance turns out to be too low, but explaining how to do them would take about as long as just implementing a CompoundHelper method to do them automatically (which I might end up doing after I hunt down a nasty bug).
Post Reply