CCD - Continuous Collision Detection

Hello,



is there a way to use CCD in jMonkeyEngine?



I'm using jME with jBullet. Bullet supports CCD, but I can't find this option in jBullet.





Best regards



Mateusz

Wow, ccd! Can you explain the difference between the jBullet-behaviour we

have and that? Or do you want to prevent PhysicsObject to 'sleep'?

ttrocha said:

Wow, ccd! Can you explain the difference between the jBullet-behaviour we
have and that? Or do you want to prevent PhysicsObject to 'sleep'?


I want to prevent following:
- ball moved over the floor can sink in it (specially with high gravity)
- ball hitting the wall can miss it (if ball move fast)
- ball hitting other ball can miss it (if balls move fast)
- ball crushing the wall can stay in it (should bounce)

Wow,… didn't know that there are this issues.



Afaik jbullet is running on internall 60 fps(!?). Maybe you have to set you fps to 60 as

well to keep it synchron!? Just guessing (actually I have no clue)

ttrocha said:

Wow,... didn't know that there are this issues.

Afaik jbullet is running on internall 60 fps(!?). Maybe you have to set you fps to 60 as
well to keep it synchron!? Just guessing (actually I have no clue)


yes,

physicsSpace.setAccuracy(1f/60 * X f);

helps, but it's neither a good nor deterministic solution.
What's worst it does not solve the 'ball in the wall' (ball crushing the wall can stay in it) problem.

…the ball is moved by the physics-engine and got stuck?

BTW: Are we talking about jME3 or jME2?

jME 2 with jBullet integration.



I add velocity to the ball to move it towards the wall:


    @Override
    protected void simpleUpdate() {
       if (physicsSpace != null) {
          physicsSpace.update(timer.getTimePerFrame());
          
           if (KeyBindingManager.getKeyBindingManager().isValidCommand("START_BALL", true)) {
              ballNode.setLinearVelocity(new Vector3f(0, 0, 500));
           }
          
       }
    }



where ballNode is:


        ballNode = new PhysicsNode(whiteBall, collisionShape, 1f);
        ballNode.setLocalTranslation(new Vector3f(0, 200, 0));
        ballNode.setName("ball");
        rootNode.attachChild(ballNode);
        ballNode.updateRenderState();
        ballNode.setDamping(0.0f, 1f);
        physicsSpace.add(ballNode);



and it can stuck in the wall:



        v1 = new Vector3f(-80, -11, -5f);
        v2 = new Vector3f(80, 10, 0);
   Box shortBound1 = new Box("short bound 1", v1, v2);

   Vector3f collisionVector = new Vector3f(v2.x, v2.y, v2.z);
   BoxCollisionShape colisionShape = new BoxCollisionShape(collisionVector);
   
   PhysicsNode shortBoundNode1 = new PhysicsNode(shortBound1, colisionShape, 0.f);
   shortBoundNode1.setName("short bound node 1");
   shortBoundNode1.setLocalTranslation(new Vector3f(0, 0, 177));
   rootNode.attachChild(shortBoundNode1);
   shortBoundNode1.updateRenderState();
   physicsSpace.add(shortBoundNode1);



The ball may miss (accuracy 1/60) or stuck into (1/6000) the wall.

As far as the bullet wiki said alst time I checked the continous collison space it said it was highly experimental, as far as I knwo newtown is the only engine supporting that currently.



Or do you mean the Maximum speed stuff? at least in jbullet there is a function for that not sure about jmejbullet

There is no CCD in jbullet. And as empire said, even in native its experimental.

I beg to differ, after poking around a bit a both the native and jbullet source.  It seems all you have to do is set your thresholds. This are done by calling the two methods setCcdSweptSphereRadius and setCcdSquareMotionThreshold on a CollisionObject which is subclassed by both GhostObject and RigidBody. http://jbullet.advel.cz/javadoc/com/bulletphysics/collision/dispatch/CollisionObject.html#setCcdSquareMotionThreshold(float) and http://jbullet.advel.cz/javadoc/com/bulletphysics/collision/dispatch/CollisionObject.html#setCcdSweptSphereRadius(float)



Looking at the CcdPhysicsDemo.cpp http://code.google.com/p/bullet/source/browse/trunk/Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp Looks like they did

      // Only do CCD if  motion in one timestep (1.f/60.f) exceeds CUBE_HALF_EXTENTS

      body->setCcdMotionThreshold( CUBE_HALF_EXTENTS );



      //Experimental: better estimation of CCD Time of Impact:

      body->setCcdSweptSphereRadius( 0.2*CUBE_HALF_EXTENTS );

to set the threshold.  Hope this helps.  Makes me wonder why they even called it Bullet if it didn’t have CCD, I thought that was the point.  :slight_smile:

Hm, I wonder if it requires enabling something in the dynamics world or some resolver, I did not have the feeling that it worked in jbullet. Maybe I did something wrong when I was testing, but I will check again and add the option if it works.



Cheers,

Normen



Edit: Added to svn, not yet sure about the results but it seems to work :wink:

CCdThreashold sets the max speed a far as c++ wiki goes…

And they named it probably because it is faster than ode wich uses the same basic mathlibrarys

Has this been added in jbullet-jme, or just jbullet?  How do you enable it?  Curious to see if this will get the PhysicsCharacterNode to stop falling through slopes.

it wonz the character is using a ghost node, as far as i know it only helps with physicnodes

Empire Phoenix said:

it wonz the character is using a ghost node, as far as i know it only helps with physicnodes

Aye, but maybe setting a ccd threshold for the surface helps..