public float ScreenToWorldScale(float z = 0) => 1 / Vector2.Distance(ScreenToWorld(0, 0, z), ScreenToWorld(1, 0, z));
Should be
public float ScreenToWorldScale(float z = 0) => Vector2.Distance(ScreenToWorld(0, 0, z), ScreenToWorld(1, 0, z));
The reason it's bad is that let's say I have 200 pixels in screen scale and I want to know how many pixels that is in world scale, right now you have to do:
float inWorldScale = 200f / ScreenToWorldScale();
but it should be
float inWorldScale = 200f * ScreenToWorldScale();
Saves 2 divisions.
public float ScreenToWorldScale(float z = 0) => 1 / Vector2.Distance(ScreenToWorld(0, 0, z), ScreenToWorld(1, 0, z));Should be
public float ScreenToWorldScale(float z = 0) => Vector2.Distance(ScreenToWorld(0, 0, z), ScreenToWorld(1, 0, z));The reason it's bad is that let's say I have 200 pixels in screen scale and I want to know how many pixels that is in world scale, right now you have to do:
float inWorldScale = 200f / ScreenToWorldScale();but it should be
float inWorldScale = 200f * ScreenToWorldScale();Saves 2 divisions.