diff --git a/core/scene.jai b/core/scene.jai index 817a8e3..9036e62 100644 --- a/core/scene.jai +++ b/core/scene.jai @@ -160,7 +160,7 @@ create_scene :: (name: string = "", max_entities: s64 = 256) -> *Scene { array_reserve(*scene.entities, max_entities); - scene.directional_light.color_and_intensity = .{1,1,1,1}; + scene.directional_light.color_and_intensity = .{1,1,1,2}; scene.directional_light.direction = to_v4(normalize(Vector3.{0.2, -0.7, 0.4})); dir_light_data : Directional_Light_Buffer_Data; diff --git a/editor/editor.jai b/editor/editor.jai index c194d4b..39ff05d 100644 --- a/editor/editor.jai +++ b/editor/editor.jai @@ -602,7 +602,7 @@ intersect_rotation_gizmo :: (ray: Ray) -> Transform_Axis, Vector3 { update_gizmo_buffers :: () { entity := engine.editor.selected_entities[0]; engine.editor.transform_gizmo.transform.position = entity.transform.position; - engine.editor.transform_gizmo.transform.orientation = entity.transform.orientation; + engine.editor.transform_gizmo.transform.orientation = ifx engine.editor.transform_gizmo.space == .LOCAL then entity.transform.orientation else .{0,0,0,1}; update_matrix(*engine.editor.transform_gizmo.transform); up_rotation := rotation_matrix(Matrix3, euler_to_quaternion(degrees_to_radians(90), degrees_to_radians(90), degrees_to_radians(0))); diff --git a/editor/editor_ui.jai b/editor/editor_ui.jai index 836eaa5..3638493 100644 --- a/editor/editor_ui.jai +++ b/editor/editor_ui.jai @@ -11,7 +11,7 @@ pick_scene_view_at :: (camera: Camera, coordinates: Vector2) { for engine.current_scene.entities { if !(it.flags & .RENDERABLE) continue; - //if it.flags & Entity_Flags.DELETED || !it.selectable || it.parent != null continue; + if it.flags & Entity_Flags.DELETED || it.parent != null continue; success, dist := ray_entity_intersect(ray, it); if success && dist < closest { @@ -211,39 +211,27 @@ text_fun : string; slider_value : float = 0.0; base_editor_update :: () { - if engine.editor.show_menu && (key_down(.MOUSE_LEFT) || key_down(.ESCAPE)) { - engine.editor.show_menu = false; - eat_key(.MOUSE_LEFT); - } - - // @Incomplete: Show that we saved the scene in the editor. Maybe a quick text message or just inside one of the tab titles - if key_pressed(.CTRL) && key_down(.S) { - save_scene(engine.current_scene); - } - - // Check if we hit the gizmo - // @Incomplete: MOVE THIS - engine.editor.should_check_entities = true; - - if engine.editor.selected_entities.count == 1 { - entity := engine.editor.selected_entities[0]; - gizmo_scale := distance(entity.transform.position, engine.editor.camera.position) * 0.1 * 0.5; - engine.editor.transform_gizmo.uniform_gizmo_scale = gizmo_scale; - set_scale(*engine.editor.transform_gizmo.transform, .{gizmo_scale, gizmo_scale, gizmo_scale}); - - 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); - - if update_transform_gizmo(ray, coordinates) { - engine.editor.should_check_entities = false; - } - } - editor_ui(); camera := *engine.editor.camera; - if engine.editor.focused_widget == null { + if engine.editor.focused_widget == null && engine.mode == .EDITING { + engine.editor.should_check_entities = true; + + if engine.editor.selected_entities.count == 1 { + entity := engine.editor.selected_entities[0]; + gizmo_scale := distance(entity.transform.position, engine.editor.camera.position) * 0.1 * 0.5; + engine.editor.transform_gizmo.uniform_gizmo_scale = gizmo_scale; + set_scale(*engine.editor.transform_gizmo.transform, .{gizmo_scale, gizmo_scale, gizmo_scale}); + + 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); + + if update_transform_gizmo(ray, coordinates) { + engine.editor.should_check_entities = false; + } + } + if key_pressed(.CTRL) && key_down(.S) { save_scene(engine.current_scene, "../assets/scenes/"); //show_message("Saved scene"); @@ -254,6 +242,7 @@ base_editor_update :: () { mark_entity_deleted(it); } + engine.editor.transform_gizmo.selected_axis = .NONE; engine.editor.selected_entities.count = 0; } diff --git a/module.jai b/module.jai index ff94880..4861ff9 100644 --- a/module.jai +++ b/module.jai @@ -144,6 +144,7 @@ switch_engine_mode :: (to_mode: Engine_Mode) { #if EDITOR { engine.editor.selected_entities.count = 0; + engine.editor.transform_gizmo.selected_axis = .NONE; } if engine.current_scene != null { diff --git a/physics/physics.jai b/physics/physics.jai index 0ad78b0..2b17aef 100644 --- a/physics/physics.jai +++ b/physics/physics.jai @@ -210,6 +210,10 @@ physics_step :: (scene: *Scene, timestep: float) { if e.collider.ignore continue; if e.flags & .PHYSICS { + if e.body.check_for_grounded { + e.body.grounded = false; + } + for other_e: scene.entities { if e == other_e continue; if other_e.collider.ignore continue; diff --git a/ui/ui.jai b/ui/ui.jai index 9912fb0..9924e7e 100644 --- a/ui/ui.jai +++ b/ui/ui.jai @@ -926,6 +926,8 @@ is_mouse_inside :: (x: float, y: float, rect: Rect) -> bool { } ui_update_input :: () { + if engine.mode == .PLAYING return; // @Robustness + mouse_x := engine.input.mouse.x; mouse_y := engine.input.mouse.y;