Converting to and from display/sim units.

Mar 18, 2010 at 6:03 PM


I was messing around with Farseer, and I noticed that when I would set the position of a sprite, it would not end up where expected. I also noticed that the gravity seemed off. I did some research and found some information about converting the value to display units. I tried, and it works right...but I was just curious about something.

Here's an example of a property I made to store the position of the sprite:

public Vector2 Position
    get { return ConvertUnits.ToDisplayUnits(Body.Position); }
    set { Body.Position = ConvertUnits.ToSimUnits(value); }

Again, this works, or at least it seems to. Can anyone see any reasons why I shouldn't do it this way? Will this eventually cause problems? Or does it seem alright?

The reason I did this was so I could just work with the units I'm used to, with out having to convert them each time.