Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CCD doesn't work with collisionGroups ? #359

Open
ramirofages opened this issue Aug 31, 2020 · 1 comment
Open

CCD doesn't work with collisionGroups ? #359

ramirofages opened this issue Aug 31, 2020 · 1 comment

Comments

@ramirofages
Copy link

ramirofages commented Aug 31, 2020

Hello, I found this weird issue with the following configuration:

I have a few balls bouncing around in a contained square (the container is made up of 4 planes) like so:

// BALL BODY CREATION
let collision_groups = {
      BALL: Math.pow(2,0),
      WALL: Math.pow(2,1)
}
let ball_body = new p2.Body({
        mass: 1,
        ccdSpeedThreshold: 0,
        damping: 0,
        angularDamping: 0,
        type : p2.Body.DYNAMIC,
        allowSleep: false
      });

ball_body.addShape(new p2.Circle({ 
        radius: 0.5, 
        collisionGroup: collision_groups.BALL,
        collisionMask: collision_groups.WALL 
      }));
//#################
//#################
// WALL BODY CREATION
let wall_body = new p2.Body({
      mass: 0, 
      position: [x,y],
      angle: THREE.Math.degToRad(rotation) // I use this and the position to put the planes in a square-like shape
    });

wall_body .addShape(new p2.Plane({
      collisionGroup: collision_groups.WALL,
      collisionMask: collision_groups.BALL
      }));

//####################
//####################
// WORLD CREATION
    let world = new p2.World({
        gravity:[0, 0],
        applyDamping : false,
        applyGravity: false
    });
    world.setGlobalStiffness(1e18)
    world.defaultContactMaterial.frictionStiffness = 1e18;
    world.defaultContactMaterial.restitution = 1;
    world.defaultContactMaterial.friction = 0;

I then fire a few balls that go very fast, and when the balls intersect each other, they get stuck between said balls. And the weird thing is that I set my collision masks explicitly to avoid having balls colliding with each other :/
They bounce around fine against the walls, so no problems there.
Then if I remove the line 'ccdSpeedThreshold: 0' to disable CCD, they work fine, and the balls don't get stuck anymore when they collide with each other. Am I missing something? I would upload a test case but unfortunately I have this integrated with a complex system running threejs for the visualization... but here is a screenshot with the balls stuck:
imagen

@visarunas
Copy link

I think this is related to #347 , I am experiencing something similar. Did you find a fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants