Enable/Disable Physics collisions issue r80.2

Bugs will be moved here once resolved.

Post » Tue Mar 06, 2012 4:49 pm

I've come across this issue and was wondering if it could be a bug, I've prepared a small demo, check the .capx.

Basically, if 2 objects are already making contact, disabling collisions won't affect them.

Anyway, here's the capx: http://dl.dropbox.com/u/1910765/bugtest.capx

As you can see, if you disable collisions when the 2 objects are already making contact, the first object will stay there instead of falling down.

Hope it helps. Thank you.Xavier2012-03-06 16:53:15
B
63
S
23
G
17
Posts: 254
Reputation: 14,342

Post » Tue Mar 06, 2012 7:42 pm

I'm not sure we can fix this - it's handled by the physics engine entirely, and it only filters collisions at the start of a touch, not during. Maybe you can work around it by applying a little impulse to the object after disabling the collision? That might make it "wake up".
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Tue Mar 06, 2012 11:51 pm

I see. I tried applying an impulse but it really needs to make a big bounce before it bypasses this, and it's too much noticeable anyway. I even tried moving the top sprite position up or down, but still it won't "let go".

The only way I can think of would be to cheat, replacing the bottom sprite with a clone without physics at the exact moment you want the top object to drop. I guess I'll do that.
B
63
S
23
G
17
Posts: 254
Reputation: 14,342

Post » Wed Mar 07, 2012 4:26 pm

[QUOTE=Xavier]The only way I can think of would be to cheat, replacing the bottom sprite with a clone without physics at the exact moment you want the top object to drop. I guess I'll do that.[/QUOTE]

Ok, actually that worked really well. If anyone is interested in an example I'll update the capx.
B
63
S
23
G
17
Posts: 254
Reputation: 14,342

Post » Fri Feb 20, 2015 8:54 pm

This bug is a result of cached contacts, and is not really a bug. Box2d does offer a way to get around this caching though. The only way to get around it in more recent versions of box2d (2.1a or later), is to filter it out during presolve. In presolve you can disable the contacts that need to be disabled at run time. Once the objects' AABB are no longer overlapping - which is not the same as isTouching in box2d, the contact will function as expected.

PreSolve and PostSolve are missing from AMS.JS in the the bindings. Consequently this can only be fixed in box2dweb.
Image
B
25
S
9
G
2
Posts: 534
Reputation: 4,653


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 1 guest