Ccd usage

Hey I got a problem with the collision detection of my foosball simulator. Sometimes when a rod is turned very fast the poppet won’t hit the ball. There are a few things that I tried:

Setting the accuracy of bulletAppState. -> This works if I set the accuracy to (1f / 300f+). However this also makes the physics of the ball way too fast (so if you give a very small touch to the ball, it flies away with approx 80km/h while it should be less than 5km/h).

Setting the CcdMotionThreshold and the CcdSweptSphereRadius on the ball as well as on the players. However I’m not sure what values I should add to them. The motion threshold probably should be as low as possible (the lower the better the quality) so I got that at 0.0001f for both the players and the ball, but my biggest problem is the sweptSphereRadius. Should this be as big as the mesh? The bigger the better? Or the smaller the better?

Thanks in advance,
Marco

1 Like

Do you use eclipse or why don’t you have the javadoc available?
From setCcdMotionThreshold:

Sets the amount of motion that has to happen in one physics tick to trigger the continuous motion detection This avoids the problem of fast objects moving through other objects, set to zero to disable (default) Parameters:
The radius is just the radius of the sphere that is swept to do this check, so make it so large that it resembles your object.
1 Like

No I’m using the RC2 version (which possibly makes use of NetBeans), with JDK 1.6. I can see the JavaDoc of setCcdMotionThreshold but the JavaDoc of setCcdSweptSphereRadius is empty for some reason (not even giving me a “JavaDoc not found” error).

However the problem still persists after adding/changing the CcdSweptSphereRadius. Any other idea’s? At the moment this is more or less what I’ve done:

  • Added each player to different rod-nodes (each node resembles a different rod of the foosballtable).
  • Added dynamicMeshShape to the rod-nodes and made them kinematic (movement is done by mouse or a custom foosball-table-controller). Next to that each rod has the following variables:
    setCcdMotionThreshold(0.0001f);
    setCcdSweptSphereRadius(12f); //12f is the length of the rod
    setRestitution(.1f);
    setSleepingThresholds(0f, 0f);
  • Added sphereCollisionShape to the ball. The ball has the following variables:
    this.setCcdSweptSphereRadius(.18f); //Same radius as the ball it’sself
    this.setRestitution(.3f);
    this.setSleepingThresholds(0f, 0f);
    this.setDamping(.15f, .2f);
    this.setCcdMotionThreshold(0.0001f);

The strange thing imo is just that when I read docs and stuff on the internet, it tells me this problem shouldn’t happen, however… It does :frowning:

Do you use eclipse or why don’t you have the javadoc available?

Actually the javadoc works perfectly fine with eclipse.

Actually the javadoc works perfectly fine with eclipse.
Sure it does but most people who use Eclipse with jME and post here don't know how to embed the javadoc ^^
this.setCcdSweptSphereRadius(.18f);

I’m just speculating since I haven’t really worked with this but maybe there is some precision loss with a small radius. I seem to recall bullet recommending sticking to objects around 1.0f in size. Although 0.18f isn’t freakishly small so maybe I’m just blowing smoke.

1 Like
I’m just speculating since I haven’t really worked with this but maybe there is some precision loss with a small radius. I seem to recall bullet recommending sticking to objects around 1.0f in size. Although 0.18f isn’t freakishly small so maybe I’m just blowing smoke.

Hmm interesting… I’ve also been wondering about if that could be a possibility or not. Although I couldn’t really think of a reason why a scene with scaled-down-objects would have problems, which the exact same scene but without scaled-down-objects wouldn’t have… Truth is: All of my objects (apart from dynamically created objects) are at or around a scale of 0.05f.

I’ll try to make my objects bigger and see if that helps. Only problem is that I’m also doing hard-coded checks which also have to be “re-scaled” and I don’t have a lot more time left for this project. Anyway thanks for the input, if I notice any difference I’ll definetly post it!

1 = 1m, what kind of objects are those?

1 = 1m, what kind of objects are those?

.obj 3D-objects, exported with 3DS-Max and imported with the jME3 model importer. For instance I got a foosball-table model, which is after the scale-down approx 15f long, 8f wide and 5f high. But I’m also having this problem with planes I use for making static walls collide with the ball, for these I use quads and add RigidBodyControl(0f) to them.

Although I couldn’t really think of a reason why a scene with scaled-down-objects would have problems, which the exact same scene but without scaled-down-objects wouldn’t have.

Again, just speculation from my side, but, it isn’t that hard to imagine that scale plays a part. Bullet interpolates a lot of forces 60 times a second. If you begin with cutting precision to second decimal to start with it leaves less room for precision in fractional interpolations.

Yeah, try dropping a marble or a 10m diameter glass ball and check if it looks the same if you just move the cam further away :wink: Speeding up/slowing down time or adapting gravity can remedy the issues that come with that though. And note that FPS players apparently need to feel almost double “real” gravity on their player to not feel like “on the moon”. I guess its because those FPS characters jump friggin’ high in real world terms ^^

Speeding up/slowing down time or adapting gravity can remedy the issues that come with that though

That’s exactly what I did to make it look realistic again :slight_smile:

btw does it matter that the player’s aren’t moving to shoot the ball but only rotating, or in other words does the setCcdSweptSphereRadius / setCcdMotionThreshold also have effect on rotation and not only on movement? I can imagine that if I have a rectangle, and rotate it around the center the sphereRadius doesn’t have any effect at all…

EDIT: Oh and Normen in addition to your previous post, I think neither the marble nor the glass ball would fall through the floor but it will collide with it xD

EDIT2: The name is Normen and not Norman =)

What the ccd does is simple: Each time the object moves more than (motionThreshold) within one frame a sphere of radius (sweptSphereRadius) is swept from the first position of the object to the position in the next frame to check if there was any objects in between that were missed because the object moved too fast. There is some bugs in jbullet with sweeping and ccd as well so there might be some specialties, you might want to check back with native bullet (which is in a general alpha state so might have other issues) if your problem is consistent.

Edit: About the scale thing: Bullet is more or less made for the 1m = 1unit scale. If you go grossly above or below that you might generate values within the system that are reaching the accuracy limits and/or get out of proportion with some of the default values in the system.

2 Likes

Cool, thanks!

I still was in doubt in what values to setup, but I found this:
http://www.bulletphysics.org/mediawiki-1.5.8/index.php/Anti_tunneling_by_Motion_Clamping
it says the swept sphere must be smaller

basically, I am using
setCcdMotionThreshold(radius*2f); //so it is the dimension for movement of the real sphere
setCcdSweptSphereRadius(radius/2f); //half the radius, so the actual swept sphere dimension will be about half the real sphere size