[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
Chipmunk Physics • View topic - Breaking joints/constraints and magnet effect?

Breaking joints/constraints and magnet effect?

Official forum for the .

Breaking joints/constraints and magnet effect?

Postby rfkrakora » Tue Oct 26, 2010 6:40 pm

Hello,

I want some objects ( bodies & shapes ) to be dragged around with the mouse, then stick to a wall, then be able to be pulled from the wall with the mouse ( this is on iPhone ).

I have the mouse as a body that touches another body and I connect a joint between them and pull it around. Works fine. I also have a wall that I connect a joint between the body I am dragging and the wall when the body touches it ( also works fine - other than the body sometimes slightly shakes while it is connected to the wall ). I was thinking if my maxForce of the mouse body was greater than that of the joint, that the joint would break when the mouse grabs it again and pulls it away, but it doesn't. Am I not correct? I searched some throughout the day today but didn't find anything, but maybe I am using the wrong search terms. ( break joint/constraint ).

I can solve this by adding code to change the object being attached to the wall to static ( then it won't bounce ) and adding grab logic to change it back and remove the constraint when the mouse touches it. But I thought I had read somewhere that Chipmunk had breakable joints ( also I see functions for it - although commented out in SpaceManager.mm ). Anything chipmunk can do for me on the bouncing shapes ( when attached ) as well?

Regards,
rfkrakora
rfkrakora
 
Posts: 12
Joined: Mon Jun 29, 2009 10:53 pm

Re: Breaking joints/constraints and magnet effect?

Postby slembcke » Wed Oct 27, 2010 8:44 am

Chipmunk used to have support for breakable joints, but the API was pretty badly broken for them. They leaked memory and had no sort of callback API to let you know when a joint was broken.

In 5.3.2, you can get the impulse a particular joint applied on the previous step using cpConstraintGetImpulse(). Divide the impulse by the timestep you passed to cpSpaceStep() to convert it to a force. You can use this to test if the joint should break.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Breaking joints/constraints and magnet effect?

Postby hode » Fri Nov 26, 2010 5:45 pm

Why does cpConstraintGetImpulse return a float? Isn't an impulse defined with a cpVect?
hode
 
Posts: 1
Joined: Fri Nov 26, 2010 5:43 pm

Re: Breaking joints/constraints and magnet effect?

Postby slembcke » Sat Nov 27, 2010 12:09 am

It's not consistently possible to get a vector impulse back from all of the joints. It doesn't make sense with the rotary constraints for instance.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Breaking joints/constraints and magnet effect?

Postby rfkrakora » Sun Nov 28, 2010 1:32 am

Thanks for the replies.

What I ended up doing was when I touched the shape again ( after it is hanging on the wall ) I find and remove all existing constraints on that body. Then I connect the mouse constraint and can pull the body around again. Seems to work well. I like the idea of using cpConstraintGetImpulse and may come back to it ( I may have to ), but it seemed a little more intimidating right now. :)

Regards,
Randy
rfkrakora
 
Posts: 12
Joined: Mon Jun 29, 2009 10:53 pm

Re: Breaking joints/constraints and magnet effect?

Postby rfkrakora » Sun Nov 28, 2010 7:30 pm

I did try to use cpConstraintGetImpulse(), because now it looks like it will be easier to keep a list of constraints that may need to be broken and break them if necessary. Keeps me from having to iterate over all constraints and comparing them to ones I want to keep ( mouse, motors, etc. ).

But, I couldn't see any change in the return values from cpConstraintGetImpulse(). I printed values for the mouse constraint and the pivot constraint, both on the same body and the mouse seemed to increase as I pulled away, but the other constraint ( the one I am interested in breaking ) stayed constant. One difference is the other constraint is connected to a STATIC body. Maybe I am not sampling it properly? I added calls to cpConstraintGetImpulse() in my mouse move method.

I tried changing the maxForce of the mouse and joint constraints, but nothing seemed to make a difference. I'm not sure what maxBias and biasCoef are?

Here's specs on the mouse joint:

_mouseConstraint->maxForce = 30000.0f;
_mouseConstraint->maxBias = 1000.0f;
_mouseConstraint->biasCoef = 0.52f;

Here's some specs on the joint I want to break at some point:

joint->maxForce = 10000.0f;
joint->maxBias = 1000.0f;
joint->biasCoef = 0.52f;

Regards,
Randy
rfkrakora
 
Posts: 12
Joined: Mon Jun 29, 2009 10:53 pm

Re: Breaking joints/constraints and magnet effect?

Postby slembcke » Mon Nov 29, 2010 1:08 pm

maxBias and biasCoef are explained in the "Error correction by feeback" section here: http://files.slembcke.net/chipmunk/rele ... Constraint

Your mouse constraint has a higher max force than your joint. It makes sense that it would stop climbing before the mouse value does. Also keep in mind that the impulse is not the same as the force. Constraints don't actually deal with forces directly, so they never store them. As it says in the docs, if you want to convert the impulse to a force, divide by the timestep you passed to cpSpaceStep().
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm


Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 1 guest