| 239 | } |
| 240 | |
| 241 | void input_released() |
| 242 | { |
| 243 | input_grab->ungrab_input(); |
| 244 | output->deactivate_plugin(&grab_interface); |
| 245 | current_view_unmapped.disconnect(); |
| 246 | if ((current_mode == mode::ROT_3D) && current_view) |
| 247 | { |
| 248 | auto tr = current_view->get_transformed_node() |
| 249 | ->get_transformer<wf::scene::view_3d_transformer_t>(transformer_3d); |
| 250 | if (tr) |
| 251 | { |
| 252 | /* check if the view was rotated to perpendicular to the screen |
| 253 | * and move it a bit more, so it will not get "stuck" that way */ |
| 254 | glm::vec4 n{0, 0, 1.f, 0}; |
| 255 | glm::vec4 x = tr->rotation * n; |
| 256 | auto dot = glm::dot(n, x); |
| 257 | if (std::abs(dot) < 0.05) |
| 258 | { |
| 259 | /* rotate 2.5 degrees around an axis perpendicular to x */ |
| 260 | current_view->get_transformed_node()->begin_transform_update(); |
| 261 | tr->rotation = glm::rotate<float>(tr->rotation, glm::radians( |
| 262 | dot < 0 ? -2.5f : 2.5f), {x.y, -x.x, 0}); |
| 263 | current_view->get_transformed_node()->end_transform_update(); |
| 264 | } |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | current_mode = mode::NONE; |
| 269 | } |
| 270 | |
| 271 | void fini() override |
| 272 | { |
nothing calls this directly
no test coverage detected