How to disable affection of a body's velocity in collision?

Official forum for the Chipmunk2D Physics Library.

How to disable affection of a body's velocity in collision?

Postby fanhe » Tue Feb 15, 2011 9:35 pm

A body with infinity mass and infinity moment of inertia and 100 velocity collide with a normal ball.
I do not want the infinity body's velocity affect the normal ball, what should I do?
Thanks.
fanhe
 
Posts: 6
Joined: Fri Jan 07, 2011 4:26 am

Re: How to disable affection of a body's velocity in collision?

Postby slembcke » Wed Feb 16, 2011 9:02 am

If you just want them to pass through each other, use the layers or group properties of their shapes to filter out the collision. You can also reject the collision from the begin or pre-solve collision callbacks.
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: How to disable affection of a body's velocity in collision?

Postby fanhe » Wed Feb 16, 2011 10:01 pm

Just hold that question.
I have a new question
what is the role v_bias and w_bias?

A ball body just add to space(has some static shapes) once which never destroy until application quit. I want to predict the movement of the ball.
I just did these every round.
Code: Select all
    cpBodyResetForces(pBall);
    cpBodySetPos(pBall, vect);
    cpBodySetVel(pBall, cpvzero);
    cpBodySetAngle(pBall, 0.0);
    cpBodySetAngVel(pBall, 0.0);

but it seemed to be different every round, and I found v_bias was not cpvzero since second round.
How can I make the movement of the ball the same after I set the same original position, zero velocity, zero angle, zero angle velocity every round.
Thanks.
fanhe
 
Posts: 6
Joined: Fri Jan 07, 2011 4:26 am

Re: How to disable affection of a body's velocity in collision?

Postby slembcke » Thu Feb 17, 2011 9:10 am

The "bias" fields store values used by the overlap solver. Chipmunk holds a lot of internal state like this and more that cannot be easily reset.

Instead of trying to reset everything back to your starting conditions, why not just rebuild the scene from scratch? It would be far easier.
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: How to disable affection of a body's velocity in collision?

Postby dieterweb » Fri Feb 18, 2011 2:58 am

I think there are some scenarios where reseting a body is needed or would make thinks much easier. I would love to have a simple API call for that.
Visit our game Blog: http://zombiesmash.gamedrs.com or follow us on twitter: http://twitter.com/zombiesmash
dieterweb
 
Posts: 176
Joined: Fri Feb 27, 2009 7:12 am
Location: Germany

Re: How to disable affection of a body's velocity in collision?

Postby slembcke » Fri Feb 18, 2011 11:17 am

Well, if you really want to reset a body you can remove it, it's shapes and joints from the space and call cpBodyInit() on it again. That would effectively flush out all of the cached collision and contact data from the space. At that point though it's pretty much the same as just creating a new body. The only thing you are saving is the pointer.
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 0 guests

cron