Renamed v2 camera ray procs and added auto normalization of screen coords

This commit is contained in:
2025-07-03 22:54:10 +02:00
parent 2408c03579
commit eb5121802f
3 changed files with 8 additions and 36 deletions

View File

@@ -220,7 +220,7 @@ update_transform_gizmo :: (ray: Ray, mouse_position: Vector2) -> bool {
r1.origin = selected_entity.transform.position;
r1.direction = rotate(axis_vec, engine.editor.transform_gizmo.transform.orientation);
r2 := normalized_screen_to_ray_v2(*engine.editor.camera, mouse_position);
r2 := normalized_screen_to_ray(*engine.editor.camera, mouse_position);
d, t1, t2 := closest_distance_between_rays(r1, r2);
@@ -376,11 +376,7 @@ update_transform_gizmo :: (ray: Ray, mouse_position: Vector2) -> bool {
mouse_position.x = xx engine.input.mouse.x;
mouse_position.y = xx engine.input.mouse.y;
screen_size : Vector2;
screen_size.x = cast(float)engine.window.width;
screen_size.y = cast(float)engine.window.height;
r2 := screen_to_ray_v2(*engine.editor.camera, mouse_position, screen_size);
r2 := screen_to_ray(*engine.editor.camera, mouse_position);
d, t1, t2 := closest_distance_between_rays(r1, r2);
new_position := r1.origin + r1.direction * t1;

View File

@@ -1,7 +1,7 @@
#load "../ui/widgets.jai";
pick_scene_view_at :: (camera: Camera, coordinates: Vector2) {
ray := normalized_screen_to_ray_v2(camera, coordinates);
ray := normalized_screen_to_ray(camera, coordinates);
if engine.editor.should_check_entities {
hit_entity : *Entity;
@@ -182,7 +182,7 @@ base_editor_update :: () {
coordinates.y = 1.0 - coordinates.y;
//coordinates := Vector2.{engine.editor.mouse_viewport_state.normalized_local_mouse_coordinates.x, 1.0 - engine.editor.mouse_viewport_state.normalized_local_mouse_coordinates.y};
ray := normalized_screen_to_ray_v2(engine.editor.camera, coordinates);
ray := normalized_screen_to_ray(engine.editor.camera, coordinates);
if !blocking_input {
if update_transform_gizmo(ray, coordinates) {