Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/object/object_modes.c
| Show First 20 Lines • Show All 422 Lines • ▼ Show 20 Lines | |||||
| static int object_switch_object_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) | static int object_switch_object_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) | ||||
| { | { | ||||
| Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| ARegion *ar = CTX_wm_region(C); | ARegion *ar = CTX_wm_region(C); | ||||
| struct Main *bmain = CTX_data_main(C); | struct Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| struct SnapObjectContext *sctx = ED_transform_snap_object_context_create(scene, 0); | View3D *v3d = CTX_wm_view3d(C); | ||||
| float global_normal[3], global_loc[3]; | float hit_loc[3]; | ||||
| float r_obmat[4][4]; | float r_obmat[4][4]; | ||||
| float normal_dummy[3]; | |||||
| float mouse[2]; | float mouse_fl[2] = {event->mval[0], event->mval[1]}; | ||||
| mouse[0] = event->mval[0]; | |||||
| mouse[1] = event->mval[1]; | |||||
| float ray_co[3], ray_no[3]; | |||||
| float ray_dist = BVH_RAYCAST_DIST_MAX; | |||||
| int index_dummy; | |||||
| ED_view3d_win_to_origin(ar, mouse, ray_co); | |||||
| ED_view3d_win_to_vector(ar, mouse, ray_no); | |||||
| Object *ob_dst = NULL; | Object *ob_dst = NULL; | ||||
| struct SnapObjectContext *sctx = ED_transform_snap_object_context_create_view3d( | |||||
| bool ret = ED_transform_snap_object_project_ray_ex(sctx, | scene, 0, ar, v3d); | ||||
| bool ret = ED_transform_snap_object_project_view3d_ex(sctx, | |||||
| depsgraph, | depsgraph, | ||||
| SCE_SNAP_MODE_FACE, | |||||
| &(const struct SnapObjectParams){ | &(const struct SnapObjectParams){ | ||||
| .snap_select = SNAP_NOT_ACTIVE, | .snap_select = SNAP_ALL, | ||||
| .use_object_edit_cage = false, | |||||
| }, | }, | ||||
| ray_co, | mouse_fl, | ||||
| ray_no, | NULL, | ||||
| &ray_dist, | NULL, | ||||
| global_loc, | hit_loc, | ||||
| global_normal, | normal_dummy, | ||||
| &index_dummy, | NULL, | ||||
| &ob_dst, | &ob_dst, | ||||
| (float(*)[4])r_obmat); | r_obmat); | ||||
| ED_transform_snap_object_context_destroy(sctx); | ED_transform_snap_object_context_destroy(sctx); | ||||
| if (!ret || ob_dst == NULL) { | if (!ret || ob_dst == NULL) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| Object *ob_src = CTX_data_active_object(C); | Object *ob_src = CTX_data_active_object(C); | ||||
| if (ob_dst == ob_src) { | if (ob_dst == ob_src) { | ||||
| Show All 13 Lines | static int object_switch_object_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) | ||||
| DEG_id_tag_update(&scene->id, ID_RECALC_SELECT); | DEG_id_tag_update(&scene->id, ID_RECALC_SELECT); | ||||
| depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| ob_dst_orig = DEG_get_original_object(ob_dst); | ob_dst_orig = DEG_get_original_object(ob_dst); | ||||
| ED_object_mode_set(C, last_mode); | ED_object_mode_set(C, last_mode); | ||||
| /* Update the viewport rotation origin to the mouse cursor. */ | /* Update the viewport rotation origin to the mouse cursor. */ | ||||
| UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings; | UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings; | ||||
| copy_v3_v3(ups->average_stroke_accum, global_loc); | copy_v3_v3(ups->average_stroke_accum, hit_loc); | ||||
| ups->average_stroke_counter = 1; | ups->average_stroke_counter = 1; | ||||
| ups->last_stroke_valid = true; | ups->last_stroke_valid = true; | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); | WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); | ||||
| WM_toolsystem_update_from_context_view3d(C); | WM_toolsystem_update_from_context_view3d(C); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| Show All 18 Lines | |||||