fixing some normalized space calculation issues

I need to review the convention I'm using for the "view" or at least how I interpret these coordinate spaces so its inutitive for the interface.
At the end of the day, the draw_list should be in normalized space, however how it gets digested to that state needs to be better documented or made more explicit in its transformation from the usual user calls.
This commit is contained in:
ed committed 2025-01-10 16:15:09 -05:00
1 parent 91e8af8839
commit 52584f888c
2 files changed
+26 -10

No files matched your search

+12 -6
View File
@@ -686,7 +686,7 @@ draw_text_shape_normalized_space :: #force_inline proc( ctx : ^Context,
font : Font_ID,
px_size : f32,
colour : RGBAN,
view : Vec2,
view : Vec2, // Screen
position : Vec2,
scale : Vec2,
zoom : f32, // TODO(Ed): Implement zoom support
@@ -702,10 +702,13 @@ draw_text_shape_normalized_space :: #force_inline proc( ctx : ^Context,
entry := ctx.entries[ font ]
adjusted_colour := colour
adjusted_colour.a = 1.0 + ctx.alpha_sharpen
adjusted_colour.a += ctx.alpha_sharpen
view_norm := 1 / view
scale_norm := scale * view_norm
target_px_size := px_size * ctx.px_scalar
target_scale := scale * (1 / ctx.px_scalar)
target_scale := scale_norm * (1 / ctx.px_scalar)
target_font_scale := parser_scale( entry.parser_info, target_px_size )
ctx.cursor_pos = generate_shape_draw_list( & ctx.draw_list, shape, & ctx.atlas, & ctx.glyph_buffer,
@@ -743,12 +746,15 @@ draw_text_normalized_space :: proc( ctx : ^Context,
adjusted_position := get_snapped_position( position, view )
adjusted_colour := colour
adjusted_colour.a = 1.0 + ctx.alpha_sharpen
adjusted_colour := colour
adjusted_colour.a += ctx.alpha_sharpen
view_norm := 1 / view
scale_norm := scale * view_norm
// Does nothing when px_scalar is 1.0
target_px_size := px_size * ctx.px_scalar
target_scale := scale * (1 / ctx.px_scalar)
target_scale := scale_norm * (1 / ctx.px_scalar)
target_font_scale := parser_scale( entry.parser_info, target_px_size )
shape := shaper_shape_text_cached( text_utf8, & ctx.shaper_ctx, & ctx.shape_cache, ctx.atlas, vec2(ctx.glyph_buffer.size),