Page 1 of 1

Inverse in Chipmunk

Posted: Mon Sep 01, 2014 12:49 am
by KMagic
I am new to game programming as well as Chipmunk. I have a simple question:
What do m_inv ( inverse of mass) and i_inv (inverse of moment of inertia) mean? 8-)

Re: Inverse in Chipmunk

Posted: Tue Sep 02, 2014 1:08 pm
by slembcke
On most older CPUs, floating point division is very expensive compared to multiplication. So for a something like mass where you almost always use it as var/mass, it's better to precalculate m_inv = 1/mass so you can do var*m_inv instead.

It's quite possible that in the last 8 (!) years that it's no longer a relevant optimization though. Haven't bothered to check in a long time.