At skatehead or anybody else who can answer.
How do I change the setup so that units in the physics model correspond to pixels?
Uncomment the line in b2Settings.h that says 'comment this line to use pixel units' and comment the one that says meters 😉
This is more to do with the demos rather than Box2D itself. In the demos I used a 'physics scale' variable to scale everything down to meter units for the physics simulation, then scale the values back up for drawing.
I forgot to use it to set the world AABB, so reducing it will make everything huge except the world AABB and things may become frozen.
If you want to use pixel units, make the world AABB big enough, set the m_physScale variable to 1, then uncomment that line in b2Settings.as as Diggsey suggested.
You'll have to play around with the gravity vector as it isn't affected by the b2_lengthUnitsPerMeter variable.
I probably should have just used pixel units in the demos to avoid confusion (I've had a number of emails about this) but I wasn't sure it would give correct results.
I'll look in to it further and hopefully remove the variable before the next release.
Thanks
-Matt
Thanks Matt,
I found the b2Settings class and the commented line, and then discovered the gravity issue you mentioned.
I'm pretty clueless when it comes to this physics math, how can I calculate what to set the gravity too with these settings?