Breakable Joints with new Trunk

Official forum for the Chipmunk Physics Library.

Breakable Joints with new Trunk

Postby dieterweb on Thu Dec 03, 2009 5:21 pm

Hi,

I just saw that you removed the breakable joints from the TRUNK code. Is there a new mechanism for that?

Thomas
Visit our game Blog: http://zombiesmash.gamedrs.com or follow us on twitter: http://twitter.com/zombiesmash
dieterweb
 
Posts: 116
Joined: Fri Feb 27, 2009 7:12 am
Location: Germany

Re: Breakable Joints with new Trunk

Postby dieterweb on Thu Dec 03, 2009 6:23 pm

Ok I add another problem to this thread:

I am currently trying to make the transition to the current trunk code.
I register a postStep collision callback. I use cpArbiterIsFirstContact to check if the collision is new, but it never returns TRUE.

Thomas
Visit our game Blog: http://zombiesmash.gamedrs.com or follow us on twitter: http://twitter.com/zombiesmash
dieterweb
 
Posts: 116
Joined: Fri Feb 27, 2009 7:12 am
Location: Germany

Re: Breakable Joints with new Trunk

Postby slembcke on Thu Dec 03, 2009 6:42 pm

Uh oh. I was hoping that nobody noticed and nobody was using them. :oops: I had meant to remove them a long long time ago and had simply forgotten they were still in there. Unfortunately they never really worked correctly and had memory management ownership issues. They could cause terrible crashes in the rare case too.

The easy short term solution is to add the files back from subversion and compile them into your project. A better solution would be to iterate over the joints after cpSpaceStep() returns and check that constraint->klass.getImpulse(constraint) is not greater than the breaking force. This is the correct and safe way to do it. I could swear I had a convenient wrapper function for calling the getImpulse() function...

I had two possible long term solutions in mind. The first was going to be to have something like post solve callbacks on joints like there are on collisions. Then you could check the joint impulse and add a post step callback. I'm not quite sure if a post/pre solve callback would be useful for other than breakable joints though, so I might do something more focused on breakable joints.

Adding a focused post solve pass for breaking joints would probably be pretty easy. Though you would still need to register a callback to perform the proper memory management. Hard coding it to simply remove and free the joint without telling your game controller code would be sort of evil.
I'm the guy that wrote Chipmunk. Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 1502
Joined: Tue Aug 14, 2007 7:13 pm

Re: Breakable Joints with new Trunk

Postby slembcke on Thu Dec 03, 2009 6:44 pm

dieterweb wrote:Ok I add another problem to this thread:

I am currently trying to make the transition to the current trunk code.
I register a postStep collision callback. I use cpArbiterIsFirstContact to check if the collision is new, but it never returns TRUE.

Thomas


Hmm. I'll look into that.

edit:
The short answer is that cpArbiterIsFirstContact() can't be used in the postSolve callback. :( I never thought about that.

The long version is that it updates the timestamp on the arbiter before calling the postSolve callback. I'll have to add a flag or something to handle that so it works in postSolve too. I'll have to get back to you on that one.
I'm the guy that wrote Chipmunk. Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 1502
Joined: Tue Aug 14, 2007 7:13 pm

Re: Breakable Joints with new Trunk

Postby dieterweb on Thu Dec 03, 2009 6:58 pm

thanks again for your fast help.

I have already added my breakableJoint code back. I added the ability to call a function when the joint breaks. I will look into your saver solution to iterate over all joints.

Thomas
Visit our game Blog: http://zombiesmash.gamedrs.com or follow us on twitter: http://twitter.com/zombiesmash
dieterweb
 
Posts: 116
Joined: Fri Feb 27, 2009 7:12 am
Location: Germany

Re: Breakable Joints with new Trunk

Postby slembcke on Thu Dec 03, 2009 11:28 pm

I committed a fix for cpArbiterIsFirstContact().
I'm the guy that wrote Chipmunk. Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 1502
Joined: Tue Aug 14, 2007 7:13 pm

Re: Breakable Joints with new Trunk

Postby dieterweb on Fri Dec 04, 2009 5:41 am

great.

fix is working. I really like the new callback system. Makes my code much easier.
Visit our game Blog: http://zombiesmash.gamedrs.com or follow us on twitter: http://twitter.com/zombiesmash
dieterweb
 
Posts: 116
Joined: Fri Feb 27, 2009 7:12 am
Location: Germany

Re: Breakable Joints with new Trunk

Postby RitterGT on Sun Feb 07, 2010 5:09 pm

Sorry if this is a stupid question - I am updating code base to the 5.1 release, but when I grab with svn, the breakable joints aren't in place. Is there something else I need to do, or should those be available in the trunk?

-Ritter
RitterGT
 
Posts: 3
Joined: Mon Jul 27, 2009 3:51 pm

Re: Breakable Joints with new Trunk

Postby slembcke on Sun Feb 07, 2010 6:51 pm

Unfortunately the breakable joints never really worked right and could cause nasty crashes in the rare case. It took me a while to figure this out. It also didn't have any way to let you manage the memory. It just removed and freed the joint. You can still do breakable joints by getting the joint force from the joint after cpSpaceStep() returns. I haven't replaced the old functionality with a new API yet though.
I'm the guy that wrote Chipmunk. Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 1502
Joined: Tue Aug 14, 2007 7:13 pm


Return to Chipmunk Physics

Who is online

Users browsing this forum: Google [Bot] and 3 guests

cron