| 3338 | } |
| 3339 | |
| 3340 | static void StartMouseTransformation(EditorTypes::Tool type, Object* obj, ControlEditorInfo* control_editor_info, const Collision& c, const LineSegment& mouseray, GameCursor* cursor) { |
| 3341 | control_editor_info->start_mouseray_ = mouseray; |
| 3342 | control_editor_info->start_cam_pos = ActiveCameras::Get()->GetPos(); |
| 3343 | control_editor_info->clicked_point_ = c.hit_where; |
| 3344 | |
| 3345 | // turn off camera controls |
| 3346 | if (ActiveCameras::Get()->m_camera_object != NULL) { |
| 3347 | ActiveCameras::Get()->m_camera_object->IgnoreMouseInput(true); |
| 3348 | } |
| 3349 | ToolMode mode = DetermineToolMode(type); |
| 3350 | |
| 3351 | mat4 obj_transform = obj->GetTransform(); |
| 3352 | quaternion obj_rot = obj->GetRotation(); |
| 3353 | int box_face_index = obj->box_.GetHitFaceIndex(invert(obj_rot) * c.hit_normal, |
| 3354 | invert(obj_transform) * control_editor_info->clicked_point_); |
| 3355 | int which_face_clicked = box_face_index; |
| 3356 | |
| 3357 | switch (mode) { |
| 3358 | case TRANSLATE_FACE_PLANE: |
| 3359 | case SCALE_PLANE: |
| 3360 | control_editor_info->face_display_.plane = true; |
| 3361 | control_editor_info->face_selected_ = which_face_clicked; |
| 3362 | break; |
| 3363 | case TRANSLATE_FACE_NORMAL: |
| 3364 | case SCALE_NORMAL: |
| 3365 | case ROTATE_CIRCLE: |
| 3366 | control_editor_info->face_display_.facing = true; |
| 3367 | control_editor_info->face_selected_ = which_face_clicked; |
| 3368 | break; |
| 3369 | default: |
| 3370 | LOGW << "Unhandled mode: " << GetToolModeString(mode) << std::endl; |
| 3371 | break; |
| 3372 | } |
| 3373 | control_editor_info->tool_.mode = mode; |
| 3374 | switch (type) { |
| 3375 | case EditorTypes::ROTATE: { |
| 3376 | if (control_editor_info->tool_.mode == ROTATE_CIRCLE) { |
| 3377 | vec3 rt_center = control_editor_info->tool_.center; |
| 3378 | vec3 rt_around = control_editor_info->tool_.around; |
| 3379 | GetRotationBasis(control_editor_info->clicked_point_, |
| 3380 | c.hit_normal, &control_editor_info->basis_, &rt_center, &rt_around, |
| 3381 | obj, obj->box_); |
| 3382 | control_editor_info->tool_.center = rt_center; |
| 3383 | control_editor_info->tool_.around = rt_around; |
| 3384 | } else { |
| 3385 | control_editor_info->tool_.center = obj->GetTranslation(); |
| 3386 | } |
| 3387 | |
| 3388 | control_editor_info->tool_.old_mousex = Input::Instance()->getMouse().pos_[0]; |
| 3389 | control_editor_info->tool_.old_mousey = Input::Instance()->getMouse().pos_[1]; |
| 3390 | control_editor_info->tool_.trackball_accumulate = quaternion(); |
| 3391 | |
| 3392 | GetRotation(mouseray, false, vec3(0.0f), control_editor_info, &control_editor_info->tool_, obj, obj->box_, cursor); |
| 3393 | } break; |
| 3394 | case EditorTypes::TRANSLATE: { |
| 3395 | if (control_editor_info->tool_.mode == TRANSLATE_CAMERA_PLANE) { |
| 3396 | GetCamBasis(&control_editor_info->basis_); |
| 3397 | } else { |
no test coverage detected