favreau / bullet

Automatically exported from code.google.com/p/bullet
0 stars 0 forks source link

Implement soft body deactivation #439

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

Currently, soft bodies always stay active and take CPU time.

We need to add (de)activation code.

Original issue reported on code.google.com by erwin.coumans on 6 Oct 2010 at 11:51

GoogleCodeExporter commented 9 years ago
In the meanwhile, it would be useful to have manual deactivation, need to check 
how we can implement this easiest.

Original comment by erwin.coumans on 6 Oct 2010 at 11:53

GoogleCodeExporter commented 9 years ago
Has anyone looked into this issue yet ?
We have scenes, with thousands of soft bodies, and deactivation
would be very useful :)

If noone has looked into it, I will when I get back after the xmas break.

Original comment by francois...@gmail.com on 19 Dec 2010 at 8:01

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Latest Bullet trunk has the option to manually de-activate a softbody, by 
calling

body->forceActivationState(ISLAND_SLEEPING);

Such deactivated softbody will take no CPU time.

Still, such manually de-activated softbody doesn't activate anymore, so we need 
code to automaticall activate and de-activate softbodies.

Help is appreciated!

Original comment by erwin.coumans on 22 Dec 2010 at 12:10

GoogleCodeExporter commented 9 years ago
ok, I will take a look at it when I get back to work :)

I already added functions in my cut of bullet, so evaluate velocities, etc
some of that stuff would be useful to know if the body should be sleeping.

Original comment by majestik...@gmail.com on 22 Dec 2010 at 1:36

GoogleCodeExporter commented 9 years ago
Hi Erwin,

I implemented the automatic activation/ deactivation for the soft bodies 
and it works pretty well, going from 20ms step to 1ms for ~300 soft 
bodie in maya.

I implemented it using a new member in btSoftBody called 
m_maxVertexVelocityLength2
which is the maximum velocity of a vertex from the soft body, I calculate it 
every step (if needed) and store it, then just compare this with the sleeping
threshold to know if we need to sleep which seems to work pretty well, with very
little overhead.
For the reactivation, I added a check in the collision algorithm, and if 
the softbody is sleeping , I wake it up before actually processing the
collision.

It alls seems to work pretty well, although am not sure of one part of the patch
which is in btDefaultSoftBodySolver.cpp, I deactivated the calls to
integrateMotion,solveConstraints and predictMotion.
Am not sure if it's the best thing to be done there or later in the calls 
themselves.

I attached a patch so you can look at it .

Cheers
Francois Sugny

Original comment by majestik...@gmail.com on 5 Jan 2011 at 7:41

Attachments:

GoogleCodeExporter commented 9 years ago
Forgot to add a couple of functions on the softBody :

  /* Set the sleeping threshold               */
  void        setSleepingThreshold(btScalar threshold) { m_sleepingThreshold = threshold; }
  /* Get the sleeping threshold               */
  btScalar    getSleepingThreshold() { return m_sleepingThreshold; }

Original comment by majestik...@gmail.com on 5 Jan 2011 at 9:51

GoogleCodeExporter commented 9 years ago
see https://github.com/bulletphysics/bullet3/issues/147

Original comment by erwin.coumans on 30 Mar 2014 at 7:47