Replacement for old functions?

Official forum for the Chipmunk2D Physics Library.
Post Reply
Hexasoft
Posts: 7
Joined: Wed May 04, 2016 10:51 am
Contact:

Replacement for old functions?

Post by Hexasoft »

Hello, again me porting some old pieces of code to Chipmunk 7.

I have some functions that are no more present in v7, and I can't find in the doc a way to replace them (I still found that "Vel" or "Pos" were replaced by "Velocity" and "Position").
- cpShapeSetLayers(body-pointer, NOT_GRABABLE_MASK); → I can't remember why this was in my code but this function don't exists anymore
- body limits : cpBodySetVelLimit(…) and cpBodySetAngVelLimit(…) → I found useful to limit that values to reasonable stuff (i.e. in a "ball" game). I guess I can get/modify these values according to the limits I decided during process but maybe a better way exists

Thanks!

Regards,
--
Hexasoft
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Replacement for old functions?

Post by slembcke »

Layers were replaced by categories and category masks which are more powerful. Both are a value on cpShapeFilter, and you can set it using cpShapeSetFilter(). You can emulate the layer functionality exactly by setting both the category and mask to your old layer value.

The velocity limits were removed because they were so basic as to be useless for many. For instance, you might want to limit downward velocity, but not upwards or horizontal velocity. They are pretty easy to implement on your own using a velocity update function.

Code: Select all

void MyVelocityUpdate(cpBody *body, cpVect gravity, cpFloat damping, cpFloat dt){
  // Have Chipmunk do the regular velocity update.
  cpBodySetVelocityUpdateFunc(body, gravity, damping, dt);

  // Then apply your own extra sauce.
  // Clamp the velocity, etc.
}

// Then somewhere set the function on your body.
cpBodyUpdateVelocity(body, MyVelocityUpdate);
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Hexasoft
Posts: 7
Joined: Wed May 04, 2016 10:51 am
Contact:

Re: Replacement for old functions?

Post by Hexasoft »

Thanks for these informations. I will try this in my code.

Regards,
--
Hexasoft
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Heise IT-Markt [Crawler] and 7 guests