Bullet version

What Bullet version is used in jME3 ?

and does jME3 has rolling friction ?

How do i use it ?



I saw many posts with date of 1 or more years ago, i believe they are irrelevant.



Tnx,

Vertilka

What is rolling friction? Rolling spheres and vehicles both have friction, yeah. It uses jbullet, thats somewhere in between 2.74 and 2.76 afaik. The native version uses 2.79 but its not stable yet, still the API is same for both, you can replace one with the other later.

Also if you self compile nativ you can use the bullet svn version, without to much problems.

@normen said: What is rolling friction? Rolling spheres and vehicles both have friction, yeah. It uses jbullet, thats somewhere in between 2.74 and 2.76 afaik. The native version uses 2.79 but its not stable yet, still the API is same for both, you can replace one with the other later.

Hello Norman,

could you give me an advice where to get the source code of the used jBullet? So far I only found the version 2.72 here, but there are some necessary methods missing (e.g. DiscreteDynamicsWorld.setPreTickCallback).
I believe there is a bug in the class RaycastVehicle, causing the vehicle to jitter at braking. (There is actually used the value of braking force instead of braking impulse, which should be significantly smaller.) I’d like to try changing it and see the difference in the JME3 behavior. It behaves much better in jBullet Vehicle example.

http://jbullet-jme.googlecode.com/svn/branches/jbullet/

The braking bug is in the c++ one too, the problem is that the force is not divided by the mount of wheels, leading normally to a 4 time to high value for an average vehicle.

You can look this up in the native bullet forums there were some posts about it.

Norman: Thanks a lot, it works like a charm!

Empire Phoenix: I haven’t read those discussions yet, but my fix seems to be working well. Could you give me a link to those topics, please? I’m very curious about the discussion there…

http://code.google.com/p/bullet/issues/detail?id=654
http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=8473

Is this the same issue? Cause then it would be great if you could bump their thread and if possible suggest a fix. This would help a great deal of people. :slight_smile:

Sorry about the late response…

Yes, those are the same issues.
You were right, ‘Empire Phoenix’. I actually ‘fixed’ the issue by coincidence, as I was fixing another one. As first, I’ll describe the one you described:
‘gjaegy’ is right - the problem occurs in the calcRollingFriction(), specifically in ‘j1’ variable calculation:

[java]float denom0 = body0.computeImpulseDenominator(frictionPosWorld, frictionDirectionWorld);
float denom1 = body1.computeImpulseDenominator(frictionPosWorld, frictionDirectionWorld);
jacDiagABInv = relaxation / (denom0 + denom1);
j1 = -vrel * contactPoint.jacDiagABInv;[/java]

<p>I will try to explain the physical principle of an issue, as I understand it:<br>
The code above basically calculates the impulseForce, necessary to eliminate the relative motion of two objects in specific direction (vector). basically:</p>

<p>F=ma<br>
a=dv/dt<br>
I=F
dt<br>
,ie. I=v*m</p>

<p>Those denominators represent the inverse mass of objects (that is how infinitely massive object is defined: 1/infinite=0).<br>
The Impulse magnitude is probably correct, but should be applied to the vehicle body in total. But it can be applied at each wheel, which causes the oscillation - the vehicle decelerates to the negative velocity and back to positive in another timeStep.<br>
If you divide this impulse by a number of braking wheels, you basically only make a mistake when the impulse is not transmittable by the wheel (wheel not in contact with the same body or the contact is not strong enough - e.g. wheel in the air or on a slippery surface) But even though the vehicle should iteratively converge into the zero speed.</p>

<p>More sophisticated solution would be, to replace the raycastVehicle model by a model with wheels created as RigidBodies. Then you wouldn’t try to stop the vehicle against the ground, but the wheel against the vehicle and the specific contact ground(s).</p>

<p>Now about the other bug:<br>
What you are supposed to apply to the wheel, is a force. And the RaycasVehicle should use it in a form of ImpulseForce. (I=F*dt) It works as supposed for the case of engineForce, but not for the case of braking:</p>
[java]if (wheel_info.engineForce != 0f) {
rollingFriction = wheel_info.engineForce * timeStep;
} else {
float defaultRollingFrictionImpulse = 0f;
float maxImpulse = wheel_info.brake != 0f ? wheel_info.brake : defaultRollingFrictionImpulse;
WheelContactPoint contactPt = new WheelContactPoint(chassisBody, groundObject, wheel_info.raycastInfo.contactPointWS, forwardWS.getQuick(wheel), maxImpulse);
rollingFriction = calcRollingFriction(contactPt);
}[/java]
<p>it is also a reason why the maxBreakingForce is 10x smaller than maxEngineForce in VehicleDemo and though it brakes faster than accelerates. Also, with different timeStep, the braking effect would be different (higher with smaller timeStep and vice versa).</p>
So the quick fix for both the issues is:<br>

  • add ‘/getNumWheels()’ to the RaycastVehicle’s line 469:
    [java]j1 = -vrel * contactPoint.jacDiagABInv /getNumWheels();[/java]
  • add ‘* timeStep’ to line 558:
    [java]float maxImpulse = wheel_info.brake != 0f ? wheel_info.brake* timeStep : defaultRollingFrictionImpulse;[/java]

I found few topics on the native Bullet forum:
Issue 1
Issue 2

Also one topic, related to wheels, represented by RigidBodies