I figured this had been asked before as a few people seem confused on it, but searching the forums didn't reveal anything, so here goes...
ApplyImpulse immediately modifies the velocities of a body, while ApplyForce adds to "force" variables that are applied during the world's step.
Coming from APE (Actionscript Physics Engine) I kinda figured that the difference between the two was whether or not they factored in mass (APE has a addMasslessForce and an addForce that do this). Since ApplyImpulse was the "quickest" to affect objects, I figured it must not factor in mass.
But, looking at the code it's clear that *both* of them factor in mass (they both are multiplied by invMass before being used).
The difference I do see, though, is that ApplyImpulse modifies the velocity of the body (with respect to mass) instantaneously, while ApplyForce modifies the velocity of the body (with respect to mass) *in terms of time passed*. In other words, ApplyForce factors in "dt", which is why it's calculated in the step function. As a result, ApplyForce has about 1/30th (or whatever your physics step is) of the apparent affect as ApplyImpulse.
That makes sense (I guess)... ApplyForce is kinda abstracted away from time and is useful for applying continuous forces, while ApplyImpulse is really just a helper for incrementing velocities with respect to a body's mass.
But, I may be missing something, as I've not looked through all of the code and have no idea if there's more math at play that I'm not seeing/noticing. I'm also not well-read-enough on physics to know whether force vs. impulse are totally apparent terms for those in the know! 😉
ApplyImpulse immediately modifies the velocities of a body, while ApplyForce adds to "force" variables that are applied during the world's step.
Coming from APE (Actionscript Physics Engine) I kinda figured that the difference between the two was whether or not they factored in mass (APE has a addMasslessForce and an addForce that do this). Since ApplyImpulse was the "quickest" to affect objects, I figured it must not factor in mass.
But, looking at the code it's clear that *both* of them factor in mass (they both are multiplied by invMass before being used).
The difference I do see, though, is that ApplyImpulse modifies the velocity of the body (with respect to mass) instantaneously, while ApplyForce modifies the velocity of the body (with respect to mass) *in terms of time passed*. In other words, ApplyForce factors in "dt", which is why it's calculated in the step function. As a result, ApplyForce has about 1/30th (or whatever your physics step is) of the apparent affect as ApplyImpulse.
That makes sense (I guess)... ApplyForce is kinda abstracted away from time and is useful for applying continuous forces, while ApplyImpulse is really just a helper for incrementing velocities with respect to a body's mass.
But, I may be missing something, as I've not looked through all of the code and have no idea if there's more math at play that I'm not seeing/noticing. I'm also not well-read-enough on physics to know whether force vs. impulse are totally apparent terms for those in the know! 😉