diff --git a/code/grime/hashmap_chained.odin b/code/grime/hashmap_chained.odin index cecdbc4..64458de 100644 --- a/code/grime/hashmap_chained.odin +++ b/code/grime/hashmap_chained.odin @@ -72,7 +72,7 @@ hmap_chained_init :: proc( $HMapChainedType : typeid/HMapChained($Type), lookup_ pool_bucket_cap := pool_bucket_cap if pool_bucket_cap == 0 { - pool_bucket_cap = cast(uint) int(lookup_capacity) * size_of( HMapChainedSlot(Type)) * 2 + pool_bucket_cap = cast(uint) int(lookup_capacity) * size_of( HMapChainedSlot(Type)) //* 2 } table.header = cast( ^HMapChainedHeader(Type)) raw_mem diff --git a/code/sectr/engine/client_api.odin b/code/sectr/engine/client_api.odin index 3ab9e61..0bd6060 100644 --- a/code/sectr/engine/client_api.odin +++ b/code/sectr/engine/client_api.odin @@ -325,7 +325,8 @@ startup :: proc( prof : ^SpallProfiler, persistent_mem, frame_mem, transient_mem ui_startup( & workspace.ui, cache_allocator = persistent_slab_allocator() ) } - debug.path_lorem = str_fmt("C:/projects/SectrPrototype/examples/Lorem_Ispsum (197).txt", allocator = persistent_slab_allocator()) + debug.path_lorem = str_fmt("C:/projects/SectrPrototype/examples/Lorem Ipsum (197).txt", allocator = persistent_slab_allocator()) + // debug.path_lorem = str_fmt("C:/projects/SectrPrototype/examples/Lorem Ipsum (1022).txt", allocator = persistent_slab_allocator()) alloc_error : AllocatorError; success : bool debug.lorem_content, success = os.read_entire_file( debug.path_lorem, persistent_slab_allocator() ) diff --git a/code/sectr/engine/render.odin b/code/sectr/engine/render.odin index ee8d18c..789e81b 100644 --- a/code/sectr/engine/render.odin +++ b/code/sectr/engine/render.odin @@ -77,6 +77,7 @@ render_mode_2d_workspace :: proc() render_set_color(Color_White) draw_filled_circle(0, 0, 2 * cam_zoom_ratio, 24) + // Blend test if false { gp.set_color( 1.0, 0, 0, 0.25 ) @@ -93,10 +94,25 @@ render_mode_2d_workspace :: proc() render_flush_gp() } + // Visualize view bounds + when true + { + render_set_view_space(screen_extent) + // render_set_camera(cam) + + view_bounds := view_get_bounds() + view_bounds.min *= 0.9 + view_bounds.max *= 0.9 + draw_rect( view_bounds, { 0, 0, 180, 30 } ) + + render_flush_gp() + } + render_set_view_space(screen_extent) render_set_camera(cam) ui := & project.workspace.ui + ui_context = & project.workspace.ui when UI_Render_Method == .Layers { render_list := array_to_slice( ui.render_list ) @@ -106,6 +122,8 @@ render_mode_2d_workspace :: proc() { render_ui_via_box_tree( ui.root, & cam ) } + + ui_context = nil } render_mode_screenspace :: proc() @@ -219,6 +237,8 @@ render_mode_screenspace :: proc() { ui := & project.workspace.ui + debug_text("Workspace Cam : %v", project.workspace.cam) + debug_text("Box Count (Workspace): %v", ui.built_box_count ) hot_box := ui_box_from_key( ui.curr_cache, ui.hot ) @@ -266,6 +286,7 @@ render_screen_ui :: proc() render_set_view_space(screen_extent) ui := & screen_ui + state.ui_context = & screen_ui text_enqueued : b32 = false shape_enqueued : b32 = false @@ -278,11 +299,13 @@ render_screen_ui :: proc() { render_ui_via_box_tree( ui.root ) } + + state.ui_context = nil } render_text_layer :: proc() { - // profile("VEFontCache: render text layer") + profile("VEFontCache: render text layer") Bindings :: gfx.Bindings Range :: gfx.Range @@ -327,7 +350,7 @@ render_text_layer :: proc() // 1. Do the glyph rendering pass // Glyphs are first rendered to an intermediate 2k x 512px R8 texture case .Glyph: - // profile("VEFontCache: draw call: glyph") + profile("VEFontCache: draw call: glyph") if num_indices == 0 && ! draw_call.clear_before_draw { continue } @@ -363,7 +386,7 @@ render_text_layer :: proc() // 2. Do the atlas rendering pass // A simple 16-tap box downsample shader is then used to blit from this intermediate texture to the final atlas location case .Atlas: - // profile("VEFontCache: draw call: atlas") + profile("VEFontCache: draw call: atlas") if num_indices == 0 && ! draw_call.clear_before_draw { continue } @@ -409,7 +432,7 @@ render_text_layer :: proc() continue } - // profile("VEFontCache: draw call: target") + profile("VEFontCache: draw call: target") width := u32(app_window.extent.x * 2) height := u32(app_window.extent.y * 2) @@ -467,8 +490,7 @@ render_ui_via_box_tree :: proc( root : ^UI_Box, cam : ^Camera = nil ) default_font := get_state().default_font cam_zoom_ratio := cam != nil ? 1.0 / cam.zoom : 1.0 - - circle_radius := cam != nil ? cam_zoom_ratio * 3 : 3 + circle_radius := cam != nil ? cam_zoom_ratio * 3 : 3 for box := root.first; box != nil; box = ui_box_tranverse_next_depth_based( box ) { @@ -483,7 +505,7 @@ render_ui_via_box_tree :: proc( root : ^UI_Box, cam : ^Camera = nil ) using computed - // profile("enqueue box") + profile("enqueue box") GP_Render: { @@ -719,7 +741,6 @@ draw_text_string_pos_extent_zoomed :: proc( content : string, id : FontID, size text_scale /= over_sample color_norm := normalize_rgba8(color) - // logf("zoom_adjust_size: %v", zoom_adjust_size) ve.set_colour( & font_provider_data.ve_font_cache, color_norm ) ve.draw_text( & font_provider_data.ve_font_cache, ve_id, content, normalized_pos, text_scale ) } diff --git a/code/sectr/engine/update.odin b/code/sectr/engine/update.odin index bf404fd..c1702fa 100644 --- a/code/sectr/engine/update.odin +++ b/code/sectr/engine/update.odin @@ -168,7 +168,7 @@ update :: proc( delta_time : f64 ) -> b32 config.cam_min_zoom = 0.10 config.cam_zoom_sensitivity_digital = 0.05 config.cam_zoom_sensitivity_smooth = 2.0 - config.cam_zoom_mode = .Smooth + config.cam_zoom_mode = .Digital switch config.cam_zoom_mode { case .Smooth: @@ -247,9 +247,9 @@ update :: proc( delta_time : f64 ) -> b32 config.ui_resize_border_width = 2.5 // test_hover_n_click() // test_draggable() - // test_text_box() + test_text_box() // test_parenting( & default_layout, & frame_style_default ) - test_whitespace_ast( & default_layout, & frame_style_default ) + // test_whitespace_ast( & default_layout, & frame_style_default ) } //endregion Workspace Imgui Tick diff --git a/code/sectr/math/math.odin b/code/sectr/math/math.odin index 9cc0b57..4f99688 100644 --- a/code/sectr/math/math.odin +++ b/code/sectr/math/math.odin @@ -116,6 +116,14 @@ add_range2 :: #force_inline proc "contextless" ( a, b : Range2 ) -> Range2 { return result } +// mul_range2 :: #force_inline proc "contextless" ( a, b : Range2 ) -> Range2 { +// result := Range2 { pts = { +// a.p0 + b.p0, +// a.p1 + b.p1, +// }} +// return result +// } + sub_range2 :: #force_inline proc "contextless" ( a, b : Range2 ) -> Range2 { // result := Range2 { array = a.array - b.array } result := Range2 { mat = a.mat - b.mat } diff --git a/code/sectr/math/space.odin b/code/sectr/math/space.odin index c05196f..98e999b 100644 --- a/code/sectr/math/space.odin +++ b/code/sectr/math/space.odin @@ -168,8 +168,11 @@ view_get_bounds :: #force_inline proc "contextless"() -> Range2 { cam := & project.workspace.cam screen_extent := state.app_window.extent cam_zoom_ratio := 1.0 / cam.zoom - bottom_left := Vec2 { cam.position.x, cam.position.y } + Vec2 { screen_extent.x, screen_extent.y} * cam_zoom_ratio - top_right := Vec2 { cam.position.x, cam.position.y } + Vec2 { screen_extent.x, screen_extent.y} * cam_zoom_ratio + + bottom_left := Vec2 { -screen_extent.x, -screen_extent.y} + top_right := Vec2 { screen_extent.x, screen_extent.y} + bottom_left = screen_to_ws_view_pos(bottom_left) + top_right = screen_to_ws_view_pos(top_right) return range2( bottom_left, top_right ) } @@ -202,7 +205,7 @@ render_to_ws_view_pos :: #force_inline proc "contextless" (pos : Vec2) -> Vec2 { screen_to_ws_view_pos :: #force_inline proc "contextless" (pos: Vec2) -> Vec2 { state := get_state(); using state cam := & project.workspace.cam - result := (Vec2 { cam.position.x, -cam.position.y} + Vec2 { pos.x, pos.y }) * (1 / cam.zoom) + result := pos - cam.position * cam.zoom return result } diff --git a/code/sectr/ui/core/base.odin b/code/sectr/ui/core/base.odin index 0757048..ff1f7e6 100644 --- a/code/sectr/ui/core/base.odin +++ b/code/sectr/ui/core/base.odin @@ -506,12 +506,13 @@ ui_top_ancestor :: #force_inline proc "contextless" ( box : ^UI_Box ) -> (^UI_Bo ui_view_bounds :: #force_inline proc "contextless" () -> (range : Range2) { using state := get_state(); - if ui_context == & screen_ui { - return screen_get_bounds() - } - else { + // if ui_context == & screen_ui { + // return screen_get_bounds() + // } + // else { + return view_get_bounds() - } + // } } ui_context :: #force_inline proc() -> ^UI_State { return get_state().ui_context } diff --git a/examples/Lorem_Ispsum (197).txt b/examples/Lorem Ipsum (197).txt similarity index 100% rename from examples/Lorem_Ispsum (197).txt rename to examples/Lorem Ipsum (197).txt diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 1fd84b2..f4c360f 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -204,8 +204,8 @@ push-location $path_root # $build_args += $flag_micro_architecture_native $build_args += $flag_use_separate_modules $build_args += $flag_thread_count + $CoreCount_Physical - $build_args += $flag_optimize_none - # $build_args += $flag_optimize_minimal + # $build_args += $flag_optimize_none + $build_args += $flag_optimize_minimal # $build_args += $flag_optimize_speed # $build_args += $falg_optimize_aggressive $build_args += $flag_debug @@ -280,10 +280,10 @@ push-location $path_root # $build_args += $flag_micro_architecture_native $build_args += $flag_use_separate_modules $build_args += $flag_thread_count + $CoreCount_Physical - $build_args += $flag_optimize_none + # $build_args += $flag_optimize_none # $build_args += $flag_optimize_minimal # $build_args += $flag_optimize_speed - # $build_args += $falg_optimize_aggressive + $build_args += $falg_optimize_aggressive $build_args += $flag_debug $build_args += $flag_pdb_name + $pdb $build_args += $flag_subsystem + 'windows'