Dynamic / kinematic body switching at runtime

chris_bore
Posts: 2
Joined: Tue Jun 25, 2013 9:29 am

Dynamic / kinematic body switching at runtime

Post by chris_bore »

Hey Everyone,

As the title says, I'm trying to decide on the best way to switch from a kinematic object to dynamic object at runtime, my project is a houdini SOP plugin, so I have a load of points I feed in to my solver node with attributes that define whether a point should become active or stay as a passive kinematic body.

I have a method (kind of) working at the moment using body->setActivationState(0) function, but the problem is that this seems to get overridden if an active body is within a certain distance of the non-active body, and soon all objects become active (ignoring the active attributes from houdini). So this works when I have a sparse distribution of bodies -- but when I have a dense distribution -- ie a fractured building this doesn't work.

I also tried setting the mass to zero for inactive points then to use the body->setMassProps() function as I step through the sim, but this didn't seem to have any effect...

So is this the best way to do this? I've read that removing object from the physics world and re-adding can work too..... but are there performance issues with this? what about collision flags?

My end goal would be to have animation on the kinematic points too, so I want to choose a method that allows for this also.

I'm relatively new to the world of bullet, so any help / advice, pointers to any demos that show examples of this would be very much appreciated,

Cheers,

Chris
Adriano
Posts: 6
Joined: Fri Mar 08, 2013 9:53 am

Re: Dynamic / kinematic body switching at runtime

Post by Adriano »

I had the same Problem.

setMassProps() and Setting flags didn't updated correctly the objects.

Now I destroy and re-create all objects, setting them as dynamics or rigid bodies every time.

Performance is not a problem by me, but maybe it depends on what you want do.
chris_bore
Posts: 2
Joined: Tue Jun 25, 2013 9:29 am

Re: Dynamic / kinematic body switching at runtime

Post by chris_bore »

Hey Adriana,

Sorry for the late reply, I got this sorted, my solution was similar to your. I just check for objects changing state before I step the sim, if any thing has changed from inactive to active, I remove the body from the world and re-add it as an active body.

The next step is to have the ability to have any inactive objects take the animation form their seed point. Answers on a post card :)
Cheers,

Chris