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

Particles penetrate regular bodies #121

Open
denisk20 opened this issue Mar 19, 2023 · 3 comments
Open

Particles penetrate regular bodies #121

denisk20 opened this issue Mar 19, 2023 · 3 comments

Comments

@denisk20
Copy link

denisk20 commented Mar 19, 2023

I'm using liquidfun with libgdx. I have a simple scene with some static bodies and one dynamic body of Circle shape. When particles contact the body under certain ange they penetrate it (slide beneath it). I have attached a gif which shows the issue. Is there anything that can be adjusted to mitigate this? I have tried all possible bodyDef / fixtureDef / particleDef / particleSystemDef tweaks but to no avail.
The code:

        ParticleSystemDef systemDef = new ParticleSystemDef();
        systemDef.radius = 10 * WORLD_TO_BOX;
        systemDef.dampingStrength = 0.2f;
        particleSystem = new ParticleSystem(world, systemDef);

        particleDef = new ParticleDef();
        particleDef.velocity.y = 4;
        particleDef.position.y = 6;

        BodyDef bodyDef = new BodyDef();
        bodyDef.type = BodyType.DynamicBody;
        bodyDef.position.set(1, 1);
        Body body = world.createBody(bodyDef);

        CircleShape shape = new CircleShape();
        shape.setRadius(2);

       body.createFixture(shape, 0.5f);

       ...
       particleSystem.createParticle(particleDef); // in a loop
       ...

       ...
       // in render()
       int particleIterations = particleSystem.calculateReasonableParticleIterations(Gdx.graphics.getDeltaTime());
       world.step(Gdx.graphics.getDeltaTime(), 10, 6, particleIterations);

Screen Recording 2023-03-19 at 21 20 34

@louis-langholtz
Copy link

louis-langholtz commented Mar 19, 2023

Did you try using the bullet attribute of BodyDef? I'm not seeing that in what you've described so far.

@denisk20
Copy link
Author

@louis-langholtz I actually didn't but unfortunately it doesn't make any difference. The only thing which seems to matter is the type of the body -- the issue doesn't happen for Static or Kinematic types, only for Dynamic, but changing the type is obviously not what I'm looking for.

@denisk20
Copy link
Author

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