Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/object/object_edit.c')
-rw-r--r--source/blender/editors/object/object_edit.c119
1 files changed, 69 insertions, 50 deletions
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index d39e34824b9..12400209866 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -150,7 +150,7 @@ static int object_hide_view_clear_exec(bContext *C, wmOperator *UNUSED(op))
}
if (changed) {
DAG_id_type_tag(bmain, ID_OB);
- DAG_scene_sort(bmain, scene);
+ DAG_relations_tag_update(bmain);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
}
@@ -207,7 +207,7 @@ static int object_hide_view_set_exec(bContext *C, wmOperator *op)
if (changed) {
DAG_id_type_tag(bmain, ID_OB);
- DAG_scene_sort(bmain, scene);
+ DAG_relations_tag_update(bmain);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C));
@@ -312,29 +312,26 @@ void OBJECT_OT_hide_render_set(wmOperatorType *ot)
/* ******************* toggle editmode operator ***************** */
-void ED_object_exit_editmode(bContext *C, int flag)
+/**
+ * Load EditMode data back into the object,
+ * optionally freeing the editmode data.
+ */
+static bool ED_object_editmode_load_ex(Object *obedit, const bool freedata)
{
- /* Note! only in exceptional cases should 'EM_DO_UNDO' NOT be in the flag */
+ if (obedit == NULL) {
+ return false;
+ }
- Scene *scene = CTX_data_scene(C);
- Object *obedit = CTX_data_edit_object(C);
- int freedata = flag & EM_FREEDATA;
-
- if (obedit == NULL) return;
-
- if (flag & EM_WAITCURSOR) waitcursor(1);
if (obedit->type == OB_MESH) {
Mesh *me = obedit->data;
-
-// if (EM_texFaceCheck())
-
+
if (me->edit_btmesh->bm->totvert > MESH_MAX_VERTS) {
error("Too many vertices");
- return;
+ return false;
}
-
+
EDBM_mesh_load(obedit);
-
+
if (freedata) {
EDBM_mesh_free(me->edit_btmesh);
MEM_freeN(me->edit_btmesh);
@@ -367,6 +364,29 @@ void ED_object_exit_editmode(bContext *C, int flag)
if (freedata) free_editMball(obedit);
}
+ return true;
+}
+
+bool ED_object_editmode_load(Object *obedit)
+{
+ return ED_object_editmode_load_ex(obedit, false);
+}
+
+void ED_object_editmode_exit(bContext *C, int flag)
+{
+ /* Note! only in exceptional cases should 'EM_DO_UNDO' NOT be in the flag */
+ /* Note! if 'EM_FREEDATA' isn't in the flag, use ED_object_editmode_load directly */
+ Scene *scene = CTX_data_scene(C);
+ Object *obedit = CTX_data_edit_object(C);
+ const bool freedata = (flag & EM_FREEDATA) != 0;
+
+ if (flag & EM_WAITCURSOR) waitcursor(1);
+
+ if (ED_object_editmode_load_ex(obedit, freedata) == false) {
+ if (flag & EM_WAITCURSOR) waitcursor(0);
+ return;
+ }
+
/* freedata only 0 now on file saves and render */
if (freedata) {
ListBase pidlist;
@@ -376,7 +396,7 @@ void ED_object_exit_editmode(bContext *C, int flag)
scene->obedit = NULL; // XXX for context
/* flag object caches as outdated */
- BKE_ptcache_ids_from_object(&pidlist, obedit, NULL, 0);
+ BKE_ptcache_ids_from_object(&pidlist, obedit, scene, 0);
for (pid = pidlist.first; pid; pid = pid->next) {
if (pid->type != PTCACHE_TYPE_PARTICLES) /* particles don't need reset on geometry change */
pid->cache->flag |= PTCACHE_OUTDATED;
@@ -390,17 +410,17 @@ void ED_object_exit_editmode(bContext *C, int flag)
if (flag & EM_DO_UNDO)
ED_undo_push(C, "Editmode");
-
- if (flag & EM_WAITCURSOR) waitcursor(0);
-
+
WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, scene);
obedit->mode &= ~OB_MODE_EDIT;
}
+
+ if (flag & EM_WAITCURSOR) waitcursor(0);
}
-void ED_object_enter_editmode(bContext *C, int flag)
+void ED_object_editmode_enter(bContext *C, int flag)
{
Scene *scene = CTX_data_scene(C);
Base *base = NULL;
@@ -429,6 +449,10 @@ void ED_object_enter_editmode(bContext *C, int flag)
ob = base->object;
+ /* this checks actual object->data, for cases when other scenes have it in editmode context */
+ if ( BKE_object_is_in_editmode(ob) )
+ return;
+
if (BKE_object_obdata_is_libdata(ob)) {
error_libdata();
return;
@@ -533,9 +557,9 @@ static int editmode_toggle_exec(bContext *C, wmOperator *UNUSED(op))
ToolSettings *toolsettings = CTX_data_tool_settings(C);
if (!CTX_data_edit_object(C))
- ED_object_enter_editmode(C, EM_WAITCURSOR);
+ ED_object_editmode_enter(C, EM_WAITCURSOR);
else
- ED_object_exit_editmode(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR); /* had EM_DO_UNDO but op flag calls undo too [#24685] */
+ ED_object_editmode_exit(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR); /* had EM_DO_UNDO but op flag calls undo too [#24685] */
ED_space_image_uv_sculpt_update(CTX_wm_manager(C), toolsettings);
@@ -585,7 +609,7 @@ static int posemode_exec(bContext *C, wmOperator *UNUSED(op))
if (base->object->type == OB_ARMATURE) {
if (base->object == CTX_data_edit_object(C)) {
- ED_object_exit_editmode(C, EM_FREEDATA | EM_DO_UNDO);
+ ED_object_editmode_exit(C, EM_FREEDATA | EM_DO_UNDO);
ED_armature_enter_posemode(C, base);
}
else if (base->object->mode & OB_MODE_POSE)
@@ -767,7 +791,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event)
Base *base;
Curve *cu, *cu1;
Nurb *nu;
- int do_scene_sort = FALSE;
+ bool do_depgraph_update = false;
if (scene->id.lib) return;
@@ -794,7 +818,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event)
for (base = FIRSTBASE; base; base = base->next) {
if (base != BASACT) {
if (TESTBASELIB(v3d, base)) {
- base->object->recalc |= OB_RECALC_OB;
+ DAG_id_tag_update(&base->object->id, OB_RECALC_DATA);
if (event == 1) { /* loc */
copy_v3_v3(base->object->loc, ob->loc);
@@ -893,7 +917,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event)
BLI_strncpy(cu1->family, cu->family, sizeof(cu1->family));
- base->object->recalc |= OB_RECALC_DATA;
+ DAG_id_tag_update(&base->object->id, OB_RECALC_DATA);
}
}
else if (event == 19) { /* bevel settings */
@@ -909,7 +933,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event)
cu1->ext1 = cu->ext1;
cu1->ext2 = cu->ext2;
- base->object->recalc |= OB_RECALC_DATA;
+ DAG_id_tag_update(&base->object->id, OB_RECALC_DATA);
}
}
else if (event == 25) { /* curve resolution */
@@ -928,7 +952,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event)
nu = nu->next;
}
- base->object->recalc |= OB_RECALC_DATA;
+ DAG_id_tag_update(&base->object->id, OB_RECALC_DATA);
}
}
else if (event == 21) {
@@ -944,15 +968,15 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event)
}
modifier_copyData(md, tmd);
- base->object->recalc |= OB_RECALC_DATA;
+ DAG_id_tag_update(&base->object->id, OB_RECALC_DATA);
}
}
}
else if (event == 22) {
/* Copy the constraint channels over */
- copy_constraints(&base->object->constraints, &ob->constraints, TRUE);
+ BKE_copy_constraints(&base->object->constraints, &ob->constraints, TRUE);
- do_scene_sort = TRUE;
+ do_depgraph_update = true;
}
else if (event == 23) {
base->object->softflag = ob->softflag;
@@ -1004,13 +1028,11 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event)
}
}
- if (do_scene_sort)
- DAG_scene_sort(bmain, scene);
-
- DAG_ids_flush_update(bmain, 0);
+ if (do_depgraph_update)
+ DAG_relations_tag_update(bmain);
}
-static void UNUSED_FUNCTION(copy_attr_menu) (Main * bmain, Scene * scene, View3D * v3d)
+static void UNUSED_FUNCTION(copy_attr_menu) (Main *bmain, Scene *scene, View3D *v3d)
{
Object *ob;
short event;
@@ -1130,7 +1152,7 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene)
/* show popup to determine settings */
-static int object_calculate_paths_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
+static int object_calculate_paths_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
Object *ob = CTX_data_active_object(C);
@@ -1147,7 +1169,7 @@ static int object_calculate_paths_invoke(bContext *C, wmOperator *op, wmEvent *U
/* show popup dialog to allow editing of range... */
/* FIXME: hardcoded dimensions here are just arbitrary */
- return WM_operator_props_dialog_popup(C, op, 200, 200);
+ return WM_operator_props_dialog_popup(C, op, 10 * UI_UNIT_X, 10 * UI_UNIT_Y);
}
/* Calculate/recalculate whole paths (avs.path_sf to avs.path_ef) */
@@ -1356,7 +1378,7 @@ void OBJECT_OT_shade_smooth(wmOperatorType *ot)
/* ********************** */
-static void UNUSED_FUNCTION(image_aspect) (Scene * scene, View3D * v3d)
+static void UNUSED_FUNCTION(image_aspect) (Scene *scene, View3D *v3d)
{
/* all selected objects with an image map: scale in image aspect */
Base *base;
@@ -1672,10 +1694,6 @@ static EnumPropertyItem game_properties_copy_operations[] = {
{0, NULL, 0, NULL, NULL}
};
-static EnumPropertyItem gameprops_items[] = {
- {0, NULL, 0, NULL, NULL}
-};
-
static EnumPropertyItem *gameprops_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free)
{
Object *ob = ED_object_active_context(C);
@@ -1685,7 +1703,7 @@ static EnumPropertyItem *gameprops_itemf(bContext *C, PointerRNA *UNUSED(ptr), P
int a, totitem = 0;
if (!ob)
- return gameprops_items;
+ return DummyRNA_NULL_items;
for (a = 1, prop = ob->prop.first; prop; prop = prop->next, a++) {
tmp.value = a;
@@ -1756,7 +1774,7 @@ void OBJECT_OT_game_property_copy(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_enum(ot->srna, "operation", game_properties_copy_operations, 3, "Operation", "");
- prop = RNA_def_enum(ot->srna, "property", gameprops_items, 0, "Property", "Properties to copy");
+ prop = RNA_def_enum(ot->srna, "property", DummyRNA_NULL_items, 0, "Property", "Properties to copy");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
RNA_def_enum_funcs(prop, gameprops_itemf);
ot->prop = prop;
@@ -1864,9 +1882,7 @@ static int game_physics_copy_exec(bContext *C, wmOperator *UNUSED(op))
ob_iter->max_vel = ob->max_vel;
ob_iter->obstacleRad = ob->obstacleRad;
ob_iter->mass = ob->mass;
- ob_iter->anisotropicFriction[0] = ob->anisotropicFriction[0];
- ob_iter->anisotropicFriction[1] = ob->anisotropicFriction[1];
- ob_iter->anisotropicFriction[2] = ob->anisotropicFriction[2];
+ copy_v3_v3(ob_iter->anisotropicFriction, ob->anisotropicFriction);
ob_iter->collision_boundtype = ob->collision_boundtype;
ob_iter->margin = ob->margin;
ob_iter->bsoft = copy_bulletsoftbody(ob->bsoft);
@@ -1874,6 +1890,9 @@ static int game_physics_copy_exec(bContext *C, wmOperator *UNUSED(op))
ob_iter->restrictflag |= OB_RESTRICT_RENDER;
else
ob_iter->restrictflag &= ~OB_RESTRICT_RENDER;
+
+ ob_iter->col_group = ob->col_group;
+ ob_iter->col_mask = ob->col_mask;
}
}
CTX_DATA_END;