how to slow down mouse interaction

Official forum for the Chipmunk2D Physics Library.
Post Reply
xjpx
Posts: 2
Joined: Wed Feb 24, 2010 7:07 am
Contact:

how to slow down mouse interaction

Post by xjpx »

Hi|! I'm, trying to make a body hanging on invisible rope connected to user's finger. Here's what i'm doing. I create a body with infinite mass and moment of inertia and don't add it to a space. I connect another body to the body with infinite mass using a pin joint or slide joint. I update position and velocity of the static body as the finger moves. When I move the finger slow around the screen everything works as i expect, but when I make fast movements the suspended object starts to spin around the finger extremely fast. In 4.1 version it did'n happen, it has started since I updated to v5.1 How can I slow it down?
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: how to slow down mouse interaction

Post by slembcke »

First of all, you need to be smoothing the mouse input. Input from the OS is always really coarse, probably running at fraction of 60Hz. Secondly, you need to limit the joint forces so that it can't just whip the attached object around with a nearly unbounded amount of force to make it exactly match what the finger body is doing.

Check out the main Chipmunk demo application. It does these things and has nice smooth mouse interaction.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
xjpx
Posts: 2
Joined: Wed Feb 24, 2010 7:07 am
Contact:

Re: how to slow down mouse interaction

Post by xjpx »

Thanks a lot for your reply! It was really helpful. The only thing that's not clear for me is how maxForce works. If the number I specify is small enough to slow the suspended body down, it responds to fast movements with a delay. Joint looks like it doesn't have constant length but stretches if the finger is moving fast. I've particulary solved this problem by smoothing touch input (using cpvlerp as in chipmunk demo ) and applying more gravity. I also set biasCoef 1. But still there's some delay. Is there a better way to do it? Did I miss something or everything is as it should be?
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: how to slow down mouse interaction

Post by slembcke »

Using a biasCoef of 1.0 can make things unstable, but a maxForce might also help to smooth that out. I guess you could try to increase the maxForce based on how fast things are moving. The issue is that it's just not realistic to allow using an infinite maxForce. Allowing the user to whip an object around the screen without any feedback simply means that they don't know when they are exceeding the limits of the system.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests