wip : trying to fix the workspace view bounds detection

This commit is contained in:
2024-06-25 02:38:08 -04:00
parent 1f4d07727e
commit 1fe741034d
9 changed files with 59 additions and 25 deletions

View File

@ -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 }

View File

@ -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
}