A little help with building a particle emitter

User avatar
godlike
Posts: 20
Joined: Fri Feb 19, 2010 7:09 pm

A little help with building a particle emitter

Post by godlike »

Im trying to build a particle emitter using bullet but I bumped into a few problems.

1) Every particle (rigid body) has a life. When it dies I want to deactivate it so it cannot be part of any collision/simulation calculations. Whats the best way to do that? Obviously the btRigidBody::setActivationState is not for that job.
2) If I want to make smoke that goes up what should I do? If I set the gravity manually (btRigidBody::setGravity) in the body nothing happens.
User avatar
godlike
Posts: 20
Joined: Fri Feb 19, 2010 7:09 pm

Re: A little help with building a particle emitter

Post by godlike »

Anyone? I promise I will write an article in the wiki in the end
Muller
Posts: 6
Joined: Fri Oct 16, 2009 12:20 pm

Re: A little help with building a particle emitter

Post by Muller »

Well, setGravity per object is working beautifully for me. I have a global -7.5 gravity, so most objects fall down, but some objects I set a positive gravity so they kind of float.

You need to check why setGravity isn't working.
User avatar
godlike
Posts: 20
Joined: Fri Feb 19, 2010 7:09 pm

Re: A little help with building a particle emitter

Post by godlike »

Great thanks. It looks like I was doing something wrong with the gravity. The first question remains though. How can deactivate a body?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: A little help with building a particle emitter

Post by Erwin Coumans »

There is not really a good mechanism for this.

You could try to remove the particle/body from the world, or is that too slow?

Otherwise, try using

Code: Select all

object->forceActivationState(DISABLE_SIMULATION);
to disable the particle, and to enable again:

Code: Select all

object->forceActivationState(ACTIVE_TAG);
Thanks,
Erwin
User avatar
godlike
Posts: 20
Joined: Fri Feb 19, 2010 7:09 pm

Re: A little help with building a particle emitter

Post by godlike »

Erwin Coumans wrote:There is not really a good mechanism for this.

You could try to remove the particle/body from the world, or is that too slow?

Otherwise, try using

Code: Select all

object->forceActivationState(DISABLE_SIMULATION);
to disable the particle, and to enable again:

Code: Select all

object->forceActivationState(ACTIVE_TAG);
Thanks,
Erwin
Thanks for the reply!

Generally I avoid mem allocations inside the main loop and by removing and adding in a btAlignedObjectArray the loop may become considerably slow (in some cases). I will try changing the activation state but its a nice thought to have such a feature (maybe in a future release?).

Without trying to be judgmental here is a thought on improving the API. You can put the activation states in an enum and change the type of the arguments on forceActivationState and setActivationState from int to that enum. With this way we can know what are the acceptable argument values in forceActivationState and setActivationState.