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

Official forum for the Chipmunk2D Physics Library.
Post Reply
fanhe
Posts: 6
Joined: Fri Jan 07, 2011 4:26 am
Contact:

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

Post by fanhe »

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.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

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

Post by slembcke »

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/
fanhe
Posts: 6
Joined: Fri Jan 07, 2011 4:26 am
Contact:

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

Post by fanhe »

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.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

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

Post by slembcke »

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/
dieterweb
Posts: 176
Joined: Fri Feb 27, 2009 7:12 am
Location: Germany
Contact:

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

Post by dieterweb »

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: [url]http://zombiesmash.gamedrs.com[/url] or follow us on twitter: [url]http://twitter.com/zombiesmash[/url]
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

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

Post by slembcke »

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/
Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests