diff --git a/src/game/editor.c b/src/game/editor.c index a3cc204..84624df 100755 --- a/src/game/editor.c +++ b/src/game/editor.c @@ -122,6 +122,7 @@ void editor_init(struct Editor* editor) editor->tool_mesh_draw_enabled = 1; editor->tool_snap_enabled = 1; editor->tool_rotate_amount = 0.f; + editor->tool_rotate_increment = 5.f; editor->tool_rotate_arc_radius = 5.f; editor->tool_rotate_arc_segments = 50.f; editor->tool_rotate_axis_selection_enabled = true; @@ -602,7 +603,7 @@ void editor_on_mousebutton_press(const struct Event* event) struct Game_State* game_state = game_state_get(); struct Editor* editor = game_state->editor; struct Gui* gui = game_state->gui; - if(game_state->game_mode != GAME_MODE_EDITOR) + if(game_state->game_mode != GAME_MODE_EDITOR && nk_window_is_any_hovered(&gui->context) == 0) return; @@ -718,7 +719,11 @@ void editor_on_mousemotion(const struct Event* event) } else /* Rotate on selected axis */ { - editor->tool_rotate_amount += event->mousemotion.xrel / 2; + if(editor->tool_snap_enabled) + editor->tool_rotate_amount += editor->grid_scale * editor->tool_rotate_increment * ((float)event->mousemotion.xrel / 2.f); + else + editor->tool_rotate_amount += event->mousemotion.xrel / 2; + if(editor->tool_rotate_amount > 360.f) editor->tool_rotate_amount = editor->tool_rotate_amount - 360.f; else if(editor->tool_rotate_amount < -360.f) diff --git a/src/game/editor.h b/src/game/editor.h index d423a11..9fe39b5 100755 --- a/src/game/editor.h +++ b/src/game/editor.h @@ -38,6 +38,7 @@ struct Editor int tool_rotate_arc_segments; bool tool_rotate_axis_selection_enabled; float tool_rotate_amount; + float tool_rotate_increment; vec3 tool_scale_amount; float axis_line_length; vec4 axis_color_x; diff --git a/todo.txt b/todo.txt index 448cdf4..d16cb98 100644 --- a/todo.txt +++ b/todo.txt @@ -1,5 +1,4 @@ Todo: - - Rotation degree snapping - Only show rotation gizmo for one axis at a time - Rotate mesh along mouse movement or show what the rotation is going to look like by using a wireframe version of mesh when rotating - Match amount to be rotate with actual axes and the gizmo arc being drawn @@ -264,4 +263,5 @@ Done: * Rotate mode tool widget * Complete rotate mode * Implement arc values greater than 360 or -360 + * Rotation degree snapping