| 121 | } |
| 122 | |
| 123 | void scene_editor_app::on_input(const app_input_event & event) |
| 124 | { |
| 125 | igm->update_input(event); |
| 126 | gizmo->on_input(event); |
| 127 | |
| 128 | if (ImGui::GetIO().WantCaptureMouse || ImGui::GetIO().WantCaptureKeyboard) |
| 129 | { |
| 130 | flycam.reset(); |
| 131 | gizmo->reset_input(); |
| 132 | return; |
| 133 | } |
| 134 | |
| 135 | // flycam only works when a mod key isn't held down |
| 136 | if (event.mods == 0) flycam.handle_input(event); |
| 137 | |
| 138 | { |
| 139 | if (event.type == app_input_event::KEY) |
| 140 | { |
| 141 | // De-select all objects |
| 142 | if (event.value[0] == GLFW_KEY_ESCAPE && event.action == GLFW_RELEASE) |
| 143 | { |
| 144 | gizmo->clear(); |
| 145 | } |
| 146 | |
| 147 | // Focus on currently selected object |
| 148 | if (event.value[0] == GLFW_KEY_F && event.action == GLFW_RELEASE) |
| 149 | { |
| 150 | if (gizmo->get_selection().size() == 0) return; |
| 151 | entity theSelection = gizmo->get_selection()[0]; |
| 152 | if (theSelection != kInvalidEntity) |
| 153 | { |
| 154 | base_object & obj = the_scene.get_graph().get_object(theSelection); |
| 155 | const transform selectedObjectPose = obj.get_component<transform_component>()->get_world_transform(); |
| 156 | const float3 focusOffset = selectedObjectPose.position + float3(0.f, 0.5f, 4.f); |
| 157 | cam.look_at(focusOffset, selectedObjectPose.position); |
| 158 | flycam.update_yaw_pitch(); |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | if (event.value[0] == GLFW_KEY_TAB && event.action == GLFW_RELEASE) |
| 163 | { |
| 164 | show_imgui = !show_imgui; |
| 165 | } |
| 166 | |
| 167 | if (event.value[0] == GLFW_KEY_SPACE && event.action == GLFW_RELEASE) |
| 168 | { |
| 169 | |
| 170 | } |
| 171 | |
| 172 | if (event.value[0] == GLFW_KEY_DELETE && event.action == GLFW_RELEASE) |
| 173 | { |
| 174 | delete_selected_entity(gizmo.get(), the_scene); |
| 175 | } |
| 176 | |
| 177 | // XZ plane nudging |
| 178 | if (event.action == GLFW_RELEASE) |
| 179 | { |
| 180 | auto nudge = [this](const float3 amount) |
nothing calls this directly
no test coverage detected