Cleanup: remove 'r_' prefix for variables

This is for return arguments, also remove redundant NULL check.
This commit is contained in:
Campbell Barton 2020-09-23 18:18:43 +10:00
parent 286909ded7
commit a6b16cfd80
1 changed files with 20 additions and 20 deletions

View File

@ -402,18 +402,17 @@ bool ED_object_mode_generic_has_data(struct Depsgraph *depsgraph, struct Object
/* -------------------------------------------------------------------- */
/** \name Switch Object
*
* Enters the same mode of the current active object in another object, leaving the mode of the
*current object.
*
* Enters the same mode of the current active object in another object,
* leaving the mode of the current object.
* \{ */
static bool object_switch_object_poll(bContext *C)
{
Object *ob = CTX_data_active_object(C);
if (!CTX_wm_region_view3d(C)) {
return false;
}
return ob && ELEM(ob->mode, OB_MODE_EDIT, OB_MODE_SCULPT);
const Object *ob = CTX_data_active_object(C);
return ob && (ob->mode & (OB_MODE_EDIT | OB_MODE_SCULPT));
}
static int object_switch_object_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
@ -435,11 +434,11 @@ static int object_switch_object_invoke(bContext *C, wmOperator *UNUSED(op), cons
float ray_co[3], ray_no[3];
float ray_dist = BVH_RAYCAST_DIST_MAX;
int r_index;
int index_dummy;
ED_view3d_win_to_origin(ar, mouse, ray_co);
ED_view3d_win_to_vector(ar, mouse, ray_no);
Object *r_ob = NULL;
Object *ob_dst = NULL;
bool ret = ED_transform_snap_object_project_ray_ex(sctx,
depsgraph,
@ -451,33 +450,34 @@ static int object_switch_object_invoke(bContext *C, wmOperator *UNUSED(op), cons
&ray_dist,
global_loc,
global_normal,
&r_index,
&r_ob,
&index_dummy,
&ob_dst,
(float(*)[4])r_obmat);
ED_transform_snap_object_context_destroy(sctx);
Object *c_ob = CTX_data_active_object(C);
if (!ret || r_ob == NULL) {
return OPERATOR_CANCELLED;
}
if (r_ob == NULL || r_ob == c_ob) {
if (!ret || ob_dst == NULL) {
return OPERATOR_CANCELLED;
}
eObjectMode last_mode = (eObjectMode)c_ob->mode;
if (!ED_object_mode_compat_test(r_ob, last_mode)) {
Object *ob_src = CTX_data_active_object(C);
if (ob_dst == ob_src) {
return OPERATOR_CANCELLED;
}
ED_object_mode_generic_exit(bmain, depsgraph, scene, c_ob);
Object *ob_orig = DEG_get_original_object(r_ob);
Base *base = BKE_view_layer_base_find(view_layer, ob_orig);
eObjectMode last_mode = (eObjectMode)ob_src->mode;
if (!ED_object_mode_compat_test(ob_dst, last_mode)) {
return OPERATOR_CANCELLED;
}
ED_object_mode_generic_exit(bmain, depsgraph, scene, ob_src);
Object *ob_dst_orig = DEG_get_original_object(ob_dst);
Base *base = BKE_view_layer_base_find(view_layer, ob_dst_orig);
BKE_view_layer_base_deselect_all(view_layer);
BKE_view_layer_base_select_and_set_active(view_layer, base);
DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ob_orig = DEG_get_original_object(r_ob);
ob_dst_orig = DEG_get_original_object(ob_dst);
ED_object_mode_set(C, last_mode);
/* Update the viewport rotation origin to the mouse cursor. */