Sleeping bodies not waking up when they should
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Sleeping bodies not waking up when they should
Unfortunately I've never been able to reproduce the issue. I looked around at the code a little a few months ago, but was never able to spot anything that stood out. It sounds like it's probably a real bug, but I have no idea where to start looking.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
-
- Posts: 12
- Joined: Sun Nov 06, 2011 6:17 am
- Contact:
Re: Sleeping bodies not waking up when they should
The game has been released and now I got some more time to look into the issue.
Sadly, it is happening too often, so I am in need of fixing it.
Luckily I was able to build a test level which allows me to continuously reproduce it with the click of a button.
Attached is a screenshot of the scene.
The level bottom is of cpSegmentShapeNew with a radius of 100.
The remaining objects are all non-static and cpPolyShapeNew.
To the left and right are each one pillar, on top of which a horizontal bar is sitting. And a small box sits on top of that.
Level start: The objects go to sleep, the buttet flies and lands on the horizontal bar, all objects wake up, impact is registered and the bar takes some damage.
By slight movement of the bullet some more damage is applied to the bar until after which its life is reduced to zero and the bar is remove:
cpSpaceRemoveShape
cpShapeFree
cpSpaceRemoveBody
cpBodyFree
Now one frame later all other objects return back to sleep and the small box on top suddenly is in mid-air.
If the object in mid air would be touched by anything, it would wake up and actually start dropping.
The only solution I found was to increase the space->sleepTimeThreshold from 0.5 to 2.0, however I would rather know what the problem is instead of thinking I fixed it but changing some number. Besides, I had one test level where sleepTime of 1.0 fixed it and this one needs 2.0
I would appreciate if you can help me out, maybe telling me what to check in order to find the cause of the problem.
Thank you!
Sadly, it is happening too often, so I am in need of fixing it.
Luckily I was able to build a test level which allows me to continuously reproduce it with the click of a button.
Attached is a screenshot of the scene.
The level bottom is of cpSegmentShapeNew with a radius of 100.
The remaining objects are all non-static and cpPolyShapeNew.
To the left and right are each one pillar, on top of which a horizontal bar is sitting. And a small box sits on top of that.
Level start: The objects go to sleep, the buttet flies and lands on the horizontal bar, all objects wake up, impact is registered and the bar takes some damage.
By slight movement of the bullet some more damage is applied to the bar until after which its life is reduced to zero and the bar is remove:
cpSpaceRemoveShape
cpShapeFree
cpSpaceRemoveBody
cpBodyFree
Now one frame later all other objects return back to sleep and the small box on top suddenly is in mid-air.
If the object in mid air would be touched by anything, it would wake up and actually start dropping.
The only solution I found was to increase the space->sleepTimeThreshold from 0.5 to 2.0, however I would rather know what the problem is instead of thinking I fixed it but changing some number. Besides, I had one test level where sleepTime of 1.0 fixed it and this one needs 2.0
I would appreciate if you can help me out, maybe telling me what to check in order to find the cause of the problem.
Thank you!
- Attachments
-
- bb.jpg (88.11 KiB) Viewed 7101 times
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Sleeping bodies not waking up when they should
So the speaker looking thing falls asleep immediately after the beam is removed? That gives me something to go on I guess. I'll see if I can replicate that and figure out a fix.
Off the top of my head, I think that removing a shape wakes up shapes that it's touching but doesn't reset their sleep timer. So if you remove an object on the same frame an object sitting on top of it is going to fall asleep it then it might fall asleep anyway.
Off the top of my head, I think that removing a shape wakes up shapes that it's touching but doesn't reset their sleep timer. So if you remove an object on the same frame an object sitting on top of it is going to fall asleep it then it might fall asleep anyway.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
-
- Posts: 12
- Joined: Sun Nov 06, 2011 6:17 am
- Contact:
Re: Sleeping bodies not waking up when they should
One more information about the flow.
1. I am calling cpSpaceStep (fixed step, but multiple times depending on time passed).
2. Chipmunk will call my callbacks to report contact information. They are all buffered in a list
3. After cpSpaceStep is completed, I am processing the list and in here I might remove an object.
Hence, I am not removing any objects while Chipmunk is being processed.
1. I am calling cpSpaceStep (fixed step, but multiple times depending on time passed).
2. Chipmunk will call my callbacks to report contact information. They are all buffered in a list
3. After cpSpaceStep is completed, I am processing the list and in here I might remove an object.
Hence, I am not removing any objects while Chipmunk is being processed.
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Sleeping bodies not waking up when they should
Pierre. I fixed your bug in git. When calling cpBodyActivate() it also resets the idle timers of any bodies touching the activated body. That way an object that has the object underneath it removed can't fall asleep the next frame before it's velocity is updated at least once.
Unfortunately I still don't know what causes the OP's issue.
Unfortunately I still don't know what causes the OP's issue.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
-
- Posts: 12
- Joined: Sun Nov 06, 2011 6:17 am
- Contact:
Re: Sleeping bodies not waking up when they should
Thank you! I will check it out soon.
-
- Posts: 12
- Joined: Sun Nov 06, 2011 6:17 am
- Contact:
Re: Sleeping bodies not waking up when they should
This spam above actually reminded me to post again.
I tried the latest version and sure enough the issue has been resolved.
Further we found no other new issues introduced and so far everything runs "stable".
Thank you!!
I tried the latest version and sure enough the issue has been resolved.
Further we found no other new issues introduced and so far everything runs "stable".
Thank you!!
Who is online
Users browsing this forum: No registered users and 1 guest