Per-body sleep thresholds

It would be nice if you could set the linear/angular sleep threshold values on a per-body basis. I have an application that is using some ragdoll physics and it is next to impossible to get the ragdolls to sleep without increasing the sleep threshold values by a factor of 5. Given that I don't want to affect the rest of the simulation I will probably end up implementing this functionality myself in b2Island.cpp:


Code:
void b2Island::Solve(const b2TimeStep& step, const b2Vec2& gravity, bool allowSleep)
{
   ...

   if (allowSleep)
   {
      float32 minSleepTime = b2_maxFloat;

      for (int32 i = 0; i < m_bodyCount; ++i)
      {
         b2Body* b = m_bodies[i];
         if (b->GetType() == b2_staticBody)
         {
            continue;
         }

         if ((b->m_flags & b2Body::e_autoSleepFlag) == 0)
         {
            b->m_sleepTime = 0.0f;
            minSleepTime = 0.0f;
         }

         // cached as a squared value on b2Body to avoid multiplications every step.
         const float32 linTolSqr = b->GetLinearSleepToleranceSquared();
         const float32 angTolSqr = b->GetAngularSleepToleranceSquared();

         if ((b->m_flags & b2Body::e_autoSleepFlag) == 0 ||
            b->m_angularVelocity * b->m_angularVelocity > angTolSqr ||
            b2Dot(b->m_linearVelocity, b->m_linearVelocity) > linTolSqr)
         {
            b->m_sleepTime = 0.0f;
            minSleepTime = 0.0f;
         }
         else
         {
            b->m_sleepTime += step.dt;
            minSleepTime = b2Min(minSleepTime, b->m_sleepTime);
         }
      }


Are there any unforeseen issues I might run into doing this?
I think you are focusing on the wrong problem. You should be able to get your ragdolls stable enough to sleep. If you post a testbed version of your ragdoll, I can take a look. Otherwise, you can try manually increasing the rotational inertia of the limbs.
Here's a testbed version of my ragdoll code. Click anywhere to spawn a new ragdoll.

Few things to notice:

- Ragdolls never go to sleep
- There is some weird popping that happens sometimes when it seems like a joint constraint is being maxed out when a ragdoll is at "rest" on the ground-- which causes the ragdoll to shoot up into the air from a relative standstill on the ground.
- Dropping the ragdoll from a great height causes him to bounce very high off of the ground, despite zero restitution on the ground. Is there a way to mitigate this?

Also, what did you mean by increasing the rotational inertia of the limbs? Or rather, how would one do that?

Thanks!
You should sync to the latest. I fixed a bug in revolute joint recently.

Your ragdolls are sleeping for me.

Original thread: https://box2d.org/forum/viewtopic.php?t=6622