2024-02-11 20:00:06 -08:00
|
|
|
package sectr
|
|
|
|
|
|
|
|
import "core:math/linalg"
|
|
|
|
|
2024-03-02 07:24:09 -08:00
|
|
|
pos_within_range2 :: proc( pos : Vec2, range : Range2 ) -> b32 {
|
|
|
|
within_x := pos.x > range.p0.x && pos.x < range.p1.x
|
|
|
|
within_y := pos.y < range.p0.y && pos.y > range.p1.y
|
|
|
|
return b32(within_x && within_y)
|
|
|
|
}
|
2024-02-11 20:00:06 -08:00
|
|
|
|
|
|
|
is_within_screenspace :: proc( pos : Vec2 ) -> b32 {
|
|
|
|
state := get_state(); using state
|
|
|
|
screen_extent := state.app_window.extent
|
|
|
|
cam := & project.workspace.cam
|
|
|
|
within_x_bounds : b32 = pos.x >= -screen_extent.x && pos.x <= screen_extent.x
|
|
|
|
within_y_bounds : b32 = pos.y >= -screen_extent.y && pos.y <= screen_extent.y
|
|
|
|
return within_x_bounds && within_y_bounds
|
|
|
|
}
|
2024-03-10 23:05:30 -07:00
|
|
|
|
|
|
|
within_range2 :: #force_inline proc ( a, b : Range2 ) -> bool {
|
|
|
|
a_half_size := size_range2( a ) * 0.5
|
|
|
|
b_half_size := size_range2( b ) * 0.5
|
|
|
|
a_center := a.p0 + { a_half_size.x, -a_half_size.y }
|
|
|
|
b_center := b.p0 + { b_half_size.x, -b_half_size.y }
|
|
|
|
|
|
|
|
within_x := abs(a_center.x - b_center.x) <= (a_half_size.x + b_half_size.y)
|
|
|
|
within_y := abs(a_center.y - b_center.y) <= (a_half_size.y + b_half_size.y)
|
|
|
|
return within_x && within_y
|
|
|
|
}
|