Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / object / object_ops.c
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * The Original Code is Copyright (C) 2008 Blender Foundation.
19  * All rights reserved.
20  *
21  *
22  * Contributor(s): Blender Foundation
23  *
24  * ***** END GPL LICENSE BLOCK *****
25  */
26
27 /** \file blender/editors/object/object_ops.c
28  *  \ingroup edobj
29  */
30
31
32 #include <stdlib.h>
33 #include <math.h>
34
35 #include "DNA_object_types.h"
36 #include "DNA_scene_types.h"
37
38 #include "BLI_utildefines.h"
39
40 #include "BKE_context.h"
41
42 #include "RNA_access.h"
43
44 #include "WM_api.h"
45 #include "WM_types.h"
46
47 #include "ED_screen.h"
48 #include "ED_object.h"
49
50 #include "DEG_depsgraph.h"
51
52 #include "object_intern.h"
53
54
55 /* ************************** registration **********************************/
56
57
58 void ED_operatortypes_object(void)
59 {
60         WM_operatortype_append(OBJECT_OT_location_clear);
61         WM_operatortype_append(OBJECT_OT_rotation_clear);
62         WM_operatortype_append(OBJECT_OT_scale_clear);
63         WM_operatortype_append(OBJECT_OT_origin_clear);
64         WM_operatortype_append(OBJECT_OT_visual_transform_apply);
65         WM_operatortype_append(OBJECT_OT_transform_apply);
66         WM_operatortype_append(OBJECT_OT_transform_axis_target);
67         WM_operatortype_append(OBJECT_OT_origin_set);
68
69         WM_operatortype_append(OBJECT_OT_mode_set);
70         WM_operatortype_append(OBJECT_OT_mode_set_or_submode);
71         WM_operatortype_append(OBJECT_OT_editmode_toggle);
72         WM_operatortype_append(OBJECT_OT_posemode_toggle);
73         WM_operatortype_append(OBJECT_OT_proxy_make);
74         WM_operatortype_append(OBJECT_OT_shade_smooth);
75         WM_operatortype_append(OBJECT_OT_shade_flat);
76         WM_operatortype_append(OBJECT_OT_paths_calculate);
77         WM_operatortype_append(OBJECT_OT_paths_update);
78         WM_operatortype_append(OBJECT_OT_paths_clear);
79         WM_operatortype_append(OBJECT_OT_forcefield_toggle);
80
81         WM_operatortype_append(OBJECT_OT_parent_set);
82         WM_operatortype_append(OBJECT_OT_parent_no_inverse_set);
83         WM_operatortype_append(OBJECT_OT_parent_clear);
84         WM_operatortype_append(OBJECT_OT_vertex_parent_set);
85         WM_operatortype_append(OBJECT_OT_track_set);
86         WM_operatortype_append(OBJECT_OT_track_clear);
87         WM_operatortype_append(OBJECT_OT_slow_parent_set);
88         WM_operatortype_append(OBJECT_OT_slow_parent_clear);
89         WM_operatortype_append(OBJECT_OT_make_local);
90         WM_operatortype_append(OBJECT_OT_make_override_static);
91         WM_operatortype_append(OBJECT_OT_make_single_user);
92         WM_operatortype_append(OBJECT_OT_make_links_scene);
93         WM_operatortype_append(OBJECT_OT_make_links_data);
94
95         WM_operatortype_append(OBJECT_OT_select_random);
96         WM_operatortype_append(OBJECT_OT_select_all);
97         WM_operatortype_append(OBJECT_OT_select_same_collection);
98         WM_operatortype_append(OBJECT_OT_select_by_type);
99         WM_operatortype_append(OBJECT_OT_select_linked);
100         WM_operatortype_append(OBJECT_OT_select_grouped);
101         WM_operatortype_append(OBJECT_OT_select_mirror);
102         WM_operatortype_append(OBJECT_OT_select_more);
103         WM_operatortype_append(OBJECT_OT_select_less);
104
105         WM_operatortype_append(COLLECTION_OT_create);
106         WM_operatortype_append(COLLECTION_OT_objects_remove_all);
107         WM_operatortype_append(COLLECTION_OT_objects_remove);
108         WM_operatortype_append(COLLECTION_OT_objects_add_active);
109         WM_operatortype_append(COLLECTION_OT_objects_remove_active);
110
111         WM_operatortype_append(OBJECT_OT_delete);
112         WM_operatortype_append(OBJECT_OT_text_add);
113         WM_operatortype_append(OBJECT_OT_armature_add);
114         WM_operatortype_append(OBJECT_OT_empty_add);
115         WM_operatortype_append(OBJECT_OT_lightprobe_add);
116         WM_operatortype_append(OBJECT_OT_drop_named_image);
117         WM_operatortype_append(OBJECT_OT_lamp_add);
118         WM_operatortype_append(OBJECT_OT_camera_add);
119         WM_operatortype_append(OBJECT_OT_speaker_add);
120         WM_operatortype_append(OBJECT_OT_add);
121         WM_operatortype_append(OBJECT_OT_add_named);
122         WM_operatortype_append(OBJECT_OT_effector_add);
123         WM_operatortype_append(OBJECT_OT_collection_instance_add);
124         WM_operatortype_append(OBJECT_OT_metaball_add);
125         WM_operatortype_append(OBJECT_OT_duplicates_make_real);
126         WM_operatortype_append(OBJECT_OT_duplicate);
127         WM_operatortype_append(OBJECT_OT_join);
128         WM_operatortype_append(OBJECT_OT_join_shapes);
129         WM_operatortype_append(OBJECT_OT_convert);
130
131         WM_operatortype_append(OBJECT_OT_modifier_add);
132         WM_operatortype_append(OBJECT_OT_modifier_remove);
133         WM_operatortype_append(OBJECT_OT_modifier_move_up);
134         WM_operatortype_append(OBJECT_OT_modifier_move_down);
135         WM_operatortype_append(OBJECT_OT_modifier_apply);
136         WM_operatortype_append(OBJECT_OT_modifier_convert);
137         WM_operatortype_append(OBJECT_OT_modifier_copy);
138         WM_operatortype_append(OBJECT_OT_multires_subdivide);
139         WM_operatortype_append(OBJECT_OT_multires_reshape);
140         WM_operatortype_append(OBJECT_OT_multires_higher_levels_delete);
141         WM_operatortype_append(OBJECT_OT_multires_base_apply);
142         WM_operatortype_append(OBJECT_OT_multires_external_save);
143         WM_operatortype_append(OBJECT_OT_multires_external_pack);
144         WM_operatortype_append(OBJECT_OT_skin_root_mark);
145         WM_operatortype_append(OBJECT_OT_skin_loose_mark_clear);
146         WM_operatortype_append(OBJECT_OT_skin_radii_equalize);
147         WM_operatortype_append(OBJECT_OT_skin_armature_create);
148
149         WM_operatortype_append(OBJECT_OT_correctivesmooth_bind);
150         WM_operatortype_append(OBJECT_OT_meshdeform_bind);
151         WM_operatortype_append(OBJECT_OT_explode_refresh);
152         WM_operatortype_append(OBJECT_OT_ocean_bake);
153
154         WM_operatortype_append(OBJECT_OT_constraint_add);
155         WM_operatortype_append(OBJECT_OT_constraint_add_with_targets);
156         WM_operatortype_append(POSE_OT_constraint_add);
157         WM_operatortype_append(POSE_OT_constraint_add_with_targets);
158         WM_operatortype_append(OBJECT_OT_constraints_copy);
159         WM_operatortype_append(POSE_OT_constraints_copy);
160         WM_operatortype_append(OBJECT_OT_constraints_clear);
161         WM_operatortype_append(POSE_OT_constraints_clear);
162         WM_operatortype_append(POSE_OT_ik_add);
163         WM_operatortype_append(POSE_OT_ik_clear);
164         WM_operatortype_append(CONSTRAINT_OT_delete);
165         WM_operatortype_append(CONSTRAINT_OT_move_up);
166         WM_operatortype_append(CONSTRAINT_OT_move_down);
167         WM_operatortype_append(CONSTRAINT_OT_stretchto_reset);
168         WM_operatortype_append(CONSTRAINT_OT_limitdistance_reset);
169         WM_operatortype_append(CONSTRAINT_OT_childof_set_inverse);
170         WM_operatortype_append(CONSTRAINT_OT_childof_clear_inverse);
171         WM_operatortype_append(CONSTRAINT_OT_objectsolver_set_inverse);
172         WM_operatortype_append(CONSTRAINT_OT_objectsolver_clear_inverse);
173         WM_operatortype_append(CONSTRAINT_OT_followpath_path_animate);
174
175         WM_operatortype_append(OBJECT_OT_vertex_group_add);
176         WM_operatortype_append(OBJECT_OT_vertex_group_remove);
177         WM_operatortype_append(OBJECT_OT_vertex_group_assign);
178         WM_operatortype_append(OBJECT_OT_vertex_group_assign_new);
179         WM_operatortype_append(OBJECT_OT_vertex_group_remove_from);
180         WM_operatortype_append(OBJECT_OT_vertex_group_select);
181         WM_operatortype_append(OBJECT_OT_vertex_group_deselect);
182         WM_operatortype_append(OBJECT_OT_vertex_group_copy_to_linked);
183         WM_operatortype_append(OBJECT_OT_vertex_group_copy_to_selected);
184         WM_operatortype_append(OBJECT_OT_vertex_group_copy);
185         WM_operatortype_append(OBJECT_OT_vertex_group_normalize);
186         WM_operatortype_append(OBJECT_OT_vertex_group_normalize_all);
187         WM_operatortype_append(OBJECT_OT_vertex_group_lock);
188         WM_operatortype_append(OBJECT_OT_vertex_group_fix);
189         WM_operatortype_append(OBJECT_OT_vertex_group_invert);
190         WM_operatortype_append(OBJECT_OT_vertex_group_levels);
191         WM_operatortype_append(OBJECT_OT_vertex_group_smooth);
192         WM_operatortype_append(OBJECT_OT_vertex_group_clean);
193         WM_operatortype_append(OBJECT_OT_vertex_group_quantize);
194         WM_operatortype_append(OBJECT_OT_vertex_group_limit_total);
195         WM_operatortype_append(OBJECT_OT_vertex_group_mirror);
196         WM_operatortype_append(OBJECT_OT_vertex_group_set_active);
197         WM_operatortype_append(OBJECT_OT_vertex_group_sort);
198         WM_operatortype_append(OBJECT_OT_vertex_group_move);
199         WM_operatortype_append(OBJECT_OT_vertex_weight_paste);
200         WM_operatortype_append(OBJECT_OT_vertex_weight_delete);
201         WM_operatortype_append(OBJECT_OT_vertex_weight_set_active);
202         WM_operatortype_append(OBJECT_OT_vertex_weight_normalize_active_vertex);
203         WM_operatortype_append(OBJECT_OT_vertex_weight_copy);
204
205         WM_operatortype_append(OBJECT_OT_face_map_add);
206         WM_operatortype_append(OBJECT_OT_face_map_remove);
207         WM_operatortype_append(OBJECT_OT_face_map_assign);
208         WM_operatortype_append(OBJECT_OT_face_map_remove_from);
209         WM_operatortype_append(OBJECT_OT_face_map_select);
210         WM_operatortype_append(OBJECT_OT_face_map_deselect);
211         WM_operatortype_append(OBJECT_OT_face_map_move);
212
213         WM_operatortype_append(TRANSFORM_OT_vertex_warp);
214
215         WM_operatortype_append(OBJECT_OT_move_to_collection);
216         WM_operatortype_append(OBJECT_OT_link_to_collection);
217
218         WM_operatortype_append(OBJECT_OT_shape_key_add);
219         WM_operatortype_append(OBJECT_OT_shape_key_remove);
220         WM_operatortype_append(OBJECT_OT_shape_key_clear);
221         WM_operatortype_append(OBJECT_OT_shape_key_retime);
222         WM_operatortype_append(OBJECT_OT_shape_key_mirror);
223         WM_operatortype_append(OBJECT_OT_shape_key_move);
224
225         WM_operatortype_append(OBJECT_OT_collection_add);
226         WM_operatortype_append(OBJECT_OT_collection_link);
227         WM_operatortype_append(OBJECT_OT_collection_remove);
228         WM_operatortype_append(OBJECT_OT_collection_unlink);
229         WM_operatortype_append(OBJECT_OT_collection_objects_select);
230
231         WM_operatortype_append(OBJECT_OT_hook_add_selob);
232         WM_operatortype_append(OBJECT_OT_hook_add_newob);
233         WM_operatortype_append(OBJECT_OT_hook_remove);
234         WM_operatortype_append(OBJECT_OT_hook_select);
235         WM_operatortype_append(OBJECT_OT_hook_assign);
236         WM_operatortype_append(OBJECT_OT_hook_reset);
237         WM_operatortype_append(OBJECT_OT_hook_recenter);
238
239         WM_operatortype_append(OBJECT_OT_bake_image);
240         WM_operatortype_append(OBJECT_OT_bake);
241         WM_operatortype_append(OBJECT_OT_drop_named_material);
242         WM_operatortype_append(OBJECT_OT_unlink_data);
243         WM_operatortype_append(OBJECT_OT_laplaciandeform_bind);
244
245         WM_operatortype_append(TRANSFORM_OT_vertex_random);
246
247         WM_operatortype_append(OBJECT_OT_data_transfer);
248         WM_operatortype_append(OBJECT_OT_datalayout_transfer);
249         WM_operatortype_append(OBJECT_OT_surfacedeform_bind);
250 }
251
252 void ED_operatormacros_object(void)
253 {
254         wmOperatorType *ot;
255         wmOperatorTypeMacro *otmacro;
256
257         ot = WM_operatortype_append_macro("OBJECT_OT_duplicate_move", "Duplicate Objects",
258                                           "Duplicate selected objects and move them", OPTYPE_UNDO | OPTYPE_REGISTER);
259         if (ot) {
260                 WM_operatortype_macro_define(ot, "OBJECT_OT_duplicate");
261                 otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
262                 RNA_enum_set(otmacro->ptr, "proportional", PROP_EDIT_OFF);
263         }
264
265         /* grr, should be able to pass options on... */
266         ot = WM_operatortype_append_macro("OBJECT_OT_duplicate_move_linked", "Duplicate Linked",
267                                           "Duplicate selected objects and move them", OPTYPE_UNDO | OPTYPE_REGISTER);
268         if (ot) {
269                 otmacro = WM_operatortype_macro_define(ot, "OBJECT_OT_duplicate");
270                 RNA_boolean_set(otmacro->ptr, "linked", true);
271                 otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
272                 RNA_enum_set(otmacro->ptr, "proportional", PROP_EDIT_OFF);
273         }
274
275 }
276
277 static int object_mode_poll(bContext *C)
278 {
279         Object *ob = CTX_data_active_object(C);
280         return (!ob || ob->mode == OB_MODE_OBJECT);
281 }
282
283 void ED_keymap_object(wmKeyConfig *keyconf)
284 {
285         wmKeyMap *keymap;
286         wmKeyMapItem *kmi;
287
288         /* Objects, Regardless of Mode -------------------------------------------------- */
289         keymap = WM_keymap_find(keyconf, "Object Non-modal", 0, 0);
290
291         /* modes */
292         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", TABKEY, KM_RELEASE, 0, 0);
293         RNA_enum_set(kmi->ptr, "mode", OB_MODE_EDIT);
294         RNA_boolean_set(kmi->ptr, "toggle", true);
295
296         kmi = WM_keymap_add_menu_pie(keymap, "VIEW3D_PIE_object_mode", TABKEY, KM_CLICK_DRAG, 0, 0);
297
298         WM_keymap_add_item(keymap, "OBJECT_OT_origin_set", CKEY, KM_PRESS, KM_ALT | KM_SHIFT | KM_CTRL, 0);
299
300         /* Object Mode ---------------------------------------------------------------- */
301         /* Note: this keymap gets disabled in non-objectmode,  */
302         keymap = WM_keymap_find(keyconf, "Object Mode", 0, 0);
303         keymap->poll = object_mode_poll;
304
305         /* object mode supports PET now */
306         ED_keymap_proportional_cycle(keyconf, keymap);
307         ED_keymap_proportional_obmode(keyconf, keymap);
308
309         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_all", AKEY, KM_PRESS, 0, 0);
310         RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
311         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
312         RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
313
314         WM_keymap_add_item(keymap, "OBJECT_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
315         WM_keymap_add_item(keymap, "OBJECT_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
316
317         WM_keymap_add_item(keymap, "OBJECT_OT_select_linked", LKEY, KM_PRESS, KM_SHIFT, 0);
318         WM_keymap_add_item(keymap, "OBJECT_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0);
319         WM_keymap_add_item(keymap, "OBJECT_OT_select_mirror", MKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
320
321         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, 0, 0);
322         RNA_enum_set_identifier(NULL, kmi->ptr, "direction", "PARENT");
323         RNA_boolean_set(kmi->ptr, "extend", false);
324
325         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
326         RNA_enum_set_identifier(NULL, kmi->ptr, "direction", "PARENT");
327         RNA_boolean_set(kmi->ptr, "extend", true);
328
329         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, 0, 0);
330         RNA_enum_set_identifier(NULL, kmi->ptr, "direction", "CHILD");
331         RNA_boolean_set(kmi->ptr, "extend", false);
332
333         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
334         RNA_enum_set_identifier(NULL, kmi->ptr, "direction", "CHILD");
335         RNA_boolean_set(kmi->ptr, "extend", true);
336
337         WM_keymap_verify_item(keymap, "OBJECT_OT_parent_set", PKEY, KM_PRESS, KM_CTRL, 0);
338         WM_keymap_verify_item(keymap, "OBJECT_OT_parent_no_inverse_set", PKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
339         WM_keymap_verify_item(keymap, "OBJECT_OT_parent_clear", PKEY, KM_PRESS, KM_ALT, 0);
340         WM_keymap_verify_item(keymap, "OBJECT_OT_track_set", TKEY, KM_PRESS, KM_CTRL, 0);
341         WM_keymap_verify_item(keymap, "OBJECT_OT_track_clear", TKEY, KM_PRESS, KM_ALT, 0);
342
343         WM_keymap_verify_item(keymap, "OBJECT_OT_constraint_add_with_targets", CKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
344         WM_keymap_verify_item(keymap, "OBJECT_OT_constraints_clear", CKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
345
346
347         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_location_clear", GKEY, KM_PRESS, KM_ALT, 0);
348         RNA_boolean_set(kmi->ptr, "clear_delta", false);
349         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_rotation_clear", RKEY, KM_PRESS, KM_ALT, 0);
350         RNA_boolean_set(kmi->ptr, "clear_delta", false);
351         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_scale_clear", SKEY, KM_PRESS, KM_ALT, 0);
352         RNA_boolean_set(kmi->ptr, "clear_delta", false);
353
354         WM_keymap_verify_item(keymap, "OBJECT_OT_origin_clear", OKEY, KM_PRESS, KM_ALT, 0);
355
356         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_delete", XKEY, KM_PRESS, 0, 0);
357         RNA_boolean_set(kmi->ptr, "use_global", false);
358
359         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_delete", XKEY, KM_PRESS, KM_SHIFT, 0);
360         RNA_boolean_set(kmi->ptr, "use_global", true);
361
362         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_delete", DELKEY, KM_PRESS, 0, 0);
363         RNA_boolean_set(kmi->ptr, "use_global", false);
364         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_delete", DELKEY, KM_PRESS, KM_SHIFT, 0);
365         RNA_boolean_set(kmi->ptr, "use_global", true);
366
367         WM_keymap_add_menu(keymap, "INFO_MT_add", AKEY, KM_PRESS, KM_SHIFT, 0);
368
369         WM_keymap_add_item(keymap, "OBJECT_OT_duplicates_make_real", AKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
370
371         WM_keymap_add_menu(keymap, "VIEW3D_MT_object_apply", AKEY, KM_PRESS, KM_CTRL, 0);
372         WM_keymap_add_menu(keymap, "VIEW3D_MT_make_single_user", UKEY, KM_PRESS, 0, 0);
373         WM_keymap_add_menu(keymap, "VIEW3D_MT_make_links", LKEY, KM_PRESS, KM_CTRL, 0);
374
375         WM_keymap_add_item(keymap, "OBJECT_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0);
376         WM_keymap_add_item(keymap, "OBJECT_OT_duplicate_move_linked", DKEY, KM_PRESS, KM_ALT, 0);
377
378         WM_keymap_add_item(keymap, "OBJECT_OT_join", JKEY, KM_PRESS, KM_CTRL, 0);
379         WM_keymap_add_item(keymap, "OBJECT_OT_convert", CKEY, KM_PRESS, KM_ALT, 0);
380         WM_keymap_add_item(keymap, "OBJECT_OT_proxy_make", PKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
381         WM_keymap_add_item(keymap, "OBJECT_OT_make_local", LKEY, KM_PRESS, 0, 0);
382
383         /* XXX this should probably be in screen instead... here for testing purposes in the meantime... - Aligorith */
384         WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_insert_menu", IKEY, KM_PRESS, 0, 0);
385         WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_delete_v3d", IKEY, KM_PRESS, KM_ALT, 0);
386         WM_keymap_verify_item(keymap, "ANIM_OT_keying_set_active_set", IKEY, KM_PRESS, KM_CTRL | KM_SHIFT | KM_ALT, 0);
387
388         WM_keymap_verify_item(keymap, "COLLECTION_OT_create", GKEY, KM_PRESS, KM_CTRL, 0);
389         WM_keymap_verify_item(keymap, "COLLECTION_OT_objects_remove", GKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
390         WM_keymap_verify_item(keymap, "COLLECTION_OT_objects_remove_all", GKEY, KM_PRESS, KM_SHIFT | KM_CTRL | KM_ALT, 0);
391         WM_keymap_verify_item(keymap, "COLLECTION_OT_objects_add_active", GKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
392         WM_keymap_verify_item(keymap, "COLLECTION_OT_objects_remove_active", GKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0);
393
394         WM_keymap_add_menu(keymap, "VIEW3D_MT_object_specials", WKEY, KM_PRESS, 0, 0);
395
396         WM_keymap_verify_item(keymap, "OBJECT_OT_data_transfer", TKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
397         /* XXX No more available 'T' shortcuts... :/ */
398         /* WM_keymap_verify_item(keymap, "OBJECT_OT_datalayout_transfer", TKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); */
399
400         for (int i = 0; i <= 5; i++) {
401                 kmi = WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY + i, KM_PRESS, KM_CTRL, 0);
402                 RNA_int_set(kmi->ptr, "level", i);
403         }
404
405         WM_keymap_add_item(keymap, "OBJECT_OT_move_to_collection", MKEY, KM_PRESS, 0, 0);
406         WM_keymap_add_item(keymap, "OBJECT_OT_link_to_collection", MKEY, KM_PRESS, KM_SHIFT, 0);
407 }
408
409 void ED_keymap_proportional_cycle(struct wmKeyConfig *UNUSED(keyconf), struct wmKeyMap *keymap)
410 {
411         wmKeyMapItem *kmi;
412
413         kmi = WM_keymap_add_item(keymap, "WM_OT_context_cycle_enum", OKEY, KM_PRESS, KM_SHIFT, 0);
414         RNA_string_set(kmi->ptr, "data_path", "tool_settings.proportional_edit_falloff");
415         RNA_boolean_set(kmi->ptr, "wrap", true);
416 }
417
418 void ED_keymap_proportional_obmode(struct wmKeyConfig *UNUSED(keyconf), struct wmKeyMap *keymap)
419 {
420         wmKeyMapItem *kmi;
421
422         kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", OKEY, KM_PRESS, 0, 0);
423         RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_proportional_edit_objects");
424 }
425
426 void ED_keymap_proportional_maskmode(struct wmKeyConfig *UNUSED(keyconf), struct wmKeyMap *keymap)
427 {
428         wmKeyMapItem *kmi;
429
430         kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", OKEY, KM_PRESS, 0, 0);
431         RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_proportional_edit_mask");
432 }
433
434 void ED_keymap_proportional_editmode(struct wmKeyConfig *UNUSED(keyconf), struct wmKeyMap *keymap,
435                                      const bool do_connected)
436 {
437         wmKeyMapItem *kmi;
438
439         kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", OKEY, KM_PRESS, 0, 0);
440         RNA_string_set(kmi->ptr, "data_path", "tool_settings.proportional_edit");
441         RNA_string_set(kmi->ptr, "value_1", "DISABLED");
442         RNA_string_set(kmi->ptr, "value_2", "ENABLED");
443
444         /* for modes/object types that allow 'connected' mode, add the Alt O key */
445         if (do_connected) {
446                 kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", OKEY, KM_PRESS, KM_ALT, 0);
447                 RNA_string_set(kmi->ptr, "data_path", "tool_settings.proportional_edit");
448                 RNA_string_set(kmi->ptr, "value_1", "DISABLED");
449                 RNA_string_set(kmi->ptr, "value_2", "CONNECTED");
450         }
451 }