Box2D Forums

It is currently Sat May 18, 2013 12:12 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Thu Mar 15, 2012 3:59 am 
Offline

Joined: Mon Jan 23, 2012 9:51 am
Posts: 15
Hello, and thanks in advance for your help.

I'm having a small issue with the ContactListener. I use the postSolve method to set which faces of the body are in touch (all my bodies are rectangles xD), and every gameLoop I reset those touching values to zero. So, for instance, if a bodyA is above bodyB, bodyA is touching down and bodyB is touching up.

The thing is that after a couple of steps with one body above the other, the contact events stop being fired and I can't update this touching direction variable. Funny thing is that if I move horizontally the postSolve method is called and the update is done.

What I would like to know is whether, for some kind of optimization, contact events stop being fired after some steps.


Top
 Profile  
 
PostPosted: Thu Mar 15, 2012 7:11 am 
Offline

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1515
Location: Tokyo
Perhaps the bodies are sleeping? You could SetSleepingAllowed(false) if that is the problem.


Top
 Profile  
 
PostPosted: Thu Mar 15, 2012 8:06 am 
Offline

Joined: Mon Jan 23, 2012 9:51 am
Posts: 15
Thanks for answering so quickly =)

So if sleeping is allowed, collision events stop being solved? Would it impact too much on performance if I did SetSleepingAllowed(false)?

I am at work right now, I will try it later at home and post my results.

Thanks!


Top
 Profile  
 
PostPosted: Thu Mar 15, 2012 1:05 pm 
Offline

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1515
Location: Tokyo
Right. Each group of connected bodies or 'island' can sleep when nothing is happening to it. It will awake when some external change occurs like a collision from outside or you applying impulses or something.

Unless you have a very large scene with a lot of bodies usually sleeping I don't think you'll see much change. If it's a problem, you could probably do something clever like storing the last result you got in PostSolve and returning that if the body is asleep.


Top
 Profile  
 
PostPosted: Fri Mar 16, 2012 7:40 am 
Offline

Joined: Mon Jan 23, 2012 9:51 am
Posts: 15
Thanks, this really helped me. I used your suggestion to save the state when the body is asleep.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group