Search found 17 matches

by Pesegato
Thu Apr 12, 2018 9:39 am
Forum: General Discussion
Topic: Strange error
Replies: 1
Views: 920

Re: Strange error

Solved, forgot to call

bp.update(body)


:lol: :lol: :lol:
by Pesegato
Wed Apr 11, 2018 11:53 am
Forum: General Discussion
Topic: Strange error
Replies: 1
Views: 920

Strange error

Hi, I've encountered a strange behavior on my test application: I add 2 square moving bodies to the BroadphaseDetector, and then run a listener to check for collisions. If the bodies are already overlapping when the application starts, the collision is correctly detected (as long as the body are ove...
by Pesegato
Mon Nov 14, 2016 3:38 am
Forum: General Discussion
Topic: How to use dyn4j for collisions without physics
Replies: 27
Views: 11974

Re: How to use dyn4j for collisions without physics

I don't use the World class therefore Body.isInContact() doesn't work :( On my game loop, I have something like: for (Enemy enemy:enemies){ for (Bullet bullet:bullets) { if (checkCollision(enemy,bullet)){ enemy.die(); bullet.remove(); } } } This means that at game level, I filter the bodies with a g...
by Pesegato
Thu Nov 10, 2016 11:42 am
Forum: General Discussion
Topic: How to use dyn4j for collisions without physics
Replies: 27
Views: 11974

Re: How to use dyn4j for collisions without physics

Thanks :) This code works, but I think is a bit convoluted in that it creates a list when I already know which bodies I'm looking for... is there a smarter way to do the same thing? public boolean checkCollision(Body a, Body b){ for (BroadphasePair<Body, BodyFixture> pair : bp.detect()) { if ((pair....
by Pesegato
Thu Nov 10, 2016 6:42 am
Forum: General Discussion
Topic: How to use dyn4j for collisions without physics
Replies: 27
Views: 11974

Re: How to use dyn4j for collisions without physics

I've noticed that sometimes bp.detect() gives me false positives (it detect a collision when the bodies are not actually colliding). How can I avoid this?
Thanks!

EDIT: mmmh... maybe I should use the NarrowPhase detector as well?
by Pesegato
Fri Nov 04, 2016 10:13 am
Forum: General Discussion
Topic: How to use dyn4j for collisions without physics
Replies: 27
Views: 11974

Re: How to use dyn4j for collisions without physics

Got it! The problem is here void updatePhysics(BroadphaseDetector bp, float tpf){ bp.update(body); } Calling broadphase.update(Body) has the side effect of readding the body to the broadphase. Basically for each cycle I'm removing then readding the body :evil: So I added this check: void updatePhysi...
by Pesegato
Fri Nov 04, 2016 5:14 am
Forum: General Discussion
Topic: How to use dyn4j for collisions without physics
Replies: 27
Views: 11974

Re: How to use dyn4j for collisions without physics

Thanks, but that didn't help. I've removed completely the world from the testcase (and pushed changes on github). https://github.com/Pesegato/MonkeySheet/blob/master/src/main/java/com/pesegato/collision/Dyn4JShapeControl.java#L66-L81 Body gets removed, fixture gets removed, but collisions are still ...
by Pesegato
Thu Nov 03, 2016 10:16 am
Forum: General Discussion
Topic: How to use dyn4j for collisions without physics
Replies: 27
Views: 11974

Re: How to use dyn4j for collisions without physics

Yes, the fixtures are removed as well. I'm using dyn4j directly, and use jMonkeyEngine as visualization only. This is the code, and can be run with gradle. https://github.com/Pesegato/MonkeySheet The executable is: com.pesegato.collision.Main The code you sent is here: https://github.com/Pesegato/Mo...
by Pesegato
Thu Nov 03, 2016 3:48 am
Forum: General Discussion
Topic: How to use dyn4j for collisions without physics
Replies: 27
Views: 11974

Re: How to use dyn4j for collisions without physics

I've debugged my code. I've seen that World.removeBody(body) is called and returns true. I can also confirm from the debugger that the body is removed from the World "bodies" arraylist. The body is no more part of the physics simulation. The total number of bodies is now 1. However, the Br...
by Pesegato
Wed Nov 02, 2016 3:55 am
Forum: General Discussion
Topic: How to use dyn4j for collisions without physics
Replies: 27
Views: 11974

Re: How to use dyn4j for collisions without physics

The collisions go on forever, as if the body wasn't removed at all.

Go to advanced search