mirror of
https://github.com/Ed94/VEFontCache-Odin.git
synced 2025-08-06 06:52:44 -07:00
fix get_normalized_position_scale
This commit is contained in:
@@ -1203,19 +1203,14 @@ get_cursor_pos :: #force_inline proc "contextless" ( ctx : Context ) -> Vec2 { r
|
|||||||
// (Does nothing if view is 1 or 0)
|
// (Does nothing if view is 1 or 0)
|
||||||
get_normalized_position_scale :: #force_inline proc "contextless" ( position, scale, view : Vec2 ) -> (position_norm, scale_norm : Vec2)
|
get_normalized_position_scale :: #force_inline proc "contextless" ( position, scale, view : Vec2 ) -> (position_norm, scale_norm : Vec2)
|
||||||
{
|
{
|
||||||
snap_quotient := 1 / Vec2 { max(view.x, 1), max(view.y, 1) }
|
should_snap := cast(f32) i32(view.x > 0 && view.y > 0)
|
||||||
should_snap := view * snap_quotient
|
view_quotient := 1 / Vec2 { max(view.x, 1), max(view.y, 1) }
|
||||||
|
|
||||||
snapped_position := position
|
position_snapped := ceil(position) * view_quotient * should_snap
|
||||||
snapped_position.x = ceil(position.x * view.x) * snap_quotient.x
|
position_norm = position * view_quotient
|
||||||
snapped_position.y = ceil(position.y * view.y) * snap_quotient.y
|
|
||||||
|
|
||||||
snapped_position *= should_snap
|
position_norm = max(position_snapped, position_norm)
|
||||||
snapped_position.x = max(snapped_position.x, position.x)
|
scale_norm = scale * view_quotient
|
||||||
snapped_position.y = max(snapped_position.y, position.y)
|
|
||||||
|
|
||||||
position_norm = snapped_position
|
|
||||||
scale_norm = scale * snap_quotient
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user