-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Technique used in manipulation demo is insufficient to wake sleeping bodies #875
Comments
Looks like this condition at the beginning of matter-js/src/collision/Detector.js Lines 38 to 39 in 7894b4b
I changed that to the following: - if ((bodyA.isStatic || bodyA.isSleeping) && (bodyB.isStatic || bodyB.isSleeping))
+ if ((bodyA.isSleeping && bodyB.isSleeping) || (bodyA.isStatic && bodyB.isStatic)) and that was enough to allow collision events to fire between a programmatically-moved static body and a dynamic sleeping body, though it doesn't wake the sleeping body (but at that point it's easy to wake it in the collision event). It didn't seem to cause any spurious events if a body comes to rest against, say, a static floor and falls asleep, though I didn't test much more thoroughly. Happy to submit a PR if this is a desirable fix! |
Is there a final solution to this problem? Recently I developed a project with creating multiple bodies, they are not static. And after each few seconds there will be a new body(isStatic) was manipulated to hit those non-static bodies, you know, like a snooker game. But because I created a lot of bodies and they keep colliding each others,so I was thinking to improve performance by using enableSleeping, then I have the same problem that when a new body start to hit those sleeping bodies,it just stoped and overlapped on them. It seems that setting different collision filter on them. how can i solve this problem? |
Hey there, thanks for this library! I really appreciate how well-structured and documented everything is.
I saw in #532 (and in other issues) that to allow programmatically-moved bodies to wake sleeping bodies, their velocity should manually be set as well as their position. Unfortunately, it doesn't actually seem like this is sufficient. I've made a repro case here by changing the manipulation demo a bit: https://codesandbox.io/s/elegant-ellis-kihf9?file=/src/index.js
The dynamic box on top of the programmatically-moved static box should fall asleep, at which point no more collisions will happen (and it'll just hang in space). The T-shaped compound on the right will also happily pass through any sleeping bodies it collides with.
Does something else need to be done? It's not clear to me if there's any way for non-dynamic bodies to even manually disable sleeping on other bodies, since no collision events ever fire.
The text was updated successfully, but these errors were encountered: