Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/object/object_modes.c
| Show All 23 Lines | |||||
| #include "DNA_gpencil_types.h" | #include "DNA_gpencil_types.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_workspace_types.h" | #include "DNA_workspace_types.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_gpencil_modifier.h" | |||||
| #include "BKE_layer.h" | #include "BKE_layer.h" | ||||
| #include "BKE_main.h" | |||||
| #include "BKE_modifier.h" | |||||
| #include "BKE_object.h" | #include "BKE_object.h" | ||||
| #include "BKE_paint.h" | #include "BKE_paint.h" | ||||
| #include "BKE_report.h" | #include "BKE_report.h" | ||||
| #include "BKE_scene.h" | #include "BKE_scene.h" | ||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| ▲ Show 20 Lines • Show All 258 Lines • ▼ Show 20 Lines | if (only_test) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| BLI_assert((ob->mode & OB_MODE_ALL_MODE_DATA) == 0); | BLI_assert((ob->mode & OB_MODE_ALL_MODE_DATA) == 0); | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| /* When locked, it's almost impossible to select the pose-object | |||||
| * then the mesh-object to enter weight paint mode. | |||||
| * Even when the object mode is not locked this is inconvenient - so allow in either case. | |||||
| * | |||||
| * In this case move our pose object in/out of pose mode. | |||||
| * This is in fits with the convention of selecting multiple objects and entering a mode. | |||||
| */ | |||||
| static void ed_object_posemode_set_for_weight_paint_ex(bContext *C, | |||||
| Main *bmain, | |||||
| Object *ob_arm, | |||||
| const bool is_mode_set) | |||||
| { | |||||
| View3D *v3d = CTX_wm_view3d(C); | |||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | |||||
| if (ob_arm != NULL) { | |||||
| const Base *base_arm = BKE_view_layer_base_find(view_layer, ob_arm); | |||||
| if (base_arm && BASE_VISIBLE(v3d, base_arm)) { | |||||
| if (is_mode_set) { | |||||
| if ((ob_arm->mode & OB_MODE_POSE) != 0) { | |||||
| ED_object_posemode_exit_ex(bmain, ob_arm); | |||||
| } | |||||
| } | |||||
| else { | |||||
| /* Only check selected status when entering weight-paint mode | |||||
| * because we may have multiple armature objects. | |||||
| * Selecting one will de-select the other, which would leave it in pose-mode | |||||
| * when exiting weight paint mode. While usable, this looks like inconsistent | |||||
| * behavior from a user perspective. */ | |||||
| if (base_arm->flag & BASE_SELECTED) { | |||||
| if ((ob_arm->mode & OB_MODE_POSE) == 0) { | |||||
| ED_object_posemode_enter_ex(bmain, ob_arm); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| void ED_object_posemode_set_for_weight_paint(bContext *C, | |||||
campbellbarton: The term `toggle` here is misleading, could use `set`, or call… | |||||
| Main *bmain, | |||||
| Object *ob, | |||||
| const bool is_mode_set) | |||||
| { | |||||
| if (ob->type == OB_GPENCIL) { | |||||
| GpencilVirtualModifierData virtualModifierData; | |||||
| GpencilModifierData *md = BKE_gpencil_modifiers_get_virtual_modifierlist(ob, | |||||
| &virtualModifierData); | |||||
| for (; md; md = md->next) { | |||||
Not Done Inline ActionsThe NULL check isn't needed, same below. campbellbarton: The NULL check isn't needed, same below. | |||||
| if (md->type == eGpencilModifierType_Armature) { | |||||
| ArmatureGpencilModifierData *amd = (ArmatureGpencilModifierData *)md; | |||||
| Object *ob_arm = amd->object; | |||||
| ed_object_posemode_set_for_weight_paint_ex(C, bmain, ob_arm, is_mode_set); | |||||
| } | |||||
| } | |||||
| } | |||||
| else { | |||||
| VirtualModifierData virtualModifierData; | |||||
| ModifierData *md = BKE_modifiers_get_virtual_modifierlist(ob, &virtualModifierData); | |||||
| for (; md; md = md->next) { | |||||
| if (md->type == eModifierType_Armature) { | |||||
| ArmatureModifierData *amd = (ArmatureModifierData *)md; | |||||
| Object *ob_arm = amd->object; | |||||
| ed_object_posemode_set_for_weight_paint_ex(C, bmain, ob_arm, is_mode_set); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| void ED_object_mode_generic_exit(struct Main *bmain, | void ED_object_mode_generic_exit(struct Main *bmain, | ||||
| struct Depsgraph *depsgraph, | struct Depsgraph *depsgraph, | ||||
| struct Scene *scene, | struct Scene *scene, | ||||
| struct Object *ob) | struct Object *ob) | ||||
| { | { | ||||
| ed_object_mode_generic_exit_ex(bmain, depsgraph, scene, ob, false); | ed_object_mode_generic_exit_ex(bmain, depsgraph, scene, ob, false); | ||||
| } | } | ||||
| bool ED_object_mode_generic_has_data(struct Depsgraph *depsgraph, struct Object *ob) | bool ED_object_mode_generic_has_data(struct Depsgraph *depsgraph, struct Object *ob) | ||||
| { | { | ||||
| return ed_object_mode_generic_exit_ex(NULL, depsgraph, NULL, ob, true); | return ed_object_mode_generic_exit_ex(NULL, depsgraph, NULL, ob, true); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
The term toggle here is misleading, could use set, or call ED_object_posemode_set_for_weight_paint, using similar prefix to (ED_object_posemode_enter).