[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/bbcode.php on line 112: 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 - Cap Force/Velocity? (I made a PayPal donation)

Cap Force/Velocity? (I made a PayPal donation)

Official forum for the .

Cap Force/Velocity? (I made a PayPal donation)

Postby clint » Fri Jul 17, 2009 2:13 pm

Am I going to publicize my PayPal donation (confirmation # ending in 76059) in hopes of getting help on the forums? Yes, yes I am. ;)

Does anyone know how I can cap the force or velocity of objects?

I have several cpBodies (circles, specifically) being displayed in an iPhone game. You can use your fingertip to push circles out of the way (i.e., an invisible circle exists under your finger and pushes the other bodies out of the way). You can also tap directly on the circles--which are about the size of your fingertip--and drag them around.

The problem is that if you start pinching several of the circles together one of them will occasionally shoot off with a ridiculous velocity (enough to escape the bounds of the game).

I'm thinking one (perhaps not the best) simple way to fix this is to figure out how to set a max velocity or force. Is a custom velocity integration function (e.g., cpBodyUpdateVelocity()) the best way to do this? I realize that I could also modify the timestep iterations (or even the thickness of my bounding box walls) to help keep objects on the screen, but the objects would still "shoot off" at crazy speeds and look weird.

Thanks for your help!
clint
 
Posts: 11
Joined: Mon May 11, 2009 11:55 am

Re: Cap Force/Velocity? (I made a PayPal donation)

Postby slembcke » Fri Jul 17, 2009 4:03 pm

This has come up a couple times actually:
viewtopic.php?f=1&t=25
viewtopic.php?f=1&t=518
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: Cap Force/Velocity? (I made a PayPal donation)

Postby clint » Fri Jul 17, 2009 4:44 pm

Oops--sorry to be the guy who couldn't find the already-existing answer. Thanks.
clint
 
Posts: 11
Joined: Mon May 11, 2009 11:55 am

Re: Cap Force/Velocity? (I made a PayPal donation)

Postby clint » Tue Jul 21, 2009 10:17 am

Unfortunately the method suggested in those posts aren't working for me (i.e., gradually reducing, or even capping, the velocities in a custom velocity integration function). More specifically, they work with "normal" velocities but not when I "pinch" a shape using two other shapes under my fingertips.

Again, the phenomenon is something like this: you have three coins on a table, you place your thumb on a coin and your index finger on another coin, then you use them to "pinch" the third coin--which shoots out like a bullet.

Perhaps the forces from the two pinching shapes are so great that the velocity reduction gets ignored? Does Chipmunk integrate forces AFTER the custom velocity integration function executes?

Again thanks for any help or advice. I'm really scratching my head on this one...
clint
 
Posts: 11
Joined: Mon May 11, 2009 11:55 am

Re: Cap Force/Velocity? (I made a PayPal donation)

Postby slembcke » Fri Jul 24, 2009 9:29 am

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: Cap Force/Velocity? (I made a PayPal donation)

Postby jeapostrophe » Fri Jul 24, 2009 9:56 am

This happens to me too. I set up static bodies around the space and things can still get out. Shouldn't that be considered a bug? Or is a result of the iterative approximation that is unavoidable?

Any suggestions for deciding what is "too fast"? Just whatever looks right in our situation or do you have an idea of what speeds cause approximation errors?

Jay
jeapostrophe
 
Posts: 13
Joined: Thu Jul 23, 2009 7:54 am

Re: Cap Force/Velocity? (I made a PayPal donation)

Postby slembcke » Fri Jul 24, 2009 11:10 am

It's not a bug, it's a limitation because Chipmunk does not do swept collisions. This is partly for speed, partly for simplicity, and partly because swept collisions are neither easy or fun to implement.

A simple but effective trick I use it to make the edges of the world thicker. For instance, instead of just using line segments to outline the world, use line segments with a big beefy beveling radius.

If your game is simply fast paced and object are always moving fast, you probably need to be using a smaller timestep. That will help avoid missed collisions between all objects.
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: Cap Force/Velocity? (I made a PayPal donation)

Postby clint » Sun Aug 16, 2009 9:38 am

The cpvclamp() code (see above) worked like a charm. THANKS!
clint
 
Posts: 11
Joined: Mon May 11, 2009 11:55 am


Return to Chipmunk2D Physics

Who is online

Users browsing this forum: Heise IT-Markt [Crawler] and 0 guests

cron