[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/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/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/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/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 - Top down pivot constraint confusion

Top down pivot constraint confusion

Official forum for the .

Top down pivot constraint confusion

Postby dorthysmash » Fri Mar 11, 2011 12:43 am

dorthysmash
 
Posts: 5
Joined: Thu Mar 10, 2011 11:21 pm

Re: Top down pivot constraint confusion

Postby slembcke » Fri Mar 11, 2011 11:00 am

Wow, all of a sudden I'm getting a lot of questions about this. I guess I need to make a clearer example that explains all the magic and strangely configured joints. :-\

1) cpBodySlew() calculates a velocity so that an object will move to the desired point in the next timestep. You don't quite want that, you need a maximum speed. Pull the calculation out of cpBodySlew() and clamp it like this:
body->v = cpvclamp(cpvmult(cpvsub(desiredPosition, body->p), 1.0f/dt), maxSpeed);

I'm seriously considering removing cpBodySlew() function in the next version because it causes so much confusion for a trivial one line function.

2 & 3) You shouldn't have to no. Setting the pivot joint's biasCoef to 0.0 should cause the joint to ignore position error and only work on the velocity. The code you pasted to initialize the bodies and joint looks correct though. I'm not sure what to tell you unless you can make a patch for the tank demo to reproduce the problem. I have no idea what the problem would be.

Maybe part of the problem is just that mass of your body is so low and the maxForce is so high? In the tank demo, the mass/force ratio is 10/1000. You are using 1/10000. I guess I would try that.

4) The gear joint is only if you want rotation. If you don't want rotation, you probably want to give your body an infinite moment of inertia so that it can't rotate at all. Actually having such a low moment of inertia might be causing some of the problems here.
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: Top down pivot constraint confusion

Postby dorthysmash » Fri Mar 11, 2011 6:11 pm

I'm already thankful for all the documentation that is there. Just started doing embedded development at my job and any documentation is a God send.

I did all the things you suggested but still had no luck (still can't control the body via the control body). Basically the only change was movement seemed a little smoother and less jittery. I edited the Tank.c source to mimic what I am doing, and it looked good (moving the body via the control body). I then went back to my project, removed all the objects I had in my space and made sure I was creating the objects in the same order with same parameters as what is in the Tank.c. And waddaya know, I can now move the body via the control body.

Hopefully tonight or tomorrow, I will start slowly piecing all of my stuff back together and try to figure out where I went wrong. I'll post an update when I actually know something.

Thanks for the quick response!
dorthysmash
 
Posts: 5
Joined: Thu Mar 10, 2011 11:21 pm

Re: Top down pivot constraint confusion

Postby slembcke » Fri Mar 11, 2011 7:50 pm

Is it possible that you were using the position of the control body instead of the normal body to draw stuff?
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: Top down pivot constraint confusion

Postby markhula » Sat Mar 12, 2011 10:39 am

Hey Scott,

Remove cpBodySlew because *everyone* tries to use it to 'force' things in place.
it causes all kinds of issues and it's not really required anymore.

Bin it :-)
markhula
 
Posts: 188
Joined: Wed Feb 02, 2011 4:23 am

Re: Top down pivot constraint confusion

Postby dorthysmash » Sun Mar 13, 2011 12:41 am

dorthysmash
 
Posts: 5
Joined: Thu Mar 10, 2011 11:21 pm

Re: Top down pivot constraint confusion

Postby slembcke » Sun Mar 13, 2011 3:38 pm

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: Top down pivot constraint confusion

Postby slembcke » Sun Mar 13, 2011 3:54 pm

Being obsessive compulsive sometimes, I had to test this one out. It does overshoot by a little bit because Chipmunk (like every other rigid body physics library) is using euler integration. Now that I think about it, I came up with probably this exact same equation for the flight control computer in the Solaro game we have been making. I know I fixed the euler issue there... I'll see if I can find the code buried in the project somewhere.

Multiplying maxStoppingSpeed by like 0.9 will probably work just as well if you aren't obsessive compulsive. It will keep it from overshooting, but will cause the object to arrive some small fraction of a second second late to the stopping point.
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: Top down pivot constraint confusion

Postby dorthysmash » Sun Mar 13, 2011 4:07 pm

dorthysmash
 
Posts: 5
Joined: Thu Mar 10, 2011 11:21 pm

Re: Top down pivot constraint confusion

Postby slembcke » Sun Mar 13, 2011 4:46 pm

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

Next

Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 5 guests

cron