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.c189
1 files changed, 95 insertions, 94 deletions
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 7b90a522d49..d47a2576a8a 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -209,7 +209,7 @@ static bool ED_object_editmode_load_ex(Main *bmain, Object *obedit, const bool f
if (arm->edbo == NULL) {
return false;
}
- ED_armature_from_edit(obedit->data);
+ ED_armature_from_edit(bmain, obedit->data);
if (freedata) {
ED_armature_edit_free(obedit->data);
}
@@ -224,7 +224,7 @@ static bool ED_object_editmode_load_ex(Main *bmain, Object *obedit, const bool f
if (cu->editnurb == NULL) {
return false;
}
- ED_curve_editnurb_load(obedit);
+ ED_curve_editnurb_load(bmain, obedit);
if (freedata) {
ED_curve_editnurb_free(obedit);
}
@@ -272,13 +272,13 @@ bool ED_object_editmode_load(Main *bmain, Object *obedit)
* \param flag:
* - If #EM_FREEDATA isn't in the flag, use ED_object_editmode_load directly.
*/
-bool ED_object_editmode_exit_ex(Scene *scene, Object *obedit, int flag)
+bool ED_object_editmode_exit_ex(Main *bmain, Scene *scene, Object *obedit, int flag)
{
const bool freedata = (flag & EM_FREEDATA) != 0;
if (flag & EM_WAITCURSOR) waitcursor(1);
- if (ED_object_editmode_load_ex(G.main, obedit, freedata) == false) {
+ if (ED_object_editmode_load_ex(bmain, obedit, freedata) == false) {
/* in rare cases (background mode) its possible active object
* is flagged for editmode, without 'obedit' being set [#35489] */
if (UNLIKELY(obedit && obedit->mode & OB_MODE_EDIT)) {
@@ -318,9 +318,10 @@ bool ED_object_editmode_exit_ex(Scene *scene, Object *obedit, int flag)
bool ED_object_editmode_exit(bContext *C, int flag)
{
+ Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
Object *obedit = CTX_data_edit_object(C);
- return ED_object_editmode_exit_ex(scene, obedit, flag);
+ return ED_object_editmode_exit_ex(bmain, scene, obedit, flag);
}
bool ED_object_editmode_enter_ex(Main *bmain, Scene *scene, Object *ob, int flag)
@@ -465,7 +466,7 @@ static int editmode_toggle_exec(bContext *C, wmOperator *op)
FOREACH_OBJECT_BEGIN(view_layer, ob)
{
if ((ob != obact) && (ob->type == obact->type)) {
- ED_object_editmode_exit_ex(scene, ob, EM_FREEDATA | EM_WAITCURSOR);
+ ED_object_editmode_exit_ex(bmain, scene, ob, EM_FREEDATA | EM_WAITCURSOR);
}
}
FOREACH_OBJECT_END;
@@ -499,16 +500,16 @@ static int editmode_toggle_poll(bContext *C)
void OBJECT_OT_editmode_toggle(wmOperatorType *ot)
{
-
+
/* identifiers */
ot->name = "Toggle Editmode";
ot->description = "Toggle object's editmode";
ot->idname = "OBJECT_OT_editmode_toggle";
-
+
/* api callbacks */
ot->exec = editmode_toggle_exec;
ot->poll = editmode_toggle_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -522,7 +523,7 @@ static int posemode_exec(bContext *C, wmOperator *op)
Object *obact = base->object;
const int mode_flag = OB_MODE_POSE;
bool is_mode_set = (obact->mode & mode_flag) != 0;
-
+
if (!is_mode_set) {
if (!ED_object_mode_compat_set(C, obact, mode_flag, op->reports)) {
return OPERATOR_CANCELLED;
@@ -581,17 +582,17 @@ static int posemode_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-void OBJECT_OT_posemode_toggle(wmOperatorType *ot)
+void OBJECT_OT_posemode_toggle(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Toggle Pose Mode";
ot->idname = "OBJECT_OT_posemode_toggle";
ot->description = "Enable or disable posing/selecting bones";
-
+
/* api callbacks */
ot->exec = posemode_exec;
ot->poll = ED_operator_object_active_editable;
-
+
/* flag */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -601,7 +602,7 @@ static void copy_texture_space(Object *to, Object *ob)
{
float *poin1 = NULL, *poin2 = NULL;
short texflag = 0;
-
+
if (ob->type == OB_MESH) {
texflag = ((Mesh *)ob->data)->texflag;
poin2 = ((Mesh *)ob->data)->loc;
@@ -616,7 +617,7 @@ static void copy_texture_space(Object *to, Object *ob)
}
else
return;
-
+
if (to->type == OB_MESH) {
((Mesh *)to->data)->texflag = texflag;
poin1 = ((Mesh *)to->data)->loc;
@@ -631,9 +632,9 @@ static void copy_texture_space(Object *to, Object *ob)
}
else
return;
-
+
memcpy(poin1, poin2, 9 * sizeof(float)); /* this was noted in DNA_mesh, curve, mball */
-
+
if (to->type == OB_MESH) {
/* pass */
}
@@ -643,7 +644,7 @@ static void copy_texture_space(Object *to, Object *ob)
else {
BKE_curve_texspace_calc(to->data);
}
-
+
}
/* UNUSED, keep in case we want to copy functionality for use elsewhere */
@@ -654,11 +655,11 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev
Curve *cu, *cu1;
Nurb *nu;
bool do_depgraph_update = false;
-
+
if (ID_IS_LINKED(scene)) return;
if (!(ob = OBACT(view_layer))) return;
-
+
if (BKE_object_is_in_editmode(ob)) {
/* obedit_copymenu(); */
return;
@@ -674,7 +675,7 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev
if (base != BASACT(view_layer)) {
if (TESTBASELIB(base)) {
DEG_id_tag_update(&base->object->id, OB_RECALC_DATA);
-
+
if (event == 1) { /* loc */
copy_v3_v3(base->object->loc, ob->loc);
copy_v3_v3(base->object->dloc, ob->dloc);
@@ -704,7 +705,7 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev
base->object->dupoff = ob->dupoff;
base->object->dupsta = ob->dupsta;
base->object->dupend = ob->dupend;
-
+
base->object->transflag &= ~OB_DUPLI;
base->object->transflag |= (ob->transflag & OB_DUPLI);
@@ -716,7 +717,7 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev
copy_texture_space(base->object, ob);
}
else if (event == 18) { /* font settings */
-
+
if (base->object->type == ob->type) {
cu = ob->data;
cu1 = base->object->data;
@@ -749,25 +750,25 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev
id_us_min(&cu1->vfontbi->id);
cu1->vfontbi = cu->vfontbi;
id_us_plus((ID *)cu1->vfontbi);
-
+
BLI_strncpy(cu1->family, cu->family, sizeof(cu1->family));
-
+
DEG_id_tag_update(&base->object->id, OB_RECALC_DATA);
}
}
else if (event == 19) { /* bevel settings */
-
+
if (ELEM(base->object->type, OB_CURVE, OB_FONT)) {
cu = ob->data;
cu1 = base->object->data;
-
+
cu1->bevobj = cu->bevobj;
cu1->taperobj = cu->taperobj;
cu1->width = cu->width;
cu1->bevresol = cu->bevresol;
cu1->ext1 = cu->ext1;
cu1->ext2 = cu->ext2;
-
+
DEG_id_tag_update(&base->object->id, OB_RECALC_DATA);
}
}
@@ -776,17 +777,17 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev
if (ELEM(base->object->type, OB_CURVE, OB_FONT)) {
cu = ob->data;
cu1 = base->object->data;
-
+
cu1->resolu = cu->resolu;
cu1->resolu_ren = cu->resolu_ren;
-
+
nu = cu1->nurb.first;
-
+
while (nu) {
nu->resolu = cu1->resolu;
nu = nu->next;
}
-
+
DEG_id_tag_update(&base->object->id, OB_RECALC_DATA);
}
}
@@ -810,13 +811,13 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev
else if (event == 22) {
/* Copy the constraint channels over */
BKE_constraints_copy(&base->object->constraints, &ob->constraints, true);
-
+
do_depgraph_update = true;
}
else if (event == 23) {
base->object->softflag = ob->softflag;
if (base->object->soft) sbFree(base->object->soft);
-
+
base->object->soft = copy_softbody(ob->soft, 0);
if (!modifiers_findByType(base->object, eModifierType_Softbody)) {
@@ -843,7 +844,7 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev
if (ELEM(base->object->type, OB_CURVE, OB_SURF)) {
cu = ob->data;
cu1 = base->object->data;
-
+
if (cu->flag & CU_UV_ORCO)
cu1->flag |= CU_UV_ORCO;
else
@@ -862,7 +863,7 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev
}
}
}
-
+
if (do_depgraph_update)
DEG_relations_tag_update(bmain);
}
@@ -872,36 +873,36 @@ static void UNUSED_FUNCTION(copy_attr_menu) (Main *bmain, Scene *scene, ViewLaye
Object *ob;
short event;
char str[512];
-
+
if (!(ob = OBACT(view_layer))) return;
-
+
if (obedit) {
/* if (ob->type == OB_MESH) */
/* XXX mesh_copy_menu(); */
return;
}
-
+
/* Object Mode */
-
+
/* If you change this menu, don't forget to update the menu in header_view3d.c
* view3d_edit_object_copyattrmenu() and in toolbox.c
*/
-
+
strcpy(str,
"Copy Attributes %t|Location %x1|Rotation %x2|Size %x3|Draw Options %x4|"
"Time Offset %x5|Dupli %x6|Object Color %x31|%l|Mass %x7|Damping %x8|All Physical Attributes %x11|Properties %x9|"
"Logic Bricks %x10|Protected Transform %x29|%l");
-
+
strcat(str, "|Object Constraints %x22");
strcat(str, "|NLA Strips %x26");
-
+
/* XXX if (OB_TYPE_SUPPORT_MATERIAL(ob->type)) { */
/* strcat(str, "|Texture Space %x17"); */
/* } */
-
+
if (ob->type == OB_FONT) strcat(str, "|Font Settings %x18|Bevel Settings %x19");
if (ob->type == OB_CURVE) strcat(str, "|Bevel Settings %x19|UV Orco %x28");
-
+
if ((ob->type == OB_FONT) || (ob->type == OB_CURVE)) {
strcat(str, "|Curve Resolution %x25");
}
@@ -911,16 +912,16 @@ static void UNUSED_FUNCTION(copy_attr_menu) (Main *bmain, Scene *scene, ViewLaye
}
if (ob->soft) strcat(str, "|Soft Body Settings %x23");
-
+
strcat(str, "|Pass Index %x30");
-
+
if (ob->type == OB_MESH || ob->type == OB_CURVE || ob->type == OB_LATTICE || ob->type == OB_SURF) {
strcat(str, "|Modifiers ... %x24");
}
event = pupmenu(str);
if (event <= 0) return;
-
+
copy_attr(bmain, scene, view_layer, event);
}
@@ -966,16 +967,16 @@ static int forcefield_toggle_exec(bContext *C, wmOperator *UNUSED(op))
void OBJECT_OT_forcefield_toggle(wmOperatorType *ot)
{
-
+
/* identifiers */
ot->name = "Toggle Force Field";
ot->description = "Toggle object's force field";
ot->idname = "OBJECT_OT_forcefield_toggle";
-
+
/* api callbacks */
ot->exec = forcefield_toggle_exec;
ot->poll = ED_operator_object_active_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -993,7 +994,7 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene)
struct Main *bmain = CTX_data_main(C);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
ListBase targets = {NULL, NULL};
-
+
/* loop over objects in scene */
CTX_DATA_BEGIN(C, Object *, ob, selected_editable_objects)
{
@@ -1002,11 +1003,11 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene)
animviz_get_object_motionpaths(ob, &targets);
}
CTX_DATA_END;
-
+
/* recalculate paths, then free */
animviz_calc_motionpaths(depsgraph, bmain, scene, &targets);
BLI_freelistN(&targets);
-
+
/* tag objects for copy on write - so paths will draw/redraw */
CTX_DATA_BEGIN(C, Object *, ob, selected_editable_objects)
{
@@ -1022,18 +1023,18 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene)
static int object_calculate_paths_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
Object *ob = CTX_data_active_object(C);
-
+
if (ob == NULL)
return OPERATOR_CANCELLED;
-
+
/* set default settings from existing/stored settings */
{
bAnimVizSettings *avs = &ob->avs;
-
+
RNA_int_set(op->ptr, "start_frame", avs->path_sf);
RNA_int_set(op->ptr, "end_frame", avs->path_ef);
}
-
+
/* show popup dialog to allow editing of range... */
/* FIXME: hardcoded dimensions here are just arbitrary */
return WM_operator_props_dialog_popup(C, op, 10 * UI_UNIT_X, 10 * UI_UNIT_Y);
@@ -1045,28 +1046,28 @@ static int object_calculate_paths_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
int start = RNA_int_get(op->ptr, "start_frame");
int end = RNA_int_get(op->ptr, "end_frame");
-
+
/* set up path data for bones being calculated */
CTX_DATA_BEGIN(C, Object *, ob, selected_editable_objects)
{
bAnimVizSettings *avs = &ob->avs;
-
+
/* grab baking settings from operator settings */
avs->path_sf = start;
avs->path_ef = end;
-
+
/* verify that the selected object has the appropriate settings */
animviz_verify_motionpaths(op->reports, scene, ob, NULL);
}
CTX_DATA_END;
-
+
/* calculate the paths for objects that have them (and are tagged to get refreshed) */
ED_objects_recalculate_paths(C, scene);
-
+
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
-
- return OPERATOR_FINISHED;
+
+ return OPERATOR_FINISHED;
}
void OBJECT_OT_paths_calculate(wmOperatorType *ot)
@@ -1075,19 +1076,19 @@ void OBJECT_OT_paths_calculate(wmOperatorType *ot)
ot->name = "Calculate Object Paths";
ot->idname = "OBJECT_OT_paths_calculate";
ot->description = "Calculate motion paths for the selected objects";
-
+
/* api callbacks */
ot->invoke = object_calculate_paths_invoke;
ot->exec = object_calculate_paths_exec;
ot->poll = ED_operator_object_active_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
- RNA_def_int(ot->srna, "start_frame", 1, MINAFRAME, MAXFRAME, "Start",
+ RNA_def_int(ot->srna, "start_frame", 1, MINAFRAME, MAXFRAME, "Start",
"First frame to calculate object paths on", MINFRAME, MAXFRAME / 2.0);
- RNA_def_int(ot->srna, "end_frame", 250, MINAFRAME, MAXFRAME, "End",
+ RNA_def_int(ot->srna, "end_frame", 250, MINAFRAME, MAXFRAME, "End",
"Last frame to calculate object paths on", MINFRAME, MAXFRAME / 2.0);
}
@@ -1099,23 +1100,23 @@ static int object_update_paths_poll(bContext *C)
Object *ob = ED_object_active_context(C);
return (ob->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS) != 0;
}
-
+
return false;
}
static int object_update_paths_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
-
+
if (scene == NULL)
return OPERATOR_CANCELLED;
-
+
/* calculate the paths for objects that have them (and are tagged to get refreshed) */
ED_objects_recalculate_paths(C, scene);
-
+
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -1125,11 +1126,11 @@ void OBJECT_OT_paths_update(wmOperatorType *ot)
ot->name = "Update Object Paths";
ot->idname = "OBJECT_OT_paths_update";
ot->description = "Recalculate paths for selected objects";
-
+
/* api callbakcs */
ot->exec = object_update_paths_exec;
ot->poll = object_update_paths_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1171,14 +1172,14 @@ void ED_objects_clear_paths(bContext *C, bool only_selected)
static int object_clear_paths_exec(bContext *C, wmOperator *op)
{
bool only_selected = RNA_boolean_get(op->ptr, "only_selected");
-
+
/* use the backend function for this */
ED_objects_clear_paths(C, only_selected);
-
+
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
-
- return OPERATOR_FINISHED;
+
+ return OPERATOR_FINISHED;
}
/* operator callback/wrapper */
@@ -1196,15 +1197,15 @@ void OBJECT_OT_paths_clear(wmOperatorType *ot)
ot->name = "Clear Object Paths";
ot->idname = "OBJECT_OT_paths_clear";
ot->description = "Clear path caches for all objects, hold Shift key for selected objects only";
-
+
/* api callbacks */
ot->invoke = object_clear_paths_invoke;
ot->exec = object_clear_paths_exec;
ot->poll = ED_operator_object_active_editable;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
ot->prop = RNA_def_boolean(ot->srna, "only_selected", false, "Only Selected",
"Only clear paths from selected objects");
@@ -1273,7 +1274,7 @@ void OBJECT_OT_shade_flat(wmOperatorType *ot)
ot->name = "Shade Flat";
ot->description = "Render and display faces uniform, using Face Normals";
ot->idname = "OBJECT_OT_shade_flat";
-
+
/* api callbacks */
ot->poll = shade_poll;
ot->exec = shade_smooth_exec;
@@ -1288,11 +1289,11 @@ void OBJECT_OT_shade_smooth(wmOperatorType *ot)
ot->name = "Shade Smooth";
ot->description = "Render and display faces smooth, using interpolated Vertex Normals";
ot->idname = "OBJECT_OT_shade_smooth";
-
+
/* api callbacks */
ot->poll = shade_poll;
ot->exec = shade_smooth_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1333,7 +1334,7 @@ static const EnumPropertyItem *object_mode_set_itemsf(
/* We need at least this one! */
RNA_enum_items_add_value(&item, &totitem, input, OB_MODE_OBJECT);
}
-
+
/* On top of all the rest, GPencil Stroke Edit Mode
* is available if there's a valid gp datablock...
*/
@@ -1403,7 +1404,7 @@ static int object_mode_set_exec(bContext *C, wmOperator *op)
WM_operator_name_call(C, "GPENCIL_OT_editmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
}
}
-
+
if (!ob || !ED_object_mode_compat_test(ob, mode))
return OPERATOR_PASS_THROUGH;
@@ -1438,20 +1439,20 @@ static int object_mode_set_exec(bContext *C, wmOperator *op)
void OBJECT_OT_mode_set(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Set Object Mode";
ot->description = "Sets the object interaction mode";
ot->idname = "OBJECT_OT_mode_set";
-
+
/* api callbacks */
ot->exec = object_mode_set_exec;
-
+
ot->poll = object_mode_set_poll; //ED_operator_object_active_editable;
-
+
/* flags */
ot->flag = 0; /* no register/undo here, leave it to operators being called */
-
+
ot->prop = RNA_def_enum(ot->srna, "mode", rna_enum_object_mode_items, OB_MODE_OBJECT, "Mode", "");
RNA_def_enum_funcs(ot->prop, object_mode_set_itemsf);
RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE);