Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Box2d units to meters conversion is applied everywhere (even where it isn't necessary) #899

Open
Vavius opened this issue Apr 16, 2014 · 0 comments
Assignees

Comments

@Vavius
Copy link
Contributor

Vavius commented Apr 16, 2014

I want to start a discussion about MOAI conversion between units and box2d meters. Since I'm writing liquidfun bindings at the moment, some of MOAI's unit scaling require rethink.
It is currently applied to all values:

  1. Position and shape dimensions
  2. Velocity, gravity, forces and impulses
  3. Density

I'm perfectly fine about 1) - it is very convenient and keeps me from manually multiplying values in lua.
2) is a kind of personal taste. I just more used to meters, but I can use units perfectly without converting them in lua.
The actual problem is with number 3). Density is specified in units too, and it's massively counterintuitive. Example:

world:setUnitsToMeters ( 0.05 )

-- now to use the default box2d density of 1 kg/m^2
-- we must do this:
fixture:setDensity ( 1 * 0.05 * 0.05 ) 

Working with densities in range from 0.00025 to 0.025 isn't easy or intuitive. But this is the values box2d expect - from 0.1 to 10 kg / m^2

Proper unit scale is crucial for box2d. It is tuned to work with sizes from 0.1 to 10 m and densities in the same range. Rigidbody physics is stable enough, so probably you haven't seen issues using wrong scale. But liquid is another beast - there are tons of constants and scaling 10x will blow up simulation.

TL;DR: Let us change density to not use UnitsToMeters and be always in kg / m^2. Also we may consider changing default UnitsToMeters from 1 to 0.05 or so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants