Skip to content

ScreenToWorldScale shouldn't have a division #2

@Apostolique

Description

@Apostolique

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions