Replacement for old functions?

Official forum for the Chipmunk2D Physics Library.

Replacement for old functions?

Postby Hexasoft » Tue May 10, 2016 2:16 am

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
Hexasoft
 
Posts: 7
Joined: Wed May 04, 2016 10:51 am

Re: Replacement for old functions?

Postby slembcke » Tue May 10, 2016 9:56 am

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

Re: Replacement for old functions?

Postby Hexasoft » Wed May 11, 2016 2:14 am

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

Regards,
--
Hexasoft
Hexasoft
 
Posts: 7
Joined: Wed May 04, 2016 10:51 am


Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 2 guests

cron