Nonlinear effects and vector decomposition.
Posted: Sun Aug 13, 2006 5:16 pm
I've talked breifly via email with Erwin over this one - he's been very helpful - but I thought I should probably bring it to the forum for wider comment.
I have a really simple system comprising one large cuboid 'world' (500x10x500 units) and a 1x1x1 cube that's sliding along the top surface - propelled by impulses and using code broadly 'lifted' from the CcdPhysicsDemo demo program. (My application is actually vastly more complex than this - but this is what I boiled it down to in an attempt to isolate a much deeper problem).
If I hit the cube with an impulse directly along the X axis, it slides along for a while, slowing down due to friction - and then stops entirely when it's moving slower than some magic threshold. Great!
If I hit the cube with an impulse along a vector like maybe (0.9, 0, 0.1), the cube initially slides off at a slight angle to the X axis (as you'd expect) - but as it slows down it abruptly changes direction so that it's moving parallel to the X axis. I deduced (and Erwin confirms) that this is because bullet is essentially doing the frictional calculations completely independently in the X and Z directions. When the motion slows down sufficiently, the frictional forces bring the object to a complete halt - but because the calculation is being done independantly along each axis, the slower Z-direction motion is halted before the X-direction motion - so the object changes direction.
Not good!
Mathematically, you can only decompose motion into X, Y and Z axes and treat them separately if the motion is driven by linear functions of speed. Neither friction nor drag are linear functions of speed - so what bullet is doing is wrong. Erwin tells me that this is a fairly common approximation - but I've played with several other physics packages and have not seen this kind of effect before - so perhaps something is just making it more obvious here.
In my case, I want to push the cube along fairly slowly - and the effect of this problem is that the cube can only be pushed either directly parallel to the axes - or at angles close to 45 degrees to the axes where the speeds are roughly the same in both directions. It is evident that at these speeds, this 'approximation' has grown big pointy teeth and turned into a big black hairy bug. All of which makes bullet pretty much unusable for my application (which is seriously annoying because I just spent about 2 weeks learning bullet and integrating it into my application so I could get to the point of finding this out!)
OK - so I need to fix this (or better still, I need to get someone else to fix it for me!) - can someone point me in the direction of the code that does this stuff - and/or suggest the measures I need to take?
Er - oh yes: I'm using SuSE 9.3 Linux on a vanilla 32 bit PC - both bullet 1.8d and 1.9 exhibit the problem.
Thanks in advance.
Steve.
I have a really simple system comprising one large cuboid 'world' (500x10x500 units) and a 1x1x1 cube that's sliding along the top surface - propelled by impulses and using code broadly 'lifted' from the CcdPhysicsDemo demo program. (My application is actually vastly more complex than this - but this is what I boiled it down to in an attempt to isolate a much deeper problem).
If I hit the cube with an impulse directly along the X axis, it slides along for a while, slowing down due to friction - and then stops entirely when it's moving slower than some magic threshold. Great!
If I hit the cube with an impulse along a vector like maybe (0.9, 0, 0.1), the cube initially slides off at a slight angle to the X axis (as you'd expect) - but as it slows down it abruptly changes direction so that it's moving parallel to the X axis. I deduced (and Erwin confirms) that this is because bullet is essentially doing the frictional calculations completely independently in the X and Z directions. When the motion slows down sufficiently, the frictional forces bring the object to a complete halt - but because the calculation is being done independantly along each axis, the slower Z-direction motion is halted before the X-direction motion - so the object changes direction.
Not good!
Mathematically, you can only decompose motion into X, Y and Z axes and treat them separately if the motion is driven by linear functions of speed. Neither friction nor drag are linear functions of speed - so what bullet is doing is wrong. Erwin tells me that this is a fairly common approximation - but I've played with several other physics packages and have not seen this kind of effect before - so perhaps something is just making it more obvious here.
In my case, I want to push the cube along fairly slowly - and the effect of this problem is that the cube can only be pushed either directly parallel to the axes - or at angles close to 45 degrees to the axes where the speeds are roughly the same in both directions. It is evident that at these speeds, this 'approximation' has grown big pointy teeth and turned into a big black hairy bug. All of which makes bullet pretty much unusable for my application (which is seriously annoying because I just spent about 2 weeks learning bullet and integrating it into my application so I could get to the point of finding this out!)
OK - so I need to fix this (or better still, I need to get someone else to fix it for me!) - can someone point me in the direction of the code that does this stuff - and/or suggest the measures I need to take?
Er - oh yes: I'm using SuSE 9.3 Linux on a vanilla 32 bit PC - both bullet 1.8d and 1.9 exhibit the problem.
Thanks in advance.
Steve.