Changeset View
Standalone View
source/blender/editors/util/ed_util.c
| Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | |||||
| #include "BKE_object.h" | #include "BKE_object.h" | ||||
| #include "BKE_packedFile.h" | #include "BKE_packedFile.h" | ||||
| #include "BKE_paint.h" | #include "BKE_paint.h" | ||||
| #include "BKE_screen.h" | #include "BKE_screen.h" | ||||
| #include "BKE_undo_system.h" | #include "BKE_undo_system.h" | ||||
| #include "BKE_workspace.h" | #include "BKE_workspace.h" | ||||
| #include "BKE_material.h" | #include "BKE_material.h" | ||||
| #include "DEG_depsgraph.h" | |||||
| #include "ED_armature.h" | #include "ED_armature.h" | ||||
| #include "ED_buttons.h" | #include "ED_buttons.h" | ||||
| #include "ED_image.h" | #include "ED_image.h" | ||||
| #include "ED_mesh.h" | #include "ED_mesh.h" | ||||
| #include "ED_node.h" | #include "ED_node.h" | ||||
| #include "ED_object.h" | #include "ED_object.h" | ||||
| #include "ED_outliner.h" | #include "ED_outliner.h" | ||||
| #include "ED_paint.h" | #include "ED_paint.h" | ||||
| ▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { | ||||
| else if (ob->type == OB_GPENCIL) { | else if (ob->type == OB_GPENCIL) { | ||||
| /* For multi-edit mode we may already have mode data. | /* For multi-edit mode we may already have mode data. | ||||
| * (grease pencil does not need it) */ | * (grease pencil does not need it) */ | ||||
| continue; | continue; | ||||
| } | } | ||||
| ID *ob_data = ob->data; | ID *ob_data = ob->data; | ||||
| ob->mode = OB_MODE_OBJECT; | ob->mode = OB_MODE_OBJECT; | ||||
| if ((ob->type == obact->type) && !ID_IS_LINKED(ob) && !(ob_data && ID_IS_LINKED(ob_data))) { | if (!ID_IS_LINKED(ob) && !(ob_data && ID_IS_LINKED(ob_data))) { | ||||
| if (ob->type == obact->type) { | |||||
| if (mode == OB_MODE_EDIT) { | if (mode == OB_MODE_EDIT) { | ||||
| ED_object_editmode_enter_ex(bmain, scene, ob, 0); | ED_object_editmode_enter_ex(bmain, scene, ob, 0); | ||||
| } | } | ||||
| else if (mode == OB_MODE_POSE) { | else if (mode == OB_MODE_POSE) { | ||||
| ED_object_posemode_enter_ex(bmain, ob); | ED_object_posemode_enter_ex(bmain, ob); | ||||
| } | } | ||||
| else if (mode & OB_MODE_ALL_SCULPT) { | else if (mode & OB_MODE_ALL_SCULPT) { | ||||
| if (obact == ob) { | if (obact == ob) { | ||||
| if (mode == OB_MODE_SCULPT) { | if (mode == OB_MODE_SCULPT) { | ||||
| ED_object_sculptmode_enter_ex(bmain, depsgraph, scene, ob, true, reports); | ED_object_sculptmode_enter_ex(bmain, depsgraph, scene, ob, true, reports); | ||||
| } | } | ||||
| else if (mode == OB_MODE_VERTEX_PAINT) { | else if (mode == OB_MODE_VERTEX_PAINT) { | ||||
| ED_object_vpaintmode_enter_ex(bmain, depsgraph, wm, scene, ob); | ED_object_vpaintmode_enter_ex(bmain, depsgraph, wm, scene, ob); | ||||
| } | } | ||||
| else if (mode == OB_MODE_WEIGHT_PAINT) { | else if (mode == OB_MODE_WEIGHT_PAINT) { | ||||
| ED_object_wpaintmode_enter_ex(bmain, depsgraph, wm, scene, ob); | ED_object_wpaintmode_enter_ex(bmain, depsgraph, wm, scene, ob); | ||||
| } | } | ||||
| else { | else { | ||||
| BLI_assert(0); | BLI_assert(0); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* Create data for non-active objects which need it for | /* Create data for non-active objects which need it for | ||||
| * mode-switching but don't yet support multi-editing. */ | * mode-switching but don't yet support multi-editing. */ | ||||
| if (mode & OB_MODE_ALL_SCULPT) { | if (mode & OB_MODE_ALL_SCULPT) { | ||||
| ob->mode = mode; | ob->mode = mode; | ||||
| BKE_object_sculpt_data_create(ob); | BKE_object_sculpt_data_create(ob); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* TODO(campbell): avoid operator calls. */ | /* TODO(campbell): avoid operator calls. */ | ||||
| if (obact == ob) { | if (obact == ob) { | ||||
| ED_object_mode_toggle(C, mode); | ED_object_mode_toggle(C, mode); | ||||
| } | } | ||||
brecht: I think this else case needs the tag too?
It should be fine to always tag the object along… | |||||
dfelintoAuthorUnsubmitted Done Inline ActionsIt probably doesn't need. The active object tends to always work. But agree that always tagging is simple in this case. dfelinto: It probably doesn't need. The active object tends to always work. But agree that always tagging… | |||||
| } | } | ||||
| } | } | ||||
| else { | |||||
| /* Sanitize objects that may still be in edit mode.*/ | |||||
| DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); | |||||
sergeyUnsubmitted Not Done Inline ActionsNothing changed but tag is needed? Or am i missing something? sergey: Nothing changed but tag is needed? Or am i missing something? | |||||
dfelintoAuthorUnsubmitted Done Inline ActionsWe run into this when (ob->type != obact->type). What changed in this case is that we set ob->mode = OB_MODE_OBJECT (line 136). dfelinto: We run into this when `(ob->type != obact->type)`. What changed in this case is that we set `ob… | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| else { | |||||
| for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { | |||||
| /* Sanitize objects that may still be in edit mode.*/ | |||||
| if (!ID_IS_LINKED(ob) && !(ob->data && ID_IS_LINKED(ob->data))) { | |||||
| if (ob->mode != OB_MODE_OBJECT) { | |||||
| ob->mode = OB_MODE_OBJECT; | |||||
| DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); | |||||
| } | |||||
| } | |||||
brechtUnsubmitted Not Done Inline ActionsThe logic here is different than the case where an active object exists. It checks BKE_object_has_mode_data, (ob->type == OB_GPENCIL) and sets the object mode before the linked data check. I see no good reason why the existence of an active object should influence other objects like that, which was already an issue in the existing code. Probably it's best to just have a single loop over all objects, and do some obact == NULL checks inside the loop. brecht: The logic here is different than the case where an active object exists. It checks… | |||||
dfelintoAuthorUnsubmitted Done Inline ActionsAgree, will look into that. dfelinto: Agree, will look into that. | |||||
| } | } | ||||
| } | } | ||||
| /* image editor paint mode */ | /* image editor paint mode */ | ||||
| if (scene) { | if (scene) { | ||||
| ED_space_image_paint_update(bmain, wm, scene); | ED_space_image_paint_update(bmain, wm, scene); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 280 Lines • Show Last 20 Lines | |||||
I think this else case needs the tag too?
It should be fine to always tag the object along with ob->mode = OB_MODE_OBJECT; and not to worry about avoiding double tags.