diff options
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r-- | source/blender/editors/object/object_add.c | 16 | ||||
-rw-r--r-- | source/blender/editors/object/object_bake.c | 4 | ||||
-rw-r--r-- | source/blender/editors/object/object_bake_api.c | 2 | ||||
-rw-r--r-- | source/blender/editors/object/object_constraint.c | 406 | ||||
-rw-r--r-- | source/blender/editors/object/object_edit.c | 270 | ||||
-rw-r--r-- | source/blender/editors/object/object_group.c | 44 | ||||
-rw-r--r-- | source/blender/editors/object/object_hook.c | 178 | ||||
-rw-r--r-- | source/blender/editors/object/object_modifier.c | 268 | ||||
-rw-r--r-- | source/blender/editors/object/object_ops.c | 38 | ||||
-rw-r--r-- | source/blender/editors/object/object_select.c | 130 | ||||
-rw-r--r-- | source/blender/editors/object/object_shapekey.c | 16 | ||||
-rw-r--r-- | source/blender/editors/object/object_transform.c | 98 | ||||
-rw-r--r-- | source/blender/editors/object/object_vgroup.c | 72 |
13 files changed, 771 insertions, 771 deletions
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 38f09570aca..cd163298642 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -971,13 +971,13 @@ static int group_instance_add_exec(bContext *C, wmOperator *op) Group *group; unsigned int layer; float loc[3], rot[3]; - + if (RNA_struct_property_is_set(op->ptr, "name")) { char name[MAX_ID_NAME - 2]; - + RNA_string_get(op->ptr, "name", name); group = (Group *)BKE_libblock_find_name(bmain, ID_GR, name); - + if (0 == RNA_struct_property_is_set(op->ptr, "location")) { const wmEvent *event = CTX_wm_window(C)->eventstate; ARegion *ar = CTX_wm_region(C); @@ -1136,7 +1136,7 @@ static int object_delete_exec(bContext *C, wmOperator *op) const bool use_global = RNA_boolean_get(op->ptr, "use_global"); bool changed = false; - if (CTX_data_edit_object(C)) + if (CTX_data_edit_object(C)) return OPERATOR_CANCELLED; CTX_DATA_BEGIN (C, Base *, base, selected_bases) @@ -1217,10 +1217,10 @@ static int object_delete_exec(bContext *C, wmOperator *op) BKE_main_id_tag_listbase(&bmain->scene, LIB_TAG_DOIT, true); for (win = wm->windows.first; win; win = win->next) { scene = win->screen->scene; - + if (scene->id.tag & LIB_TAG_DOIT) { scene->id.tag &= ~LIB_TAG_DOIT; - + DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene); @@ -1989,7 +1989,7 @@ void OBJECT_OT_convert(wmOperatorType *ot) /**************************** Duplicate ************************/ -/* +/* * dupflag: a flag made from constants declared in DNA_userdef_types.h * The flag tells adduplicate() whether to copy data linked to the object, or to reference the existing data. * U.dupflag for default operations or you can construct a flag as python does @@ -2386,7 +2386,7 @@ static int add_named_exec(bContext *C, wmOperator *op) ED_object_location_from_view(C, basen->object->loc); ED_view3d_cursor3d_position(C, basen->object->loc, mval); } - + ED_base_object_select(basen, BA_SELECT); ED_base_object_activate(C, basen); diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index 66a87d956f3..ee0dfe14cd3 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -557,7 +557,7 @@ typedef struct BakeRender { short *stop; short *do_update; float *progress; - + ListBase threads; /* backup */ @@ -662,7 +662,7 @@ static void finish_bake_internal(BakeRender *bkr) } BKE_image_release_ibuf(ima, ibuf, NULL); - DAG_id_tag_update(&ima->id, 0); + DAG_id_tag_update(&ima->id, 0); } } diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c index d24fc96b007..3e0f62154ac 100644 --- a/source/blender/editors/object/object_bake_api.c +++ b/source/blender/editors/object/object_bake_api.c @@ -272,7 +272,7 @@ static void refresh_images(BakeImages *bake_images) Image *ima = bake_images->data[i].image; if (ima->ok == IMA_OK_LOADED) { GPU_free_image(ima); - DAG_id_tag_update(&ima->id, 0); + DAG_id_tag_update(&ima->id, 0); } } } diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 1ec47cde029..d0588806313 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -89,17 +89,17 @@ ListBase *get_active_constraints(Object *ob) { if (ob == NULL) return NULL; - + if (ob->mode & OB_MODE_POSE) { bPoseChannel *pchan; - + pchan = BKE_pose_channel_active(ob); if (pchan) return &pchan->constraints; } - else + else return &ob->constraints; - + return NULL; } @@ -108,33 +108,33 @@ ListBase *get_constraint_lb(Object *ob, bConstraint *con, bPoseChannel **r_pchan { if (r_pchan) *r_pchan = NULL; - + if (ELEM(NULL, ob, con)) return NULL; - + /* try object constraints first */ if ((BLI_findindex(&ob->constraints, con) != -1)) { return &ob->constraints; } - + /* if armature, try pose bones too */ if (ob->pose) { bPoseChannel *pchan; - - /* try each bone in order + + /* try each bone in order * NOTE: it's not possible to directly look up the active bone yet, so this will have to do */ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if ((BLI_findindex(&pchan->constraints, con) != -1)) { - + if (r_pchan) *r_pchan = pchan; - + return &pchan->constraints; } } } - + /* done */ return NULL; } @@ -156,7 +156,7 @@ static void validate_pyconstraint_cb(void *arg1, void *arg2) Text *text = NULL; int index = *((int *)arg2); int i; - + /* exception for no script */ if (index) { /* innovative use of a for...loop to search */ @@ -173,36 +173,36 @@ static char *buildmenu_pyconstraints(Text *con_text, int *pyconindex) char *str; char buf[64]; int i; - + /* add title first */ sprintf(buf, "Scripts: %%t|[None]%%x0|"); BLI_dynstr_append(pupds, buf); - + /* init active-index first */ if (con_text == NULL) *pyconindex = 0; - + /* loop through markers, adding them */ for (text = G.main->text.first, i = 1; text; i++, text = text->id.next) { /* this is important to ensure that right script is shown as active */ if (text == con_text) *pyconindex = i; - + /* only include valid pyconstraint scripts */ if (BPY_is_pyconstraint(text)) { BLI_dynstr_append(pupds, text->id.name + 2); - + sprintf(buf, "%%x%d", i); BLI_dynstr_append(pupds, buf); - + if (text->id.next) BLI_dynstr_append(pupds, "|"); } } - + /* convert to normal MEM_malloc'd string */ str = BLI_dynstr_get_cstring(pupds); BLI_dynstr_free(pupds); - + return str; } #endif /* WITH_PYTHON */ @@ -230,11 +230,11 @@ static void set_constraint_nth_target(bConstraint *con, Object *target, const ch ListBase targets = {NULL, NULL}; bConstraintTarget *ct; int num_targets, i; - + if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); num_targets = BLI_listbase_count(&targets); - + if (index < 0) { if (abs(index) < num_targets) index = num_targets - abs(index); @@ -244,7 +244,7 @@ static void set_constraint_nth_target(bConstraint *con, Object *target, const ch else if (index >= num_targets) { index = num_targets - 1; } - + for (ct = targets.first, i = 0; ct; ct = ct->next, i++) { if (i == index) { ct->tar = target; @@ -252,7 +252,7 @@ static void set_constraint_nth_target(bConstraint *con, Object *target, const ch break; } } - + if (cti->flush_constraint_targets) cti->flush_constraint_targets(con, &targets, 0); } @@ -506,7 +506,7 @@ static void test_constraints(Main *bmain, Object *owner, bPoseChannel *pchan) bConstraint *curcon; ListBase *conlist = NULL; int type; - + if (owner == NULL) return; type = constraint_type_get(owner, pchan); @@ -520,7 +520,7 @@ static void test_constraints(Main *bmain, Object *owner, bPoseChannel *pchan) conlist = &pchan->constraints; break; } - + /* Check all constraints - is constraint valid? */ if (conlist) { for (curcon = conlist->first; curcon; curcon = curcon->next) { @@ -533,10 +533,10 @@ void object_test_constraints(Main *bmain, Object *owner) { if (owner->constraints.first) test_constraints(bmain, owner, NULL); - + if (owner->type == OB_ARMATURE && owner->pose) { bPoseChannel *pchan; - + for (pchan = owner->pose->chanbase.first; pchan; pchan = pchan->next) { if (pchan->constraints.first) test_constraints(bmain, owner, pchan); @@ -616,24 +616,24 @@ static int edit_constraint_invoke_properties(bContext *C, wmOperator *op) Object *ob = (ptr.id.data) ? ptr.id.data : ED_object_active_context(C); bConstraint *con; ListBase *list; - + if (RNA_struct_property_is_set(op->ptr, "constraint") && RNA_struct_property_is_set(op->ptr, "owner")) return 1; - + if (ptr.data) { con = ptr.data; RNA_string_set(op->ptr, "constraint", con->name); - + list = get_constraint_lb(ob, con, NULL); - + if (&ob->constraints == list) RNA_enum_set(op->ptr, "owner", EDIT_CONSTRAINT_OWNER_OBJECT); else RNA_enum_set(op->ptr, "owner", EDIT_CONSTRAINT_OWNER_BONE); - + return 1; } - + return 0; } @@ -643,9 +643,9 @@ static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int int owner = RNA_enum_get(op->ptr, "owner"); bConstraint *con; ListBase *list = NULL; - + RNA_string_get(op->ptr, "constraint", constraint_name); - + if (owner == EDIT_CONSTRAINT_OWNER_OBJECT) { list = &ob->constraints; } @@ -664,14 +664,14 @@ static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int //printf("edit_constraint_property_get: defaulting to getting list in the standard way\n"); list = get_active_constraints(ob); } - + con = BKE_constraints_find_name(list, constraint_name); //if (G.debug & G_DEBUG) //printf("constraint found = %p, %s\n", (void *)con, (con) ? con->name : "<Not found>"); if (con && (type != 0) && (con->type != type)) con = NULL; - + return con; } @@ -686,15 +686,15 @@ static int stretchto_reset_exec(bContext *C, wmOperator *op) Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_STRETCHTO); bStretchToConstraint *data = (con) ? (bStretchToConstraint *)con->data : NULL; - + /* despite 3 layers of checks, we may still not be able to find a constraint */ if (data == NULL) return OPERATOR_CANCELLED; - + /* just set original length to 0.0, which will cause a reset on next recalc */ data->orglength = 0.0f; ED_object_constraint_update(bmain, ob); - + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, NULL); return OPERATOR_FINISHED; } @@ -713,15 +713,15 @@ void CONSTRAINT_OT_stretchto_reset(wmOperatorType *ot) ot->name = "Reset Original Length"; ot->idname = "CONSTRAINT_OT_stretchto_reset"; ot->description = "Reset original length of bone for Stretch To Constraint"; - + /* callbacks */ ot->invoke = stretchto_reset_invoke; ot->exec = stretchto_reset_exec; ot->poll = edit_constraint_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ edit_constraint_properties(ot); } @@ -733,15 +733,15 @@ static int limitdistance_reset_exec(bContext *C, wmOperator *op) Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_DISTLIMIT); bDistLimitConstraint *data = (con) ? (bDistLimitConstraint *)con->data : NULL; - + /* despite 3 layers of checks, we may still not be able to find a constraint */ if (data == NULL) return OPERATOR_CANCELLED; - + /* just set original length to 0.0, which will cause a reset on next recalc */ data->dist = 0.0f; ED_object_constraint_update(bmain, ob); - + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, NULL); return OPERATOR_FINISHED; } @@ -760,15 +760,15 @@ void CONSTRAINT_OT_limitdistance_reset(wmOperatorType *ot) ot->name = "Reset Distance"; ot->idname = "CONSTRAINT_OT_limitdistance_reset"; ot->description = "Reset limiting distance for Limit Distance Constraint"; - + /* callbacks */ ot->invoke = limitdistance_reset_invoke; ot->exec = limitdistance_reset_exec; ot->poll = edit_constraint_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ edit_constraint_properties(ot); } @@ -779,7 +779,7 @@ static void child_get_inverse_matrix(Scene *scene, Object *ob, bConstraint *con, { /* nullify inverse matrix first */ unit_m4(invmat); - + if (owner == EDIT_CONSTRAINT_OWNER_BONE) { bPoseChannel *pchan; /* try to find a pose channel - assume that this is the constraint owner */ @@ -874,11 +874,11 @@ static int childof_set_inverse_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "Could not find constraint data for Child-Of Set Inverse"); return OPERATOR_CANCELLED; } - + child_get_inverse_matrix(scene, ob, con, data->invmat, owner); WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); - + return OPERATOR_FINISHED; } @@ -896,15 +896,15 @@ void CONSTRAINT_OT_childof_set_inverse(wmOperatorType *ot) ot->name = "Set Inverse"; ot->idname = "CONSTRAINT_OT_childof_set_inverse"; ot->description = "Set inverse correction for ChildOf constraint"; - + /* callbacks */ ot->invoke = childof_set_inverse_invoke; ot->exec = childof_set_inverse_exec; ot->poll = edit_constraint_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ edit_constraint_properties(ot); } @@ -915,17 +915,17 @@ static int childof_clear_inverse_exec(bContext *C, wmOperator *op) Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_CHILDOF); bChildOfConstraint *data = (con) ? (bChildOfConstraint *)con->data : NULL; - + if (data == NULL) { BKE_report(op->reports, RPT_ERROR, "Child Of constraint not found"); return OPERATOR_CANCELLED; } - + /* simply clear the matrix */ unit_m4(data->invmat); - + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); - + return OPERATOR_FINISHED; } @@ -943,15 +943,15 @@ void CONSTRAINT_OT_childof_clear_inverse(wmOperatorType *ot) ot->name = "Clear Inverse"; ot->idname = "CONSTRAINT_OT_childof_clear_inverse"; ot->description = "Clear inverse correction for ChildOf constraint"; - + /* callbacks */ ot->invoke = childof_clear_inverse_invoke; ot->exec = childof_clear_inverse_exec; ot->poll = edit_constraint_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ edit_constraint_properties(ot); } @@ -963,30 +963,30 @@ static int followpath_path_animate_exec(bContext *C, wmOperator *op) Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_FOLLOWPATH); bFollowPathConstraint *data = (con) ? (bFollowPathConstraint *)con->data : NULL; - + bAction *act = NULL; FCurve *fcu = NULL; int sfra = RNA_int_get(op->ptr, "frame_start"); int len = RNA_int_get(op->ptr, "length"); float standardRange = 1.0; - + /* nearly impossible sanity check */ if (data == NULL) { BKE_report(op->reports, RPT_ERROR, "Follow Path constraint not found"); return OPERATOR_CANCELLED; } - + /* add F-Curve as appropriate */ if (data->tar) { Curve *cu = (Curve *)data->tar->data; - + if (ELEM(NULL, cu->adt, cu->adt->action) || (list_find_fcurve(&cu->adt->action->curves, "eval_time", 0) == NULL)) { /* create F-Curve for path animation */ act = verify_adt_action(&cu->id, 1); fcu = verify_fcurve(act, NULL, NULL, "eval_time", 0, 1); - + /* standard vertical range - 1:1 = 100 frames */ standardRange = 100.0f; } @@ -1001,46 +1001,46 @@ static int followpath_path_animate_exec(bContext *C, wmOperator *op) PointerRNA ptr; PropertyRNA *prop; char *path; - + /* get RNA pointer to constraint's "offset_factor" property - to build RNA path */ RNA_pointer_create(&ob->id, &RNA_FollowPathConstraint, con, &ptr); prop = RNA_struct_find_property(&ptr, "offset_factor"); - + path = RNA_path_from_ID_to_property(&ptr, prop); - + /* create F-Curve for constraint */ act = verify_adt_action(&ob->id, 1); fcu = verify_fcurve(act, NULL, NULL, path, 0, 1); - + /* standard vertical range - 0.0 to 1.0 */ standardRange = 1.0f; - + /* enable "Use Fixed Position" so that animating this has effect */ data->followflag |= FOLLOWPATH_STATIC; - + /* path needs to be freed */ - if (path) + if (path) MEM_freeN(path); } - + /* setup dummy 'generator' modifier here to get 1-1 correspondence still working * and define basic slope of this curve based on the properties */ if (!fcu->bezt && !fcu->fpt && !fcu->modifiers.first) { FModifier *fcm = add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_GENERATOR, fcu); FMod_Generator *gen = fcm->data; - + /* Assume that we have the following equation: * y = Ax + B * 1 0 <-- coefficients array indices */ float A = standardRange / (float)(len); float B = (float)(-sfra) * A; - + gen->coefficients[1] = A; gen->coefficients[0] = B; } - + /* updates... */ WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); return OPERATOR_FINISHED; @@ -1063,20 +1063,20 @@ void CONSTRAINT_OT_followpath_path_animate(wmOperatorType *ot) ot->name = "Auto Animate Path"; ot->idname = "CONSTRAINT_OT_followpath_path_animate"; ot->description = "Add default animation for path used by constraint if it isn't animated already"; - + /* callbacks */ ot->invoke = followpath_path_animate_invoke; ot->exec = followpath_path_animate_exec; ot->poll = edit_constraint_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ edit_constraint_properties(ot); - RNA_def_int(ot->srna, "frame_start", 1, MINAFRAME, MAXFRAME, "Start Frame", + RNA_def_int(ot->srna, "frame_start", 1, MINAFRAME, MAXFRAME, "Start Frame", "First frame of path animation", MINAFRAME, MAXFRAME); - RNA_def_int(ot->srna, "length", 100, 0, MAXFRAME, "Length", + RNA_def_int(ot->srna, "length", 100, 0, MAXFRAME, "Length", "Number of frames that path animation should take", 0, MAXFRAME); } @@ -1118,7 +1118,7 @@ void CONSTRAINT_OT_objectsolver_set_inverse(wmOperatorType *ot) ot->name = "Set Inverse"; ot->idname = "CONSTRAINT_OT_objectsolver_set_inverse"; ot->description = "Set inverse correction for ObjectSolver constraint"; - + /* callbacks */ ot->invoke = objectsolver_set_inverse_invoke; ot->exec = objectsolver_set_inverse_exec; @@ -1126,7 +1126,7 @@ void CONSTRAINT_OT_objectsolver_set_inverse(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ edit_constraint_properties(ot); } @@ -1164,7 +1164,7 @@ void CONSTRAINT_OT_objectsolver_clear_inverse(wmOperatorType *ot) ot->name = "Clear Inverse"; ot->idname = "CONSTRAINT_OT_objectsolver_clear_inverse"; ot->description = "Clear inverse correction for ObjectSolver constraint"; - + /* callbacks */ ot->invoke = objectsolver_clear_inverse_invoke; ot->exec = objectsolver_clear_inverse_exec; @@ -1172,7 +1172,7 @@ void CONSTRAINT_OT_objectsolver_clear_inverse(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ edit_constraint_properties(ot); } @@ -1180,14 +1180,14 @@ void CONSTRAINT_OT_objectsolver_clear_inverse(wmOperatorType *ot) /***************************** BUTTONS ****************************/ void ED_object_constraint_set_active(Object *ob, bConstraint *con) -{ +{ ListBase *lb = get_constraint_lb(ob, con, NULL); - + /* lets be nice and escape if its active already */ /* NOTE: this assumes that the stack doesn't have other active ones set... */ if ((lb && con) && (con->flag & CONSTRAINT_ACTIVE)) return; - + BKE_constraints_active_set(lb, con); } @@ -1197,9 +1197,9 @@ void ED_object_constraint_update(Main *bmain, Object *ob) object_test_constraints(bmain, ob); - if (ob->type == OB_ARMATURE) + if (ob->type == OB_ARMATURE) DAG_id_tag_update(&ob->id, OB_RECALC_DATA | OB_RECALC_OB); - else + else DAG_id_tag_update(&ob->id, OB_RECALC_OB); } @@ -1276,7 +1276,7 @@ static int constraint_delete_exec(bContext *C, wmOperator *UNUSED(op)) /* notifiers */ WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, ob); - + return OPERATOR_FINISHED; } else { @@ -1291,11 +1291,11 @@ void CONSTRAINT_OT_delete(wmOperatorType *ot) ot->name = "Delete Constraint"; ot->idname = "CONSTRAINT_OT_delete"; ot->description = "Remove constraint from constraint stack"; - + /* callbacks */ ot->exec = constraint_delete_exec; ot->poll = constraint_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1305,20 +1305,20 @@ static int constraint_move_down_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(op, ob, 0); - + if (con && con->next) { ListBase *conlist = get_constraint_lb(ob, con, NULL); bConstraint *nextCon = con->next; - + /* insert the nominated constraint after the one that used to be after it */ BLI_remlink(conlist, con); BLI_insertlinkafter(conlist, nextCon, con); - + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); - + return OPERATOR_FINISHED; } - + return OPERATOR_CANCELLED; } @@ -1336,15 +1336,15 @@ void CONSTRAINT_OT_move_down(wmOperatorType *ot) ot->name = "Move Constraint Down"; ot->idname = "CONSTRAINT_OT_move_down"; ot->description = "Move constraint down in constraint stack"; - + /* callbacks */ ot->invoke = constraint_move_down_invoke; ot->exec = constraint_move_down_exec; ot->poll = edit_constraint_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ edit_constraint_properties(ot); } @@ -1354,20 +1354,20 @@ static int constraint_move_up_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(op, ob, 0); - + if (con && con->prev) { ListBase *conlist = get_constraint_lb(ob, con, NULL); bConstraint *prevCon = con->prev; - + /* insert the nominated constraint before the one that used to be before it */ BLI_remlink(conlist, con); BLI_insertlinkbefore(conlist, prevCon, con); - + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); - + return OPERATOR_FINISHED; } - + return OPERATOR_CANCELLED; } @@ -1385,12 +1385,12 @@ void CONSTRAINT_OT_move_up(wmOperatorType *ot) ot->name = "Move Constraint Up"; ot->idname = "CONSTRAINT_OT_move_up"; ot->description = "Move constraint up in constraint stack"; - + /* callbacks */ ot->exec = constraint_move_up_exec; ot->invoke = constraint_move_up_invoke; ot->poll = edit_constraint_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; edit_constraint_properties(ot); @@ -1404,7 +1404,7 @@ static int pose_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); - + /* free constraints for all selected bones */ CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) { @@ -1412,16 +1412,16 @@ static int pose_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op)) pchan->constflag &= ~(PCHAN_HAS_IK | PCHAN_HAS_SPLINEIK | PCHAN_HAS_CONST); } CTX_DATA_END; - + /* force depsgraph to get recalculated since relationships removed */ DAG_relations_tag_update(bmain); - + /* note, calling BIK_clear_data() isn't needed here */ /* do updates */ DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, ob); - + return OPERATOR_FINISHED; } @@ -1431,7 +1431,7 @@ void POSE_OT_constraints_clear(wmOperatorType *ot) ot->name = "Clear Pose Constraints"; ot->idname = "POSE_OT_constraints_clear"; ot->description = "Clear all the constraints for the selected bones"; - + /* callbacks */ ot->exec = pose_constraints_clear_exec; ot->poll = ED_operator_posemode_exclusive; // XXX - do we want to ensure there are selected bones too? @@ -1441,7 +1441,7 @@ void POSE_OT_constraints_clear(wmOperatorType *ot) static int object_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); - + /* do freeing */ CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { @@ -1449,13 +1449,13 @@ static int object_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&ob->id, OB_RECALC_OB); } CTX_DATA_END; - + /* force depsgraph to get recalculated since relationships removed */ DAG_relations_tag_update(bmain); - + /* do updates */ WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, NULL); - + return OPERATOR_FINISHED; } @@ -1465,7 +1465,7 @@ void OBJECT_OT_constraints_clear(wmOperatorType *ot) ot->name = "Clear Object Constraints"; ot->idname = "OBJECT_OT_constraints_clear"; ot->description = "Clear all the constraints for the active Object only"; - + /* callbacks */ ot->exec = object_constraints_clear_exec; ot->poll = ED_operator_object_active_editable; @@ -1479,19 +1479,19 @@ static int pose_constraint_copy_exec(bContext *C, wmOperator *op) bPoseChannel *pchan = CTX_data_active_pose_bone(C); ListBase lb; CollectionPointerLink *link; - + /* don't do anything if bone doesn't exist or doesn't have any constraints */ if (ELEM(NULL, pchan, pchan->constraints.first)) { BKE_report(op->reports, RPT_ERROR, "No active bone with constraints for copying"); return OPERATOR_CANCELLED; } - + /* copy all constraints from active posebone to all selected posebones */ CTX_data_selected_pose_bones(C, &lb); for (link = lb.first; link; link = link->next) { Object *ob = link->ptr.id.data; bPoseChannel *chan = link->ptr.data; - + /* if we're not handling the object we're copying from, copy all constraints over */ if (pchan != chan) { BKE_constraints_copy(&chan->constraints, &pchan->constraints, true); @@ -1503,12 +1503,12 @@ static int pose_constraint_copy_exec(bContext *C, wmOperator *op) } } BLI_freelistN(&lb); - + /* force depsgraph to get recalculated since new relationships added */ DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, NULL); - + return OPERATOR_FINISHED; } @@ -1518,7 +1518,7 @@ void POSE_OT_constraints_copy(wmOperatorType *ot) ot->name = "Copy Constraints to Selected Bones"; ot->idname = "POSE_OT_constraints_copy"; ot->description = "Copy constraints to other selected bones"; - + /* api callbacks */ ot->exec = pose_constraint_copy_exec; ot->poll = ED_operator_posemode_exclusive; @@ -1531,7 +1531,7 @@ static int object_constraint_copy_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); Object *obact = ED_object_active_context(C); - + /* copy all constraints from active object to all selected objects */ CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { @@ -1542,13 +1542,13 @@ static int object_constraint_copy_exec(bContext *C, wmOperator *UNUSED(op)) } } CTX_DATA_END; - + /* force depsgraph to get recalculated since new relationships added */ DAG_relations_tag_update(bmain); - + /* notifiers for updates */ WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_ADDED, NULL); - + return OPERATOR_FINISHED; } @@ -1558,7 +1558,7 @@ void OBJECT_OT_constraints_copy(wmOperatorType *ot) ot->name = "Copy Constraints to Selected Objects"; ot->idname = "OBJECT_OT_constraints_copy"; ot->description = "Copy constraints to other selected objects"; - + /* api callbacks */ ot->exec = object_constraint_copy_exec; ot->poll = ED_operator_object_active_editable; @@ -1576,15 +1576,15 @@ static bool get_new_constraint_target(bContext *C, int con_type, Object **tar_ob bPoseChannel *pchanact = BKE_pose_channel_active(obact); bool only_curve = false, only_mesh = false, only_ob = false; bool found = false; - - /* clear tar_ob and tar_pchan fields before use + + /* clear tar_ob and tar_pchan fields before use * - assume for now that both always exist... */ *tar_ob = NULL; *tar_pchan = NULL; - + /* check if constraint type doesn't requires a target - * - if so, no need to get any targets + * - if so, no need to get any targets */ switch (con_type) { /* no-target constraints --------------------------- */ @@ -1596,7 +1596,7 @@ static bool get_new_constraint_target(bContext *C, int con_type, Object **tar_ob case CONSTRAINT_TYPE_SIZELIMIT: case CONSTRAINT_TYPE_SAMEVOL: return false; - + /* restricted target-type constraints -------------- */ /* NOTE: for these, we cannot try to add a target object if no valid ones are found, since that doesn't work */ /* curve-based constraints - set the only_curve and only_ob flags */ @@ -1607,20 +1607,20 @@ static bool get_new_constraint_target(bContext *C, int con_type, Object **tar_ob only_ob = true; add = false; break; - + /* mesh only? */ case CONSTRAINT_TYPE_SHRINKWRAP: only_mesh = true; only_ob = true; add = false; break; - + /* object only - add here is ok? */ case CONSTRAINT_TYPE_RIGIDBODYJOINT: only_ob = true; break; } - + /* if the active Object is Armature, and we can search for bones, do so... */ if ((obact->type == OB_ARMATURE) && (only_ob == false)) { /* search in list of selected Pose-Channels for target */ @@ -1631,33 +1631,33 @@ static bool get_new_constraint_target(bContext *C, int con_type, Object **tar_ob *tar_ob = obact; *tar_pchan = pchan; found = true; - + break; } } CTX_DATA_END; } - + /* if not yet found, try selected Objects... */ if (found == false) { /* search in selected objects context */ CTX_DATA_BEGIN (C, Object *, ob, selected_objects) { - /* just use the first object we encounter (that isn't the active object) - * and which fulfills the criteria for the object-target that we've got + /* just use the first object we encounter (that isn't the active object) + * and which fulfills the criteria for the object-target that we've got */ if (ob != obact) { /* for armatures in pose mode, look inside the armature for the active bone * so that we set up cross-armature constraints with less effort */ - if ((ob->type == OB_ARMATURE) && (ob->mode & OB_MODE_POSE) && + if ((ob->type == OB_ARMATURE) && (ob->mode & OB_MODE_POSE) && (!only_curve && !only_mesh)) { /* just use the active bone, and assume that it is visible + usable */ *tar_ob = ob; *tar_pchan = BKE_pose_channel_active(ob); found = true; - + break; } else if (((!only_curve) || (ob->type == OB_CURVE)) && @@ -1666,39 +1666,39 @@ static bool get_new_constraint_target(bContext *C, int con_type, Object **tar_ob /* set target */ *tar_ob = ob; found = true; - + /* perform some special operations on the target */ if (only_curve) { /* Curve-Path option must be enabled for follow-path constraints to be able to work */ Curve *cu = (Curve *)ob->data; cu->flag |= CU_PATH; } - + break; } } } CTX_DATA_END; } - + /* if still not found, add a new empty to act as a target (if allowed) */ if ((found == false) && (add)) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); Base *base = BASACT, *newbase = NULL; Object *obt; - + /* add new target object */ obt = BKE_object_add(bmain, scene, OB_EMPTY, NULL); - + /* set layers OK */ newbase = BASACT; newbase->lay = base->lay; obt->lay = newbase->lay; - + /* transform cent to global coords for loc */ if (pchanact) { - /* since by default, IK targets the tip of the last bone, use the tip of the active PoseChannel + /* since by default, IK targets the tip of the last bone, use the tip of the active PoseChannel * if adding a target for an IK Constraint */ if (con_type == CONSTRAINT_TYPE_KINEMATIC) @@ -1713,12 +1713,12 @@ static bool get_new_constraint_target(bContext *C, int con_type, Object **tar_ob /* restore, BKE_object_add sets active */ BASACT = base; base->flag |= SELECT; - + /* make our new target the new object */ *tar_ob = obt; found = true; } - + /* return whether there's any target */ return found; } @@ -1729,13 +1729,13 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase Main *bmain = CTX_data_main(C); bPoseChannel *pchan; bConstraint *con; - + if (list == &ob->constraints) { pchan = NULL; } else { pchan = BKE_pose_channel_active(ob); - + /* ensure not to confuse object/pose adding */ if (pchan == NULL) { BKE_report(op->reports, RPT_ERROR, "No active pose bone to add a constraint to"); @@ -1758,23 +1758,23 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase BKE_report(op->reports, RPT_ERROR, "Spline IK constraint can only be added to bones"); return OPERATOR_CANCELLED; } - + /* create a new constraint of the type requried, and add it to the active/given constraints list */ if (pchan) con = BKE_constraint_add_for_pose(ob, pchan, NULL, type); else con = BKE_constraint_add_for_object(ob, NULL, type); - + /* get the first selected object/bone, and make that the target * - apart from the buttons-window add buttons, we shouldn't add in this way */ if (setTarget) { Object *tar_ob = NULL; bPoseChannel *tar_pchan = NULL; - + /* get the target objects, adding them as need be */ if (get_new_constraint_target(C, type, &tar_ob, &tar_pchan, 1)) { - /* method of setting target depends on the type of target we've got + /* method of setting target depends on the type of target we've got * - by default, just set the first target (distinction here is only for multiple-targeted constraints) */ if (tar_pchan) @@ -1783,7 +1783,7 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase set_constraint_nth_target(con, tar_ob, "", 0); } } - + /* do type-specific tweaking to the constraint settings */ switch (type) { case CONSTRAINT_TYPE_PYTHON: /* FIXME: this code is not really valid anymore */ @@ -1800,7 +1800,7 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase if (scriptint) { /* add constraint */ validate_pyconstraint_cb(con->data, &scriptint); - + /* make sure target allowance is set correctly */ BPY_pyconstraint_update(ob, con); } @@ -1811,7 +1811,7 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase default: break; } - + /* make sure all settings are valid - similar to above checks, but sometimes can be wrong */ object_test_constraints(bmain, ob); @@ -1821,7 +1821,7 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase /* force depsgraph to get recalculated since new relationships added */ DAG_relations_tag_update(bmain); - + if ((ob->type == OB_ARMATURE) && (pchan)) { BKE_pose_tag_recalc(bmain, ob->pose); /* sort pose channels */ if (BKE_constraints_proxylocked_owner(ob, pchan) && ob->adt) { @@ -1834,10 +1834,10 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase } else DAG_id_tag_update(&ob->id, OB_RECALC_OB); - + /* notifiers for updates */ WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_ADDED, ob); - + return OPERATOR_FINISHED; } @@ -1849,12 +1849,12 @@ static int object_constraint_add_exec(bContext *C, wmOperator *op) Object *ob = ED_object_active_context(C); int type = RNA_enum_get(op->ptr, "type"); short with_targets = 0; - + if (!ob) { BKE_report(op->reports, RPT_ERROR, "No active object to add constraint to"); return OPERATOR_CANCELLED; } - + /* hack: set constraint targets from selected objects in context is allowed when * operator name included 'with_targets', since the menu doesn't allow multiple properties */ @@ -1870,18 +1870,18 @@ static int pose_constraint_add_exec(bContext *C, wmOperator *op) Object *ob = BKE_object_pose_armature_get(ED_object_active_context(C)); int type = RNA_enum_get(op->ptr, "type"); short with_targets = 0; - + if (!ob) { BKE_report(op->reports, RPT_ERROR, "No active object to add constraint to"); return OPERATOR_CANCELLED; } - + /* hack: set constraint targets from selected objects in context is allowed when * operator name included 'with_targets', since the menu doesn't allow multiple properties */ if (strstr(op->idname, "with_targets")) with_targets = 1; - + return constraint_add_exec(C, op, ob, get_active_constraints(ob), type, with_targets); } @@ -1893,15 +1893,15 @@ void OBJECT_OT_constraint_add(wmOperatorType *ot) ot->name = "Add Constraint"; ot->description = "Add a constraint to the active object"; ot->idname = "OBJECT_OT_constraint_add"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = object_constraint_add_exec; ot->poll = ED_operator_object_active_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_constraint_type_items, 0, "Type", ""); } @@ -1912,15 +1912,15 @@ void OBJECT_OT_constraint_add_with_targets(wmOperatorType *ot) ot->name = "Add Constraint (with Targets)"; ot->description = "Add a constraint to the active object, with target (where applicable) set to the selected Objects/Bones"; ot->idname = "OBJECT_OT_constraint_add_with_targets"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = object_constraint_add_exec; ot->poll = ED_operator_object_active_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_constraint_type_items, 0, "Type", ""); } @@ -1931,15 +1931,15 @@ void POSE_OT_constraint_add(wmOperatorType *ot) ot->name = "Add Constraint"; ot->description = "Add a constraint to the active bone"; ot->idname = "POSE_OT_constraint_add"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = pose_constraint_add_exec; ot->poll = ED_operator_posemode_exclusive; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_constraint_type_items, 0, "Type", ""); } @@ -1950,15 +1950,15 @@ void POSE_OT_constraint_add_with_targets(wmOperatorType *ot) ot->name = "Add Constraint (with Targets)"; ot->description = "Add a constraint to the active bone, with target (where applicable) set to the selected Objects/Bones"; ot->idname = "POSE_OT_constraint_add_with_targets"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = pose_constraint_add_exec; ot->poll = ED_operator_posemode_exclusive; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_constraint_type_items, 0, "Type", ""); } @@ -1973,18 +1973,18 @@ static int pose_ik_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); bPoseChannel *pchan = BKE_pose_channel_active(ob); bConstraint *con = NULL; - + uiPopupMenu *pup; uiLayout *layout; Object *tar_ob = NULL; bPoseChannel *tar_pchan = NULL; - + /* must have active bone */ if (ELEM(NULL, ob, pchan)) { BKE_report(op->reports, RPT_ERROR, "Must have an active bone to add IK constraint to"); return OPERATOR_CANCELLED; } - + /* bone must not have any constraints already */ for (con = pchan->constraints.first; con; con = con->next) { if (con->type == CONSTRAINT_TYPE_KINEMATIC) break; @@ -1993,14 +1993,14 @@ static int pose_ik_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED BKE_report(op->reports, RPT_ERROR, "Bone already has an IK constraint"); return OPERATOR_CANCELLED; } - + /* prepare popup menu to choose targetting options */ pup = UI_popup_menu_begin(C, IFACE_("Add IK"), ICON_NONE); layout = UI_popup_menu_layout(pup); - + /* the type of targets we'll set determines the menu entries to show... */ if (get_new_constraint_target(C, CONSTRAINT_TYPE_KINEMATIC, &tar_ob, &tar_pchan, 0)) { - /* bone target, or object target? + /* bone target, or object target? * - the only thing that matters is that we want a target... */ if (tar_pchan) @@ -2013,10 +2013,10 @@ static int pose_ik_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED uiItemBooleanO(layout, IFACE_("To New Empty Object"), ICON_NONE, "POSE_OT_ik_add", "with_targets", 1); uiItemBooleanO(layout, IFACE_("Without Targets"), ICON_NONE, "POSE_OT_ik_add", "with_targets", 0); } - + /* finish building the menu, and process it (should result in calling self again) */ UI_popup_menu_end(C, pup); - + return OPERATOR_INTERFACE; } @@ -2025,7 +2025,7 @@ static int pose_ik_add_exec(bContext *C, wmOperator *op) { Object *ob = CTX_data_active_object(C); const bool with_targets = RNA_boolean_get(op->ptr, "with_targets"); - + /* add the constraint - all necessary checks should have been done by the invoke() callback already... */ return constraint_add_exec(C, op, ob, get_active_constraints(ob), CONSTRAINT_TYPE_KINEMATIC, with_targets); } @@ -2036,15 +2036,15 @@ void POSE_OT_ik_add(wmOperatorType *ot) ot->name = "Add IK to Bone"; ot->description = "Add IK Constraint to the active Bone"; ot->idname = "POSE_OT_ik_add"; - + /* api callbacks */ ot->invoke = pose_ik_add_invoke; ot->exec = pose_ik_add_exec; ot->poll = ED_operator_posemode_exclusive; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_boolean(ot->srna, "with_targets", 1, "With Targets", "Assign IK Constraint with targets derived from the select bones/objects"); } @@ -2055,12 +2055,12 @@ void POSE_OT_ik_add(wmOperatorType *ot) static int pose_ik_clear_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); - + /* only remove IK Constraints */ CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) { bConstraint *con, *next; - + /* TODO: should we be checking if these contraints were local before we try and remove them? */ for (con = pchan->constraints.first; con; con = next) { next = con->next; @@ -2071,13 +2071,13 @@ static int pose_ik_clear_exec(bContext *C, wmOperator *UNUSED(op)) pchan->constflag &= ~(PCHAN_HAS_IK | PCHAN_HAS_TARGET); } CTX_DATA_END; - + /* refresh depsgraph */ DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* note, notifier might evolve */ WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, ob); - + return OPERATOR_FINISHED; } @@ -2087,11 +2087,11 @@ void POSE_OT_ik_clear(wmOperatorType *ot) ot->name = "Remove IK"; ot->description = "Remove all IK Constraints from selected bones"; ot->idname = "POSE_OT_ik_clear"; - + /* api callbacks */ ot->exec = pose_ik_clear_exec; ot->poll = ED_operator_posemode_exclusive; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 34c0b22a34e..2737ae5d92d 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -145,7 +145,7 @@ static int object_hide_view_clear_exec(bContext *C, wmOperator *op) Base *base; bool changed = false; const bool select = RNA_boolean_get(op->ptr, "select"); - + /* XXX need a context loop to handle such cases */ for (base = FIRSTBASE; base; base = base->next) { if ((base->lay & v3d->lay) && base->object->restrictflag & OB_RESTRICT_VIEW) { @@ -153,7 +153,7 @@ static int object_hide_view_clear_exec(bContext *C, wmOperator *op) SET_FLAG_FROM_TEST(base->flag, select, SELECT); } base->object->flag = base->flag; - base->object->restrictflag &= ~OB_RESTRICT_VIEW; + base->object->restrictflag &= ~OB_RESTRICT_VIEW; changed = true; } } @@ -168,16 +168,16 @@ static int object_hide_view_clear_exec(bContext *C, wmOperator *op) void OBJECT_OT_hide_view_clear(wmOperatorType *ot) { - + /* identifiers */ ot->name = "Clear Restrict View"; ot->description = "Reveal the object by setting the hide flag"; ot->idname = "OBJECT_OT_hide_view_clear"; - + /* api callbacks */ ot->exec = object_hide_view_clear_exec; ot->poll = ED_operator_view3d_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -190,7 +190,7 @@ static int object_hide_view_set_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); bool changed = false; const bool unselected = RNA_boolean_get(op->ptr, "unselected"); - + CTX_DATA_BEGIN(C, Base *, base, visible_bases) { if (!unselected) { @@ -219,9 +219,9 @@ static int object_hide_view_set_exec(bContext *C, wmOperator *op) if (changed) { DAG_id_type_tag(bmain, ID_OB); DAG_relations_tag_update(bmain); - + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); - + } return OPERATOR_FINISHED; @@ -233,16 +233,16 @@ void OBJECT_OT_hide_view_set(wmOperatorType *ot) ot->name = "Set Restrict View"; ot->description = "Hide the object by setting the hide flag"; ot->idname = "OBJECT_OT_hide_view_set"; - + /* api callbacks */ ot->exec = object_hide_view_set_exec; ot->poll = ED_operator_view3d_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected objects"); - + } /* 99% same as above except no need for scene refreshing (TODO, update render preview) */ @@ -669,16 +669,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; } @@ -691,7 +691,7 @@ static int posemode_exec(bContext *C, wmOperator *op) Object *ob = base->object; const int mode_flag = OB_MODE_POSE; bool is_mode_set = (ob->mode & mode_flag) != 0; - + if (!is_mode_set) { if (!ED_object_mode_compat_set(C, ob, mode_flag, op->reports)) { return OPERATOR_CANCELLED; @@ -710,49 +710,49 @@ static int posemode_exec(bContext *C, wmOperator *op) else { ED_object_posemode_enter(C, ob); } - + return OPERATOR_FINISHED; } - + return OPERATOR_PASS_THROUGH; } -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; } static void copymenu_properties(Scene *scene, View3D *v3d, Object *ob) -{ +{ //XXX no longer used - to be removed - replaced by game_properties_copy_exec bProperty *prop; Base *base; int nr, tot = 0; char *str; - + prop = ob->prop.first; while (prop) { tot++; prop = prop->next; } - + str = MEM_callocN(50 + 33 * tot, "copymenu prop"); - + if (tot) strcpy(str, "Copy Property %t|Replace All|Merge All|%l"); else strcpy(str, "Copy Property %t|Clear All (no properties on active)"); - + tot = 0; prop = ob->prop.first; while (prop) { @@ -763,7 +763,7 @@ static void copymenu_properties(Scene *scene, View3D *v3d, Object *ob) } nr = pupmenu(str); - + if (nr == 1 || nr == 2) { for (base = FIRSTBASE; base; base = base->next) { if ((base != BASACT) && (TESTBASELIB(v3d, base))) { @@ -780,7 +780,7 @@ static void copymenu_properties(Scene *scene, View3D *v3d, Object *ob) } else if (nr > 0) { prop = BLI_findlink(&ob->prop, nr - 4); /* account for first 3 menu items & menu index starting at 1*/ - + if (prop) { for (base = FIRSTBASE; base; base = base->next) { if ((base != BASACT) && (TESTBASELIB(v3d, base))) { @@ -790,36 +790,36 @@ static void copymenu_properties(Scene *scene, View3D *v3d, Object *ob) } } MEM_freeN(str); - + } static void copymenu_logicbricks(Scene *scene, View3D *v3d, Object *ob) { //XXX no longer used - to be removed - replaced by logicbricks_copy_exec Base *base; - + for (base = FIRSTBASE; base; base = base->next) { if (base->object != ob) { if (TESTBASELIB(v3d, base)) { - + /* first: free all logic */ free_sensors(&base->object->sensors); unlink_controllers(&base->object->controllers); free_controllers(&base->object->controllers); unlink_actuators(&base->object->actuators); free_actuators(&base->object->actuators); - + /* now copy it, this also works without logicbricks! */ clear_sca_new_poins_ob(ob); copy_sensors(&base->object->sensors, &ob->sensors, 0); copy_controllers(&base->object->controllers, &ob->controllers, 0); copy_actuators(&base->object->actuators, &ob->actuators, 0); set_sca_new_poins_ob(base->object); - + /* some menu settings */ base->object->scavisflag = ob->scavisflag; base->object->scaflag = ob->scaflag; - + /* set the initial state */ base->object->state = ob->state; base->object->init_state = ob->init_state; @@ -833,7 +833,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; @@ -848,7 +848,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; @@ -863,9 +863,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 */ } @@ -875,7 +875,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 */ @@ -886,11 +886,11 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) Curve *cu, *cu1; Nurb *nu; bool do_depgraph_update = false; - + if (ID_IS_LINKED(scene)) return; if (!(ob = OBACT)) return; - + if (scene->obedit) { // XXX get from context /* obedit_copymenu(); */ return; @@ -913,7 +913,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) if (base != BASACT) { if (TESTBASELIB(v3d, base)) { DAG_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); @@ -943,7 +943,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) 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); @@ -979,7 +979,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) 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; @@ -1012,25 +1012,25 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) 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)); - + DAG_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; - + DAG_id_tag_update(&base->object->id, OB_RECALC_DATA); } } @@ -1039,17 +1039,17 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) 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; } - + DAG_id_tag_update(&base->object->id, OB_RECALC_DATA); } } @@ -1073,13 +1073,13 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) 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)) { @@ -1106,7 +1106,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) 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 @@ -1125,7 +1125,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) } } } - + if (do_depgraph_update) DAG_relations_tag_update(bmain); } @@ -1135,36 +1135,36 @@ static void UNUSED_FUNCTION(copy_attr_menu) (Main *bmain, Scene *scene, View3D * Object *ob; short event; char str[512]; - + if (!(ob = OBACT)) return; - + if (scene->obedit) { /* XXX get from context */ /* 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"); } @@ -1174,16 +1174,16 @@ static void UNUSED_FUNCTION(copy_attr_menu) (Main *bmain, Scene *scene, View3D * } 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, v3d, event); } @@ -1219,7 +1219,7 @@ static int forcefield_toggle_exec(bContext *C, wmOperator *UNUSED(op)) ob->pd->forcefield = PFIELD_FORCE; else ob->pd->forcefield = 0; - + ED_object_check_force_modifiers(CTX_data_main(C), CTX_data_scene(C), ob); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); @@ -1229,16 +1229,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; } @@ -1254,7 +1254,7 @@ void OBJECT_OT_forcefield_toggle(wmOperatorType *ot) void ED_objects_recalculate_paths(bContext *C, Scene *scene) { ListBase targets = {NULL, NULL}; - + /* loop over objects in scene */ CTX_DATA_BEGIN(C, Object *, ob, selected_editable_objects) { @@ -1263,7 +1263,7 @@ 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(scene, &targets); BLI_freelistN(&targets); @@ -1274,18 +1274,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); @@ -1297,28 +1297,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) @@ -1327,19 +1327,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); } @@ -1351,23 +1351,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; } @@ -1377,11 +1377,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; } @@ -1423,14 +1423,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 */ @@ -1448,15 +1448,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"); @@ -1524,7 +1524,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; @@ -1539,11 +1539,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; } @@ -1559,15 +1559,15 @@ static void UNUSED_FUNCTION(image_aspect) (Scene *scene, View3D *v3d) Tex *tex; float x, y, space; int a, b, done; - + if (scene->obedit) return; // XXX get from context if (ID_IS_LINKED(scene)) return; - + for (base = FIRSTBASE; base; base = base->next) { if (TESTBASELIB(v3d, base)) { ob = base->object; done = false; - + for (a = 1; a <= ob->totcol; a++) { ma = give_current_material(ob, a); if (ma) { @@ -1576,7 +1576,7 @@ static void UNUSED_FUNCTION(image_aspect) (Scene *scene, View3D *v3d) tex = ma->mtex[b]->tex; if (tex->type == TEX_IMAGE && tex->ima) { ImBuf *ibuf = BKE_image_acquire_ibuf(tex->ima, NULL, NULL); - + /* texturespace */ space = 1.0; if (ob->type == OB_MESH) { @@ -1589,13 +1589,13 @@ static void UNUSED_FUNCTION(image_aspect) (Scene *scene, View3D *v3d) BKE_curve_texspace_get(ob->data, NULL, NULL, size); space = size[0] / size[1]; } - + x = ibuf->x / space; y = ibuf->y; - + if (x > y) ob->size[0] = ob->size[1] * x / y; else ob->size[1] = ob->size[0] * y / x; - + done = true; DAG_id_tag_update(&ob->id, OB_RECALC_OB); @@ -1609,7 +1609,7 @@ static void UNUSED_FUNCTION(image_aspect) (Scene *scene, View3D *v3d) } } } - + } static const EnumPropertyItem *object_mode_set_itemsf( @@ -1646,7 +1646,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... */ @@ -1682,7 +1682,7 @@ static int object_mode_set_exec(bContext *C, wmOperator *op) eObjectMode mode = RNA_enum_get(op->ptr, "mode"); eObjectMode restore_mode = (ob) ? ob->mode : OB_MODE_OBJECT; const bool toggle = RNA_boolean_get(op->ptr, "toggle"); - + if (gpd) { /* GP Mode is not bound to a specific object. Therefore, * we don't want it to be actually saved on any objects, @@ -1700,7 +1700,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; @@ -1735,20 +1735,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); @@ -1922,13 +1922,13 @@ static const EnumPropertyItem game_properties_copy_operations[] = { }; static const EnumPropertyItem *gameprops_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) -{ +{ Object *ob = ED_object_active_context(C); EnumPropertyItem tmp = {0, "", 0, "", ""}; EnumPropertyItem *item = NULL; bProperty *prop; int a, totitem = 0; - + if (!ob) return DummyRNA_NULL_items; @@ -1954,7 +1954,7 @@ static int game_property_copy_exec(bContext *C, wmOperator *op) if (propid > 0) { /* copy */ prop = BLI_findlink(&ob->prop, propid - 1); - + if (prop) { CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects) { @@ -2048,18 +2048,18 @@ static int logicbricks_copy_exec(bContext *C, wmOperator *UNUSED(op)) free_controllers(&ob_iter->controllers); unlink_actuators(&ob_iter->actuators); free_actuators(&ob_iter->actuators); - + /* now copy it, this also works without logicbricks! */ clear_sca_new_poins_ob(ob); copy_sensors(&ob_iter->sensors, &ob->sensors, 0); copy_controllers(&ob_iter->controllers, &ob->controllers, 0); copy_actuators(&ob_iter->actuators, &ob->actuators, 0); set_sca_new_poins_ob(ob_iter); - + /* some menu settings */ ob_iter->scavisflag = ob->scavisflag; ob_iter->scaflag = ob->scaflag; - + /* set the initial state */ ob_iter->state = ob->state; ob_iter->init_state = ob->init_state; @@ -2095,7 +2095,7 @@ void OBJECT_OT_logic_bricks_copy(wmOperatorType *ot) static int game_physics_copy_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = ED_object_active_context(C); - + CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects) { if (ob != ob_iter) { @@ -2115,7 +2115,7 @@ static int game_physics_copy_exec(bContext *C, wmOperator *UNUSED(op)) ob_iter->collision_boundtype = ob->collision_boundtype; ob_iter->margin = ob->margin; ob_iter->bsoft = copy_bulletsoftbody(ob->bsoft, 0); - if (ob->restrictflag & OB_RESTRICT_RENDER) + if (ob->restrictflag & OB_RESTRICT_RENDER) ob_iter->restrictflag |= OB_RESTRICT_RENDER; else ob_iter->restrictflag &= ~OB_RESTRICT_RENDER; @@ -2125,7 +2125,7 @@ static int game_physics_copy_exec(bContext *C, wmOperator *UNUSED(op)) } } CTX_DATA_END; - + return OPERATOR_FINISHED; } @@ -2135,11 +2135,11 @@ void OBJECT_OT_game_physics_copy(struct wmOperatorType *ot) ot->name = "Copy Game Physics Properties to Selected"; ot->description = "Copy game physics properties to other selected objects"; ot->idname = "OBJECT_OT_game_physics_copy"; - + /* api callbacks */ ot->exec = game_physics_copy_exec; ot->poll = ED_operator_object_active_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c index 46c2c4e4b7d..e5accee171a 100644 --- a/source/blender/editors/object/object_group.c +++ b/source/blender/editors/object/object_group.c @@ -181,7 +181,7 @@ void GROUP_OT_objects_add_active(wmOperatorType *ot) ot->name = "Add Selected To Active Group"; ot->description = "Add the object to an object group that contains the active object"; ot->idname = "GROUP_OT_objects_add_active"; - + /* api callbacks */ ot->exec = objects_add_active_exec; ot->invoke = WM_menu_invoke; @@ -206,10 +206,10 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op) Group *single_group = group_object_active_find_index(ob, single_group_index); Group *group; bool ok = false; - + if (ob == NULL) return OPERATOR_CANCELLED; - + /* linking to same group requires its own loop so we can avoid * looking up the active objects groups each time */ @@ -227,13 +227,13 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op) CTX_DATA_END; } } - + if (!ok) BKE_report(op->reports, RPT_ERROR, "Active object contains no groups"); - + DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -245,12 +245,12 @@ void GROUP_OT_objects_remove_active(wmOperatorType *ot) ot->name = "Remove Selected From Active Group"; ot->description = "Remove the object from an object group that contains the active object"; ot->idname = "GROUP_OT_objects_remove_active"; - + /* api callbacks */ ot->exec = objects_remove_active_exec; ot->invoke = WM_menu_invoke; ot->poll = ED_operator_objectmode; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -274,7 +274,7 @@ static int group_objects_remove_all_exec(bContext *C, wmOperator *UNUSED(op)) DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -284,11 +284,11 @@ void GROUP_OT_objects_remove_all(wmOperatorType *ot) ot->name = "Remove From All Groups"; ot->description = "Remove selected objects from all groups"; ot->idname = "GROUP_OT_objects_remove_all"; - + /* api callbacks */ ot->exec = group_objects_remove_all_exec; ot->poll = ED_operator_objectmode; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -360,11 +360,11 @@ static int group_create_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); Group *group = NULL; char name[MAX_ID_NAME - 2]; /* id name */ - + RNA_string_get(op->ptr, "name", name); - + group = BKE_group_add(bmain, name); - + CTX_DATA_BEGIN (C, Base *, base, selected_bases) { BKE_group_object_add(group, base->object, scene, base); @@ -373,7 +373,7 @@ static int group_create_exec(bContext *C, wmOperator *op) DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -383,14 +383,14 @@ void GROUP_OT_create(wmOperatorType *ot) ot->name = "Create New Group"; ot->description = "Create an object group from selected objects"; ot->idname = "GROUP_OT_create"; - + /* api callbacks */ ot->exec = group_create_exec; ot->poll = ED_operator_objectmode; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_string(ot->srna, "name", "Group", MAX_ID_NAME - 2, "Name", "Name of the new group"); } @@ -420,7 +420,7 @@ void OBJECT_OT_group_add(wmOperatorType *ot) ot->name = "Add to Group"; ot->idname = "OBJECT_OT_group_add"; ot->description = "Add an object to a new group"; - + /* api callbacks */ ot->exec = group_add_exec; ot->poll = ED_operator_objectmode; @@ -472,7 +472,7 @@ void OBJECT_OT_group_link(wmOperatorType *ot) ot->name = "Link to Group"; ot->idname = "OBJECT_OT_group_link"; ot->description = "Add an object to an existing group"; - + /* api callbacks */ ot->exec = group_link_exec; ot->invoke = WM_enum_search_invoke; @@ -500,7 +500,7 @@ static int group_remove_exec(bContext *C, wmOperator *UNUSED(op)) BKE_group_object_unlink(group, ob, scene, NULL); /* base will be used if found */ WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); - + return OPERATOR_FINISHED; } @@ -510,7 +510,7 @@ void OBJECT_OT_group_remove(wmOperatorType *ot) ot->name = "Remove Group"; ot->idname = "OBJECT_OT_group_remove"; ot->description = "Remove the active object from this group"; - + /* api callbacks */ ot->exec = group_remove_exec; ot->poll = ED_operator_objectmode; diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index e9203fa1972..5963e4b769b 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -79,17 +79,17 @@ static int return_editmesh_indexar( BMVert *eve; BMIter iter; int *index, nr, totvert = 0; - + BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) totvert++; } if (totvert == 0) return 0; - + *r_indexar = index = MEM_mallocN(4 * totvert, "hook indexar"); *r_tot = totvert; nr = 0; zero_v3(r_cent); - + BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) { *index = nr; index++; @@ -97,9 +97,9 @@ static int return_editmesh_indexar( } nr++; } - + mul_v3_fl(r_cent, 1.0f / (float)totvert); - + return totvert; } @@ -133,9 +133,9 @@ static bool return_editmesh_vgroup(Object *obedit, BMEditMesh *em, char *r_name, return true; } } - + return false; -} +} static void select_editbmesh_hook(Object *ob, HookModifierData *hmd) { @@ -144,10 +144,10 @@ static void select_editbmesh_hook(Object *ob, HookModifierData *hmd) BMVert *eve; BMIter iter; int index = 0, nr = 0; - + if (hmd->indexar == NULL) return; - + BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { if (nr == hmd->indexar[index]) { BM_vert_select_set(em->bm, eve, true); @@ -166,7 +166,7 @@ static int return_editlattice_indexar( { BPoint *bp; int *index, nr, totvert = 0, a; - + /* count */ a = editlatt->pntsu * editlatt->pntsv * editlatt->pntsw; bp = editlatt->def; @@ -178,12 +178,12 @@ static int return_editlattice_indexar( } if (totvert == 0) return 0; - + *r_indexar = index = MEM_mallocN(4 * totvert, "hook indexar"); *r_tot = totvert; nr = 0; zero_v3(r_cent); - + a = editlatt->pntsu * editlatt->pntsv * editlatt->pntsw; bp = editlatt->def; while (a--) { @@ -196,9 +196,9 @@ static int return_editlattice_indexar( bp++; nr++; } - + mul_v3_fl(r_cent, 1.0f / (float)totvert); - + return totvert; } @@ -231,7 +231,7 @@ static int return_editcurve_indexar( BPoint *bp; BezTriple *bezt; int *index, a, nr, totvert = 0; - + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { bezt = nu->bezt; @@ -253,12 +253,12 @@ static int return_editcurve_indexar( } } if (totvert == 0) return 0; - + *r_indexar = index = MEM_mallocN(sizeof(*index) * totvert, "hook indexar"); *r_tot = totvert; nr = 0; zero_v3(r_cent); - + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { bezt = nu->bezt; @@ -295,9 +295,9 @@ static int return_editcurve_indexar( } } } - + mul_v3_fl(r_cent, 1.0f / (float)totvert); - + return totvert; } @@ -307,7 +307,7 @@ static bool object_hook_index_array(Scene *scene, Object *obedit, *r_indexar = NULL; *r_tot = 0; r_name[0] = 0; - + switch (obedit->type) { case OB_MESH: { @@ -353,7 +353,7 @@ static void select_editcurve_hook(Object *obedit, HookModifierData *hmd) BPoint *bp; BezTriple *bezt; int index = 0, a, nr = 0; - + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { bezt = nu->bezt; @@ -374,7 +374,7 @@ static void select_editcurve_hook(Object *obedit, HookModifierData *hmd) if (index < hmd->totindex - 1) index++; } nr++; - + bezt++; } } @@ -418,11 +418,11 @@ static void object_hook_from_context(bContext *C, PointerRNA *ptr, const int num } } -static void object_hook_select(Object *ob, HookModifierData *hmd) +static void object_hook_select(Object *ob, HookModifierData *hmd) { if (hmd->indexar == NULL) return; - + if (ob->type == OB_MESH) select_editbmesh_hook(ob, hmd); else if (ob->type == OB_LATTICE) select_editlattice_hook(ob, hmd); else if (ob->type == OB_CURVE) select_editcurve_hook(ob, hmd); @@ -434,14 +434,14 @@ static void object_hook_select(Object *ob, HookModifierData *hmd) static int hook_op_edit_poll(bContext *C) { Object *obedit = CTX_data_edit_object(C); - + if (obedit) { if (ED_operator_editmesh(C)) return 1; if (ED_operator_editsurfcurve(C)) return 1; if (ED_operator_editlattice(C)) return 1; //if (ED_operator_editmball(C)) return 1; } - + return 0; } @@ -451,12 +451,12 @@ static Object *add_hook_object_new(Main *bmain, Scene *scene, Object *obedit) Object *ob; ob = BKE_object_add(bmain, scene, OB_EMPTY, NULL); - + basedit = BKE_scene_base_find(scene, obedit); base = scene->basact; base->lay = ob->lay = obedit->lay; BLI_assert(scene->basact->object == ob); - + /* icky, BKE_object_add sets new base as active. * so set it back to the original edit object */ scene->basact = basedit; @@ -472,7 +472,7 @@ static int add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *ob float pose_mat[4][4]; int tot, ok, *indexar; char name[MAX_NAME]; - + ok = object_hook_index_array(scene, obedit, &tot, &indexar, name, cent); if (!ok) { @@ -481,29 +481,29 @@ static int add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *ob } if (mode == OBJECT_ADDHOOK_NEWOB && !ob) { - + ob = add_hook_object_new(bmain, scene, obedit); - + /* transform cent to global coords for loc */ mul_v3_m4v3(ob->loc, obedit->obmat, cent); } - + md = obedit->modifiers.first; while (md && modifierType_getInfo(md->type)->type == eModifierTypeType_OnlyDeform) { md = md->next; } - + hmd = (HookModifierData *) modifier_new(eModifierType_Hook); BLI_insertlinkbefore(&obedit->modifiers, md, hmd); BLI_snprintf(hmd->modifier.name, sizeof(hmd->modifier.name), "Hook-%s", ob->id.name + 2); modifier_unique_name(&obedit->modifiers, (ModifierData *)hmd); - + hmd->object = ob; hmd->indexar = indexar; copy_v3_v3(hmd->cent, cent); hmd->totindex = tot; BLI_strncpy(hmd->name, name, sizeof(hmd->name)); - + unit_m4(pose_mat); invert_m4_m4(obedit->imat, obedit->obmat); @@ -542,11 +542,11 @@ static int add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *ob /* vert x (obmat x hook->imat) x hook->obmat x ob->imat */ /* (parentinv ) */ BKE_object_where_is_calc(scene, ob); - + invert_m4_m4(ob->imat, ob->obmat); /* apparently this call goes from right to left... */ mul_m4_series(hmd->parentinv, pose_mat, ob->imat, obedit->obmat); - + DAG_relations_tag_update(bmain); return true; @@ -560,7 +560,7 @@ static int object_add_hook_selob_exec(bContext *C, wmOperator *op) Object *obsel = NULL; const bool use_bone = RNA_boolean_get(op->ptr, "use_bone"); const int mode = use_bone ? OBJECT_ADDHOOK_SELOB_BONE : OBJECT_ADDHOOK_SELOB; - + CTX_DATA_BEGIN (C, Object *, ob, selected_objects) { if (ob != obedit) { @@ -569,7 +569,7 @@ static int object_add_hook_selob_exec(bContext *C, wmOperator *op) } } CTX_DATA_END; - + if (!obsel) { BKE_report(op->reports, RPT_ERROR, "Cannot add hook with no other selected objects"); return OPERATOR_CANCELLED; @@ -579,7 +579,7 @@ static int object_add_hook_selob_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "Cannot add hook bone for a non armature object"); return OPERATOR_CANCELLED; } - + if (add_hook_object(bmain, scene, obedit, obsel, mode, op->reports)) { WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, obedit); return OPERATOR_FINISHED; @@ -595,11 +595,11 @@ void OBJECT_OT_hook_add_selob(wmOperatorType *ot) ot->name = "Hook to Selected Object"; ot->description = "Hook selected vertices to the first selected object"; ot->idname = "OBJECT_OT_hook_add_selob"; - + /* api callbacks */ ot->exec = object_add_hook_selob_exec; ot->poll = hook_op_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -629,11 +629,11 @@ void OBJECT_OT_hook_add_newob(wmOperatorType *ot) ot->name = "Hook to New Object"; ot->description = "Hook selected vertices to a newly created object"; ot->idname = "OBJECT_OT_hook_add_newob"; - + /* api callbacks */ ot->exec = object_add_hook_newob_exec; ot->poll = hook_op_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -649,29 +649,29 @@ static int object_hook_remove_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier"); return OPERATOR_CANCELLED; } - + /* remove functionality */ - + BLI_remlink(&ob->modifiers, (ModifierData *)hmd); modifier_free((ModifierData *)hmd); - + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } static const EnumPropertyItem *hook_mod_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) -{ +{ Object *ob = CTX_data_edit_object(C); EnumPropertyItem tmp = {0, "", 0, "", ""}; EnumPropertyItem *item = NULL; ModifierData *md = NULL; int a, totitem = 0; - + if (!ob) return DummyRNA_NULL_items; - + for (a = 0, md = ob->modifiers.first; md; md = md->next, a++) { if (md->type == eModifierType_Hook) { tmp.value = a; @@ -681,32 +681,32 @@ static const EnumPropertyItem *hook_mod_itemf(bContext *C, PointerRNA *UNUSED(pt RNA_enum_item_add(&item, &totitem, &tmp); } } - + RNA_enum_item_end(&item, &totitem); *r_free = true; - + return item; } void OBJECT_OT_hook_remove(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Remove Hook"; ot->idname = "OBJECT_OT_hook_remove"; ot->description = "Remove a hook from the active object"; - + /* api callbacks */ ot->exec = object_hook_remove_exec; ot->invoke = WM_menu_invoke; ot->poll = hook_op_edit_poll; - + /* flags */ /* this operator removes modifier which isn't stored in local undo stack, * so redoing it from redo panel gives totally weird results */ ot->flag = /*OPTYPE_REGISTER|*/ OPTYPE_UNDO; - + /* properties */ prop = RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to remove"); RNA_def_enum_funcs(prop, hook_mod_itemf); @@ -731,26 +731,26 @@ static int object_hook_reset_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } void OBJECT_OT_hook_reset(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Reset Hook"; ot->description = "Recalculate and clear offset transformation"; ot->idname = "OBJECT_OT_hook_reset"; - + /* callbacks */ ot->exec = object_hook_reset_exec; ot->poll = hook_op_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ prop = RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to assign to"); RNA_def_enum_funcs(prop, hook_mod_itemf); @@ -765,42 +765,42 @@ static int object_hook_recenter_exec(bContext *C, wmOperator *op) HookModifierData *hmd = NULL; Scene *scene = CTX_data_scene(C); float bmat[3][3], imat[3][3]; - + object_hook_from_context(C, &ptr, num, &ob, &hmd); if (hmd == NULL) { BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier"); return OPERATOR_CANCELLED; } - + /* recenter functionality */ copy_m3_m4(bmat, ob->obmat); invert_m3_m3(imat, bmat); - + sub_v3_v3v3(hmd->cent, scene->cursor, ob->obmat[3]); mul_m3_v3(imat, hmd->cent); - + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } void OBJECT_OT_hook_recenter(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Recenter Hook"; ot->description = "Set hook center to cursor position"; ot->idname = "OBJECT_OT_hook_recenter"; - + /* callbacks */ ot->exec = object_hook_recenter_exec; ot->poll = hook_op_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ prop = RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to assign to"); RNA_def_enum_funcs(prop, hook_mod_itemf); @@ -817,50 +817,50 @@ static int object_hook_assign_exec(bContext *C, wmOperator *op) float cent[3]; char name[MAX_NAME]; int *indexar, tot; - + object_hook_from_context(C, &ptr, num, &ob, &hmd); if (hmd == NULL) { BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier"); return OPERATOR_CANCELLED; } - + /* assign functionality */ - + if (!object_hook_index_array(scene, ob, &tot, &indexar, name, cent)) { BKE_report(op->reports, RPT_WARNING, "Requires selected vertices or active vertex group"); return OPERATOR_CANCELLED; } if (hmd->indexar) MEM_freeN(hmd->indexar); - + copy_v3_v3(hmd->cent, cent); hmd->indexar = indexar; hmd->totindex = tot; - + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } void OBJECT_OT_hook_assign(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Assign to Hook"; ot->description = "Assign the selected vertices to a hook"; ot->idname = "OBJECT_OT_hook_assign"; - + /* callbacks */ ot->exec = object_hook_assign_exec; ot->poll = hook_op_edit_poll; - + /* flags */ /* this operator changes data stored in modifier which doesn't get pushed to undo stack, * so redoing it from redo panel gives totally weird results */ ot->flag = /*OPTYPE_REGISTER|*/ OPTYPE_UNDO; - + /* properties */ prop = RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to assign to"); RNA_def_enum_funcs(prop, hook_mod_itemf); @@ -873,37 +873,37 @@ static int object_hook_select_exec(bContext *C, wmOperator *op) int num = RNA_enum_get(op->ptr, "modifier"); Object *ob = NULL; HookModifierData *hmd = NULL; - + object_hook_from_context(C, &ptr, num, &ob, &hmd); if (hmd == NULL) { BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier"); return OPERATOR_CANCELLED; } - + /* select functionality */ object_hook_select(ob, hmd); - + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data); - + return OPERATOR_FINISHED; } void OBJECT_OT_hook_select(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Select Hook"; ot->description = "Select affected vertices on mesh"; ot->idname = "OBJECT_OT_hook_select"; - + /* callbacks */ ot->exec = object_hook_select_exec; ot->poll = hook_op_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ prop = RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to remove"); RNA_def_enum_funcs(prop, hook_mod_itemf); diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 34f192fbffa..c79be8ed223 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -97,7 +97,7 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc { ModifierData *md = NULL, *new_md = NULL; const ModifierTypeInfo *mti = modifierType_getInfo(type); - + /* Check compatibility of modifier [T25291, T50373]. */ if (!BKE_object_support_modifier_type_check(ob, type)) { BKE_reportf(reports, RPT_WARNING, "Modifiers cannot be added to object '%s'", ob->id.name + 2); @@ -110,23 +110,23 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc return NULL; } } - + if (type == eModifierType_ParticleSystem) { /* don't need to worry about the new modifier's name, since that is set to the number - * of particle systems which shouldn't have too many duplicates + * of particle systems which shouldn't have too many duplicates */ new_md = object_add_particle_system(scene, ob, name); } else { /* get new modifier data to add */ new_md = modifier_new(type); - + if (mti->flags & eModifierTypeFlag_RequiresOriginalData) { md = ob->modifiers.first; - + while (md && modifierType_getInfo(md->type)->type == eModifierTypeType_OnlyDeform) md = md->next; - + BLI_insertlinkbefore(&ob->modifiers, md, new_md); } else @@ -139,7 +139,7 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc /* make sure modifier data has unique name */ modifier_unique_name(&ob->modifiers, new_md); - + /* special cases */ if (type == eModifierType_Softbody) { if (!ob->soft) { @@ -150,7 +150,7 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc else if (type == eModifierType_Collision) { if (!ob->pd) ob->pd = object_add_collision_fields(0); - + ob->pd->deflect = 1; } else if (type == eModifierType_Surface) { @@ -465,14 +465,14 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene * /* add new mesh */ obn = BKE_object_add(bmain, scene, OB_MESH, NULL); me = obn->data; - + me->totvert = totvert; me->totedge = totedge; - + me->mvert = CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, totvert); me->medge = CustomData_add_layer(&me->edata, CD_MEDGE, CD_CALLOC, NULL, totedge); me->mface = CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, NULL, 0); - + mvert = me->mvert; medge = me->medge; @@ -547,18 +547,18 @@ static int modifier_apply_shape(ReportList *reports, Scene *scene, Object *ob, M Mesh *me = ob->data; Key *key = me->key; KeyBlock *kb; - + if (!modifier_isSameTopology(md) || mti->type == eModifierTypeType_NonGeometrical) { BKE_report(reports, RPT_ERROR, "Only deforming modifiers can be applied to shapes"); return 0; } - + dm = mesh_create_derived_for_modifier(scene, ob, md, 0); if (!dm) { BKE_report(reports, RPT_ERROR, "Modifier is disabled or returned error, skipping apply"); return 0; } - + if (key == NULL) { key = me->key = BKE_key_add((ID *)me); key->type = KEY_RELATIVE; @@ -570,7 +570,7 @@ static int modifier_apply_shape(ReportList *reports, Scene *scene, Object *ob, M kb = BKE_keyblock_add(key, md->name); DM_to_meshkey(dm, me, kb); - + dm->release(dm); } else { @@ -656,7 +656,7 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob, ParticleSystem *psys = ob->particlesystem.first; for (; psys; psys = psys->next) { - + if (psys->part->type != PART_HAIR) continue; @@ -718,7 +718,7 @@ int ED_object_modifier_apply(ReportList *reports, Scene *scene, Object *ob, Modi int ED_object_modifier_copy(ReportList *UNUSED(reports), Object *ob, ModifierData *md) { ModifierData *nmd; - + nmd = modifier_new(md->type); modifier_copyData(md, nmd); BLI_insertlinkafter(&ob->modifiers, md, nmd); @@ -740,19 +740,19 @@ static int modifier_add_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } static const EnumPropertyItem *modifier_add_itemf( bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) -{ +{ Object *ob = ED_object_active_context(C); EnumPropertyItem *item = NULL; const EnumPropertyItem *md_item, *group_item = NULL; const ModifierTypeInfo *mti; int totitem = 0, a; - + if (!ob) return rna_enum_object_modifier_type_items; @@ -797,15 +797,15 @@ void OBJECT_OT_modifier_add(wmOperatorType *ot) ot->name = "Add Modifier"; ot->description = "Add a procedural operation/effect to the active object"; ot->idname = "OBJECT_OT_modifier_add"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = modifier_add_exec; ot->poll = ED_operator_object_active_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ prop = RNA_def_enum(ot->srna, "type", rna_enum_object_modifier_type_items, eModifierType_Subsurf, "Type", ""); RNA_def_enum_funcs(prop, modifier_add_itemf); @@ -818,11 +818,11 @@ int edit_modifier_poll_generic(bContext *C, StructRNA *rna_type, int obtype_flag { PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", rna_type); Object *ob = (ptr.id.data) ? ptr.id.data : ED_object_active_context(C); - + if (!ob || ID_IS_LINKED(ob)) return 0; if (obtype_flag && ((1 << ob->type) & obtype_flag) == 0) return 0; if (ptr.id.data && ID_IS_LINKED(ptr.id.data)) return 0; - + return 1; } @@ -839,7 +839,7 @@ void edit_modifier_properties(wmOperatorType *ot) int edit_modifier_invoke_properties(bContext *C, wmOperator *op) { ModifierData *md; - + if (RNA_struct_property_is_set(op->ptr, "modifier")) { return true; } @@ -860,9 +860,9 @@ ModifierData *edit_modifier_property_get(wmOperator *op, Object *ob, int type) char modifier_name[MAX_NAME]; ModifierData *md; RNA_string_get(op->ptr, "modifier", modifier_name); - + md = modifiers_findByName(ob, modifier_name); - + if (md && type != 0 && md->type != type) md = NULL; @@ -878,7 +878,7 @@ static int modifier_remove_exec(bContext *C, wmOperator *op) Object *ob = ED_object_active_context(C); ModifierData *md = edit_modifier_property_get(op, ob, 0); int mode_orig = ob->mode; - + if (!md || !ED_object_modifier_remove(op->reports, bmain, ob, md)) return OPERATOR_CANCELLED; @@ -889,7 +889,7 @@ static int modifier_remove_exec(bContext *C, wmOperator *op) if ((ob->mode & OB_MODE_PARTICLE_EDIT) == 0) if (scene->basact && scene->basact->object == ob) WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL); - + return OPERATOR_FINISHED; } @@ -910,7 +910,7 @@ void OBJECT_OT_modifier_remove(wmOperatorType *ot) ot->invoke = modifier_remove_invoke; ot->exec = modifier_remove_exec; ot->poll = edit_modifier_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); @@ -928,7 +928,7 @@ static int modifier_move_up_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } @@ -949,7 +949,7 @@ void OBJECT_OT_modifier_move_up(wmOperatorType *ot) ot->invoke = modifier_move_up_invoke; ot->exec = modifier_move_up_exec; ot->poll = edit_modifier_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); @@ -967,7 +967,7 @@ static int modifier_move_down_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } @@ -988,7 +988,7 @@ void OBJECT_OT_modifier_move_down(wmOperatorType *ot) ot->invoke = modifier_move_down_invoke; ot->exec = modifier_move_down_exec; ot->poll = edit_modifier_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); @@ -1009,7 +1009,7 @@ static int modifier_apply_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } @@ -1036,10 +1036,10 @@ void OBJECT_OT_modifier_apply(wmOperatorType *ot) ot->invoke = modifier_apply_invoke; ot->exec = modifier_apply_exec; ot->poll = edit_modifier_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; - + RNA_def_enum(ot->srna, "apply_as", modifier_apply_as_items, MODIFIER_APPLY_DATA, "Apply as", "How to apply the modifier to the geometry"); edit_modifier_properties(ot); } @@ -1052,13 +1052,13 @@ static int modifier_convert_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); ModifierData *md = edit_modifier_property_get(op, ob, 0); - + if (!md || !ED_object_modifier_convert(op->reports, bmain, scene, ob, md)) return OPERATOR_CANCELLED; DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } @@ -1079,7 +1079,7 @@ void OBJECT_OT_modifier_convert(wmOperatorType *ot) ot->invoke = modifier_convert_invoke; ot->exec = modifier_convert_exec; ot->poll = edit_modifier_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); @@ -1097,7 +1097,7 @@ static int modifier_copy_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } @@ -1118,7 +1118,7 @@ void OBJECT_OT_modifier_copy(wmOperatorType *ot) ot->invoke = modifier_copy_invoke; ot->exec = modifier_copy_exec; ot->poll = edit_modifier_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); @@ -1135,18 +1135,18 @@ static int multires_higher_levels_delete_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires); - + if (!mmd) return OPERATOR_CANCELLED; - + multiresModifier_del_levels(mmd, ob, 1); ED_object_iter_other(CTX_data_main(C), ob, true, ED_object_multires_update_totlevels_cb, &mmd->totlvl); - + WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } @@ -1167,7 +1167,7 @@ void OBJECT_OT_multires_higher_levels_delete(wmOperatorType *ot) ot->poll = multires_poll; ot->invoke = multires_higher_levels_delete_invoke; ot->exec = multires_higher_levels_delete_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); @@ -1179,10 +1179,10 @@ static int multires_subdivide_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires); - + if (!mmd) return OPERATOR_CANCELLED; - + multiresModifier_subdivide(mmd, ob, 0, mmd->simple); ED_object_iter_other(CTX_data_main(C), ob, true, @@ -1196,7 +1196,7 @@ static int multires_subdivide_exec(bContext *C, wmOperator *op) /* ensure that grid paint mask layer is created */ BKE_sculpt_mask_layers_ensure(ob, mmd); } - + return OPERATOR_FINISHED; } @@ -1217,7 +1217,7 @@ void OBJECT_OT_multires_subdivide(wmOperatorType *ot) ot->poll = multires_poll; ot->invoke = multires_subdivide_invoke; ot->exec = multires_subdivide_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); @@ -1281,14 +1281,14 @@ void OBJECT_OT_multires_reshape(wmOperatorType *ot) ot->poll = multires_poll; ot->invoke = multires_reshape_invoke; ot->exec = multires_reshape_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); } - + /****************** multires save external operator *********************/ static int multires_external_save_exec(bContext *C, wmOperator *op) @@ -1304,7 +1304,7 @@ static int multires_external_save_exec(bContext *C, wmOperator *op) if (CustomData_external_test(&me->ldata, CD_MDISPS)) return OPERATOR_CANCELLED; - + RNA_string_get(op->ptr, "filepath", path); if (relative) @@ -1312,7 +1312,7 @@ static int multires_external_save_exec(bContext *C, wmOperator *op) CustomData_external_add(&me->ldata, &me->id, CD_MDISPS, me->totloop, path); CustomData_external_write(&me->ldata, &me->id, CD_MASK_MESH, me->totloop, 0); - + return OPERATOR_FINISHED; } @@ -1325,23 +1325,23 @@ static int multires_external_save_invoke(bContext *C, wmOperator *op, const wmEv if (!edit_modifier_invoke_properties(C, op)) return OPERATOR_CANCELLED; - + mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires); - + if (!mmd) return OPERATOR_CANCELLED; - + if (CustomData_external_test(&me->ldata, CD_MDISPS)) return OPERATOR_CANCELLED; if (RNA_struct_property_is_set(op->ptr, "filepath")) return multires_external_save_exec(C, op); - + op->customdata = me; BLI_snprintf(path, sizeof(path), "//%s.btx", me->id.name + 2); RNA_string_set(op->ptr, "filepath", path); - + WM_event_add_fileselect(C, op); return OPERATOR_RUNNING_MODAL; @@ -1357,7 +1357,7 @@ void OBJECT_OT_multires_external_save(wmOperatorType *ot) ot->exec = multires_external_save_exec; ot->invoke = multires_external_save_invoke; ot->poll = multires_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; @@ -1379,7 +1379,7 @@ static int multires_external_pack_exec(bContext *C, wmOperator *UNUSED(op)) /* XXX don't remove.. */ CustomData_external_remove(&me->ldata, &me->id, CD_MDISPS, me->totloop); - + return OPERATOR_FINISHED; } @@ -1391,7 +1391,7 @@ void OBJECT_OT_multires_external_pack(wmOperatorType *ot) ot->poll = multires_poll; ot->exec = multires_external_pack_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1401,15 +1401,15 @@ static int multires_base_apply_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires); - + if (!mmd) return OPERATOR_CANCELLED; - + multiresModifier_base_apply(mmd, ob); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } @@ -1431,7 +1431,7 @@ void OBJECT_OT_multires_base_apply(wmOperatorType *ot) ot->poll = multires_poll; ot->invoke = multires_base_apply_invoke; ot->exec = multires_base_apply_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); @@ -1444,7 +1444,7 @@ static void modifier_skin_customdata_delete(Object *ob) { Mesh *me = ob->data; BMEditMesh *em = me->edit_btmesh; - + if (em) BM_data_layer_free(em->bm, &em->bm->vdata, CD_MVERT_SKIN); else @@ -1467,7 +1467,7 @@ static void skin_root_clear(BMVert *bm_vert, GSet *visited, const int cd_vert_sk { BMEdge *bm_edge; BMIter bm_iter; - + BM_ITER_ELEM (bm_edge, &bm_iter, bm_vert, BM_EDGES_OF_VERT) { BMVert *v2 = BM_edge_other_vert(bm_edge, bm_vert); @@ -1515,7 +1515,7 @@ static int skin_root_mark_exec(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } @@ -1527,7 +1527,7 @@ void OBJECT_OT_skin_root_mark(wmOperatorType *ot) ot->poll = skin_edit_poll; ot->exec = skin_root_mark_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1570,7 +1570,7 @@ static int skin_loose_mark_clear_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } @@ -1588,7 +1588,7 @@ void OBJECT_OT_skin_loose_mark_clear(wmOperatorType *ot) ot->poll = skin_edit_poll; ot->exec = skin_loose_mark_clear_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1620,7 +1620,7 @@ static int skin_radii_equalize_exec(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } @@ -1632,7 +1632,7 @@ void OBJECT_OT_skin_radii_equalize(wmOperatorType *ot) ot->poll = skin_edit_poll; ot->exec = skin_radii_equalize_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1676,7 +1676,7 @@ static void skin_armature_bone_create(Object *skin_ob, ED_vgroup_vert_add(skin_ob, dg, parent_v, 1, WEIGHT_REPLACE); ED_vgroup_vert_add(skin_ob, dg, v, 1, WEIGHT_REPLACE); } - + skin_armature_bone_create(skin_ob, mvert, medge, arm, @@ -1709,7 +1709,7 @@ static Object *modifier_skin_armature_create(Main *bmain, Scene *scene, Object * CD_CALLOC, NULL, me->totvert); - + arm_ob = BKE_object_add(bmain, scene, OB_ARMATURE, NULL); BKE_object_transform_copy(arm_ob, skin_ob); arm = arm_ob->data; @@ -1742,7 +1742,7 @@ static Object *modifier_skin_armature_create(Main *bmain, Scene *scene, Object * bone->head[1] = 1.0f; bone->rad_head = bone->rad_tail = 0.25; } - + if (emap[v].count >= 1) { skin_armature_bone_create(skin_ob, mvert, me->medge, @@ -1816,7 +1816,7 @@ void OBJECT_OT_skin_armature_create(wmOperatorType *ot) ot->poll = skin_poll; ot->invoke = skin_armature_create_invoke; ot->exec = skin_armature_create_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); @@ -1901,7 +1901,7 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); MeshDeformModifierData *mmd = (MeshDeformModifierData *)edit_modifier_property_get(op, ob, eModifierType_MeshDeform); - + if (!mmd) return OPERATOR_CANCELLED; @@ -1926,7 +1926,7 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op) mmd->totvert = 0; mmd->totcagevert = 0; mmd->totinfluence = 0; - + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); } @@ -1955,7 +1955,7 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op) mmd->bindfunc = NULL; mmd->modifier.mode = mode; } - + return OPERATOR_FINISHED; } @@ -1963,7 +1963,7 @@ static int meshdeform_bind_invoke(bContext *C, wmOperator *op, const wmEvent *UN { if (edit_modifier_invoke_properties(C, op)) return meshdeform_bind_exec(C, op); - else + else return OPERATOR_CANCELLED; } @@ -1973,12 +1973,12 @@ void OBJECT_OT_meshdeform_bind(wmOperatorType *ot) ot->name = "Mesh Deform Bind"; ot->description = "Bind mesh to cage in mesh deform modifier"; ot->idname = "OBJECT_OT_meshdeform_bind"; - + /* api callbacks */ ot->poll = meshdeform_poll; ot->invoke = meshdeform_bind_invoke; ot->exec = meshdeform_bind_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); @@ -1995,7 +1995,7 @@ static int explode_refresh_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); ExplodeModifierData *emd = (ExplodeModifierData *)edit_modifier_property_get(op, ob, eModifierType_Explode); - + if (!emd) return OPERATOR_CANCELLED; @@ -2003,7 +2003,7 @@ static int explode_refresh_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } @@ -2025,7 +2025,7 @@ void OBJECT_OT_explode_refresh(wmOperatorType *ot) ot->poll = explode_poll; ot->invoke = explode_refresh_invoke; ot->exec = explode_refresh_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); @@ -2043,14 +2043,14 @@ static int ocean_bake_poll(bContext *C) static void init_ocean_modifier_bake(struct Ocean *oc, struct OceanModifierData *omd) { int do_heightfield, do_chop, do_normals, do_jacobian; - - if (!omd || !oc) return; - + + if (!omd || !oc) return; + do_heightfield = true; do_chop = (omd->chop_amount > 0); do_normals = (omd->flag & MOD_OCEAN_GENERATE_NORMALS); do_jacobian = (omd->flag & MOD_OCEAN_GENERATE_FOAM); - + BKE_ocean_init(oc, omd->resolution * omd->resolution, omd->resolution * omd->resolution, omd->spatial_size, omd->spatial_size, omd->wind_velocity, omd->smallest_wave, 1.0, omd->wave_direction, omd->damp, omd->wave_alignment, omd->depth, omd->time, @@ -2080,8 +2080,8 @@ static int oceanbake_breakjob(void *UNUSED(customdata)) { //OceanBakeJob *ob = (OceanBakeJob *)customdata; //return *(ob->stop); - - /* this is not nice yet, need to make the jobs list template better + + /* this is not nice yet, need to make the jobs list template better * for identifying/acting upon various different jobs */ /* but for now we'll reuse the render break... */ return (G.is_break); @@ -2091,10 +2091,10 @@ static int oceanbake_breakjob(void *UNUSED(customdata)) static void oceanbake_update(void *customdata, float progress, int *cancel) { OceanBakeJob *oj = customdata; - + if (oceanbake_breakjob(oj)) *cancel = 1; - + *(oj->do_update) = true; *(oj->progress) = progress; } @@ -2102,15 +2102,15 @@ static void oceanbake_update(void *customdata, float progress, int *cancel) static void oceanbake_startjob(void *customdata, short *stop, short *do_update, float *progress) { OceanBakeJob *oj = customdata; - + oj->stop = stop; oj->do_update = do_update; oj->progress = progress; - + G.is_break = false; /* XXX shared with render - replace with job 'stop' switch */ - + BKE_ocean_bake(oj->ocean, oj->och, oceanbake_update, (void *)oj); - + *do_update = true; *stop = 0; } @@ -2118,12 +2118,12 @@ static void oceanbake_startjob(void *customdata, short *stop, short *do_update, static void oceanbake_endjob(void *customdata) { OceanBakeJob *oj = customdata; - + if (oj->ocean) { BKE_ocean_free(oj->ocean); oj->ocean = NULL; } - + oj->omd->oceancache = oj->och; oj->omd->cached = true; } @@ -2138,13 +2138,13 @@ static int ocean_bake_exec(bContext *C, wmOperator *op) struct Ocean *ocean; int f, cfra, i = 0; const bool free = RNA_boolean_get(op->ptr, "free"); - + wmJob *wm_job; OceanBakeJob *oj; - + if (!omd) return OPERATOR_CANCELLED; - + if (free) { omd->refresh |= MOD_OCEAN_REFRESH_CLEAR_CACHE; DAG_id_tag_update(&ob->id, OB_RECALC_DATA); @@ -2155,11 +2155,11 @@ static int ocean_bake_exec(bContext *C, wmOperator *op) och = BKE_ocean_init_cache(omd->cachepath, modifier_path_relbase(bmain, ob), omd->bakestart, omd->bakeend, omd->wave_scale, omd->chop_amount, omd->foam_coverage, omd->foam_fade, omd->resolution); - + och->time = MEM_mallocN(och->duration * sizeof(float), "foam bake time"); - + cfra = scene->r.cfra; - + /* precalculate time variable before baking */ for (f = omd->bakestart; f <= omd->bakeend; f++) { /* from physics_fluid.c: @@ -2170,41 +2170,41 @@ static int ocean_bake_exec(bContext *C, wmOperator *op) * This doesn't work with drivers: * --> BKE_animsys_evaluate_animdata(&fsDomain->id, fsDomain->adt, eval_time, ADT_RECALC_ALL); */ - - /* Modifying the global scene isn't nice, but we can do it in + + /* Modifying the global scene isn't nice, but we can do it in * this part of the process before a threaded job is created */ - + //scene->r.cfra = f; //ED_update_for_newframe(bmain, scene, 1); - - /* ok, this doesn't work with drivers, but is way faster. + + /* ok, this doesn't work with drivers, but is way faster. * let's use this for now and hope nobody wants to drive the time value... */ BKE_animsys_evaluate_animdata(scene, (ID *)ob, ob->adt, f, ADT_RECALC_ANIM); - + och->time[i] = omd->time; i++; } - + /* make a copy of ocean to use for baking - threadsafety */ ocean = BKE_ocean_add(); init_ocean_modifier_bake(ocean, omd); - + #if 0 BKE_ocean_bake(ocean, och); - + omd->oceancache = och; omd->cached = true; - + scene->r.cfra = cfra; - + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); #endif - + /* job stuff */ - + scene->r.cfra = cfra; - + /* setup job */ wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Ocean Simulation", WM_JOB_PROGRESS, WM_JOB_TYPE_OBJECT_SIM_OCEAN); @@ -2212,15 +2212,15 @@ static int ocean_bake_exec(bContext *C, wmOperator *op) oj->ocean = ocean; oj->och = och; oj->omd = omd; - + WM_jobs_customdata_set(wm_job, oj, oceanbake_free); WM_jobs_timer(wm_job, 0.1, NC_OBJECT | ND_MODIFIER, NC_OBJECT | ND_MODIFIER); WM_jobs_callbacks(wm_job, oceanbake_startjob, NULL, NULL, oceanbake_endjob); - + WM_jobs_start(CTX_wm_manager(C), wm_job); - - - + + + return OPERATOR_FINISHED; } @@ -2238,15 +2238,15 @@ void OBJECT_OT_ocean_bake(wmOperatorType *ot) ot->name = "Bake Ocean"; ot->description = "Bake an image sequence of ocean data"; ot->idname = "OBJECT_OT_ocean_bake"; - + ot->poll = ocean_bake_poll; ot->invoke = ocean_bake_invoke; ot->exec = ocean_bake_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); - + RNA_def_boolean(ot->srna, "free", false, "Free", "Free the bake, rather than generating it"); } @@ -2279,7 +2279,7 @@ static int laplaciandeform_bind_invoke(bContext *C, wmOperator *op, const wmEven { if (edit_modifier_invoke_properties(C, op)) return laplaciandeform_bind_exec(C, op); - else + else return OPERATOR_CANCELLED; } @@ -2289,12 +2289,12 @@ void OBJECT_OT_laplaciandeform_bind(wmOperatorType *ot) ot->name = "Laplacian Deform Bind"; ot->description = "Bind mesh to system in laplacian deform modifier"; ot->idname = "OBJECT_OT_laplaciandeform_bind"; - + /* api callbacks */ ot->poll = laplaciandeform_poll; ot->invoke = laplaciandeform_bind_invoke; ot->exec = laplaciandeform_bind_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index ed78342f3d2..9a0b37e6dab 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -62,7 +62,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_visual_transform_apply); WM_operatortype_append(OBJECT_OT_transform_apply); WM_operatortype_append(OBJECT_OT_origin_set); - + WM_operatortype_append(OBJECT_OT_mode_set); WM_operatortype_append(OBJECT_OT_editmode_toggle); WM_operatortype_append(OBJECT_OT_posemode_toggle); @@ -150,7 +150,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_meshdeform_bind); WM_operatortype_append(OBJECT_OT_explode_refresh); WM_operatortype_append(OBJECT_OT_ocean_bake); - + WM_operatortype_append(OBJECT_OT_constraint_add); WM_operatortype_append(OBJECT_OT_constraint_add_with_targets); WM_operatortype_append(POSE_OT_constraint_add); @@ -253,7 +253,7 @@ void ED_operatormacros_object(void) { wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - + ot = WM_operatortype_append_macro("OBJECT_OT_duplicate_move", "Duplicate Objects", "Duplicate selected objects and move them", OPTYPE_UNDO | OPTYPE_REGISTER); if (ot) { @@ -271,7 +271,7 @@ void ED_operatormacros_object(void) otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", PROP_EDIT_OFF); } - + } static int object_mode_poll(bContext *C) @@ -285,10 +285,10 @@ void ED_keymap_object(wmKeyConfig *keyconf) wmKeyMap *keymap; wmKeyMapItem *kmi; int i; - + /* Objects, Regardless of Mode -------------------------------------------------- */ keymap = WM_keymap_find(keyconf, "Object Non-modal", 0, 0); - + /* Note: this keymap works disregarding mode */ kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", TABKEY, KM_PRESS, 0, 0); RNA_enum_set(kmi->ptr, "mode", OB_MODE_EDIT); @@ -301,18 +301,18 @@ void ED_keymap_object(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", VKEY, KM_PRESS, 0, 0); RNA_enum_set(kmi->ptr, "mode", OB_MODE_VERTEX_PAINT); RNA_boolean_set(kmi->ptr, "toggle", true); - + kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", TABKEY, KM_PRESS, KM_CTRL, 0); RNA_enum_set(kmi->ptr, "mode", OB_MODE_WEIGHT_PAINT); RNA_boolean_set(kmi->ptr, "toggle", true); - + WM_keymap_add_item(keymap, "OBJECT_OT_origin_set", CKEY, KM_PRESS, KM_ALT | KM_SHIFT | KM_CTRL, 0); /* Object Mode ---------------------------------------------------------------- */ /* Note: this keymap gets disabled in non-objectmode, */ keymap = WM_keymap_find(keyconf, "Object Mode", 0, 0); keymap->poll = object_mode_poll; - + /* object mode supports PET now */ ED_keymap_proportional_cycle(keyconf, keymap); ED_keymap_proportional_obmode(keyconf, keymap); @@ -331,7 +331,7 @@ void ED_keymap_object(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "OBJECT_OT_select_linked", LKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "OBJECT_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "OBJECT_OT_select_mirror", MKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); - + kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, 0, 0); RNA_enum_set_identifier(NULL, kmi->ptr, "direction", "PARENT"); RNA_boolean_set(kmi->ptr, "extend", false); @@ -353,20 +353,20 @@ void ED_keymap_object(wmKeyConfig *keyconf) WM_keymap_verify_item(keymap, "OBJECT_OT_parent_clear", PKEY, KM_PRESS, KM_ALT, 0); WM_keymap_verify_item(keymap, "OBJECT_OT_track_set", TKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_verify_item(keymap, "OBJECT_OT_track_clear", TKEY, KM_PRESS, KM_ALT, 0); - + WM_keymap_verify_item(keymap, "OBJECT_OT_constraint_add_with_targets", CKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); WM_keymap_verify_item(keymap, "OBJECT_OT_constraints_clear", CKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); - - + + kmi = WM_keymap_add_item(keymap, "OBJECT_OT_location_clear", GKEY, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "clear_delta", false); kmi = WM_keymap_add_item(keymap, "OBJECT_OT_rotation_clear", RKEY, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "clear_delta", false); kmi = WM_keymap_add_item(keymap, "OBJECT_OT_scale_clear", SKEY, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "clear_delta", false); - + WM_keymap_verify_item(keymap, "OBJECT_OT_origin_clear", OKEY, KM_PRESS, KM_ALT, 0); - + WM_keymap_add_item(keymap, "OBJECT_OT_hide_view_clear", HKEY, KM_PRESS, KM_ALT, 0); kmi = WM_keymap_add_item(keymap, "OBJECT_OT_hide_view_set", HKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "unselected", false); @@ -385,7 +385,7 @@ void ED_keymap_object(wmKeyConfig *keyconf) #endif WM_keymap_add_item(keymap, "OBJECT_OT_move_to_layer", MKEY, KM_PRESS, 0, 0); - + kmi = WM_keymap_add_item(keymap, "OBJECT_OT_delete", XKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "use_global", false); @@ -407,7 +407,7 @@ void ED_keymap_object(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "OBJECT_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "OBJECT_OT_duplicate_move_linked", DKEY, KM_PRESS, KM_ALT, 0); - + WM_keymap_add_item(keymap, "OBJECT_OT_join", JKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "OBJECT_OT_convert", CKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "OBJECT_OT_proxy_make", PKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); @@ -417,13 +417,13 @@ void ED_keymap_object(wmKeyConfig *keyconf) WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_insert_menu", IKEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_delete_v3d", IKEY, KM_PRESS, KM_ALT, 0); WM_keymap_verify_item(keymap, "ANIM_OT_keying_set_active_set", IKEY, KM_PRESS, KM_CTRL | KM_SHIFT | KM_ALT, 0); - + WM_keymap_verify_item(keymap, "GROUP_OT_create", GKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_verify_item(keymap, "GROUP_OT_objects_remove", GKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); WM_keymap_verify_item(keymap, "GROUP_OT_objects_remove_all", GKEY, KM_PRESS, KM_SHIFT | KM_CTRL | KM_ALT, 0); WM_keymap_verify_item(keymap, "GROUP_OT_objects_add_active", GKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); WM_keymap_verify_item(keymap, "GROUP_OT_objects_remove_active", GKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0); - + WM_keymap_add_menu(keymap, "VIEW3D_MT_object_specials", WKEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "OBJECT_OT_data_transfer", TKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index 440c9d01487..6b53807ce1c 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -83,7 +83,7 @@ * this takes into account the 'restrict selection in 3d view' flag. * deselect works always, the restriction just prevents selection */ -/* Note: send a NC_SCENE|ND_OB_SELECT notifier yourself! (or +/* Note: send a NC_SCENE|ND_OB_SELECT notifier yourself! (or * or a NC_SCENE|ND_OB_VISIBLE in case of visibility toggling */ void ED_base_object_select(Base *base, short mode) @@ -104,15 +104,15 @@ void ED_base_object_select(Base *base, short mode) void ED_base_object_activate(bContext *C, Base *base) { Scene *scene = CTX_data_scene(C); - + /* sets scene->basact */ BASACT = base; - + if (base) { - + /* XXX old signals, remember to handle notifiers now! */ // select_actionchannel_by_name(base->object->action, "Object", 1); - + WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene); } else @@ -131,7 +131,7 @@ static int objects_selectable_poll(bContext *C) return 0; if (obact && obact->mode) return 0; - + return 1; } @@ -140,10 +140,10 @@ static int objects_selectable_poll(bContext *C) static int object_select_by_type_exec(bContext *C, wmOperator *op) { short obtype, extend; - + obtype = RNA_enum_get(op->ptr, "type"); extend = RNA_boolean_get(op->ptr, "extend"); - + if (extend == 0) { CTX_DATA_BEGIN (C, Base *, base, visible_bases) { @@ -151,7 +151,7 @@ static int object_select_by_type_exec(bContext *C, wmOperator *op) } CTX_DATA_END; } - + CTX_DATA_BEGIN (C, Base *, base, visible_bases) { if (base->object->type == obtype) { @@ -159,9 +159,9 @@ static int object_select_by_type_exec(bContext *C, wmOperator *op) } } CTX_DATA_END; - + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); - + return OPERATOR_FINISHED; } @@ -171,15 +171,15 @@ void OBJECT_OT_select_by_type(wmOperatorType *ot) ot->name = "Select By Type"; ot->description = "Select all visible objects that are of a type"; ot->idname = "OBJECT_OT_select_by_type"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = object_select_by_type_exec; ot->poll = objects_selectable_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting everything first"); ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_object_type_items, 1, "Type", ""); @@ -324,7 +324,7 @@ static bool object_select_all_by_particle(bContext *C, Object *ob) if ((base->flag & SELECT) == 0) { /* loop through other particles*/ ParticleSystem *psys; - + for (psys = base->object->particlesystem.first; psys; psys = psys->next) { if (psys->part == psys_act->part) { base->flag |= SELECT; @@ -413,7 +413,7 @@ static int object_select_linked_exec(bContext *C, wmOperator *op) bool changed = false, extend; extend = RNA_boolean_get(op->ptr, "extend"); - + if (extend == 0) { CTX_DATA_BEGIN (C, Base *, base, visible_bases) { @@ -421,13 +421,13 @@ static int object_select_linked_exec(bContext *C, wmOperator *op) } CTX_DATA_END; } - + ob = OBACT; if (ob == NULL) { BKE_report(op->reports, RPT_ERROR, "No active object"); return OPERATOR_CANCELLED; } - + if (nr == OBJECT_SELECT_LINKED_IPO) { // XXX old animation system //if (ob->ipo == 0) return OPERATOR_CANCELLED; @@ -485,7 +485,7 @@ static int object_select_linked_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); return OPERATOR_FINISHED; } - + return OPERATOR_CANCELLED; } @@ -495,15 +495,15 @@ void OBJECT_OT_select_linked(wmOperatorType *ot) ot->name = "Select Linked"; ot->description = "Select all visible objects that are linked"; ot->idname = "OBJECT_OT_select_linked"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = object_select_linked_exec; ot->poll = objects_selectable_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting everything first"); ot->prop = RNA_def_enum(ot->srna, "type", prop_select_linked_types, 0, "Type", ""); @@ -781,7 +781,7 @@ static bool select_grouped_keyingset(bContext *C, Object *UNUSED(ob), ReportList { KeyingSet *ks = ANIM_scene_get_active_keyingset(CTX_data_scene(C)); bool changed = false; - + /* firstly, validate KeyingSet */ if (ks == NULL) { BKE_report(reports, RPT_ERROR, "No active Keying Set to use"); @@ -790,7 +790,7 @@ static bool select_grouped_keyingset(bContext *C, Object *UNUSED(ob), ReportList else if (ANIM_validate_keyingset(C, NULL, ks) != 0) { if (ks->paths.first == NULL) { if ((ks->flag & KEYINGSET_ABSOLUTE) == 0) { - BKE_report(reports, RPT_ERROR, + BKE_report(reports, RPT_ERROR, "Use another Keying Set, as the active one depends on the currently " "selected objects or cannot find any targets due to unsuitable context"); } @@ -800,7 +800,7 @@ static bool select_grouped_keyingset(bContext *C, Object *UNUSED(ob), ReportList } return false; } - + /* select each object that Keying Set refers to */ /* TODO: perhaps to be more in line with the rest of these, we should only take objects * if the passed in object is included in this too */ @@ -809,8 +809,8 @@ static bool select_grouped_keyingset(bContext *C, Object *UNUSED(ob), ReportList /* only check for this object if it isn't selected already, to limit time wasted */ if ((base->flag & SELECT) == 0) { KS_Path *ksp; - - /* this is the slow way... we could end up with > 500 items here, + + /* this is the slow way... we could end up with > 500 items here, * with none matching, but end up doing this on 1000 objects... */ for (ksp = ks->paths.first; ksp; ksp = ksp->next) { @@ -824,7 +824,7 @@ static bool select_grouped_keyingset(bContext *C, Object *UNUSED(ob), ReportList } } CTX_DATA_END; - + return changed; } @@ -914,15 +914,15 @@ void OBJECT_OT_select_grouped(wmOperatorType *ot) ot->name = "Select Grouped"; ot->description = "Select all visible objects grouped by various properties"; ot->idname = "OBJECT_OT_select_grouped"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = object_select_grouped_exec; ot->poll = objects_selectable_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting everything first"); ot->prop = RNA_def_enum(ot->srna, "type", prop_select_grouped_types, 0, "Type", ""); @@ -939,11 +939,11 @@ static int object_select_by_layer_exec(bContext *C, wmOperator *op) unsigned int layernum; bool extend; int match; - + extend = RNA_boolean_get(op->ptr, "extend"); layernum = RNA_int_get(op->ptr, "layers"); match = RNA_enum_get(op->ptr, "match"); - + if (extend == false) { CTX_DATA_BEGIN (C, Base *, base, visible_bases) { @@ -951,7 +951,7 @@ static int object_select_by_layer_exec(bContext *C, wmOperator *op) } CTX_DATA_END; } - + CTX_DATA_BEGIN (C, Base *, base, visible_bases) { bool ok = false; @@ -973,10 +973,10 @@ static int object_select_by_layer_exec(bContext *C, wmOperator *op) } } CTX_DATA_END; - + /* undo? */ WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); - + return OPERATOR_FINISHED; } @@ -992,15 +992,15 @@ void OBJECT_OT_select_by_layer(wmOperatorType *ot) ot->name = "Select by Layer"; ot->description = "Select all visible objects on a layer"; ot->idname = "OBJECT_OT_select_by_layer"; - + /* api callbacks */ /*ot->invoke = XXX - need a int grid popup*/ ot->exec = object_select_by_layer_exec; ot->poll = objects_selectable_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_enum(ot->srna, "match", match_items, OB_SEL_LAYERMATCH_EXACT, "Match", ""); RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting everything first"); @@ -1012,7 +1012,7 @@ void OBJECT_OT_select_by_layer(wmOperatorType *ot) static int object_select_all_exec(bContext *C, wmOperator *op) { int action = RNA_enum_get(op->ptr, "action"); - + /* passthrough if no objects are visible */ if (CTX_DATA_COUNT(C, visible_bases) == 0) return OPERATOR_PASS_THROUGH; @@ -1048,24 +1048,24 @@ static int object_select_all_exec(bContext *C, wmOperator *op) } } CTX_DATA_END; - + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); - + return OPERATOR_FINISHED; } void OBJECT_OT_select_all(wmOperatorType *ot) { - + /* identifiers */ ot->name = "(De)select All"; ot->description = "Change selection of all visible objects in scene"; ot->idname = "OBJECT_OT_select_all"; - + /* api callbacks */ ot->exec = object_select_all_exec; ot->poll = objects_selectable_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1099,22 +1099,22 @@ static int object_select_same_group_exec(bContext *C, wmOperator *op) CTX_DATA_END; WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); - + return OPERATOR_FINISHED; } void OBJECT_OT_select_same_group(wmOperatorType *ot) { - + /* identifiers */ ot->name = "Select Same Group"; ot->description = "Select object in the same group"; ot->idname = "OBJECT_OT_select_same_group"; - + /* api callbacks */ ot->exec = object_select_same_group_exec; ot->poll = objects_selectable_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1127,15 +1127,15 @@ static int object_select_mirror_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); bool extend; - + extend = RNA_boolean_get(op->ptr, "extend"); - + CTX_DATA_BEGIN (C, Base *, primbase, selected_bases) { char name_flip[MAXBONENAME]; BLI_string_flip_side_name(name_flip, primbase->object->id.name + 2, true, sizeof(name_flip)); - + if (!STREQ(name_flip, primbase->object->id.name + 2)) { Object *ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, name_flip); if (ob) { @@ -1146,33 +1146,33 @@ static int object_select_mirror_exec(bContext *C, wmOperator *op) } } } - + if (extend == false) ED_base_object_select(primbase, BA_DESELECT); - + } CTX_DATA_END; - + /* undo? */ WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); - + return OPERATOR_FINISHED; } void OBJECT_OT_select_mirror(wmOperatorType *ot) { - + /* identifiers */ ot->name = "Select Mirror"; ot->description = "Select the Mirror objects of the selected object eg. L.sword -> R.sword"; ot->idname = "OBJECT_OT_select_mirror"; - + /* api callbacks */ ot->exec = object_select_mirror_exec; ot->poll = objects_selectable_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend selection instead of deselecting everything first"); } @@ -1297,7 +1297,7 @@ void OBJECT_OT_select_less(wmOperatorType *ot) /**************************** Select Random ****************************/ static int object_select_random_exec(bContext *C, wmOperator *op) -{ +{ const float randfac = RNA_float_get(op->ptr, "percent") / 100.0f; const int seed = WM_operator_properties_select_random_seed_increment_get(op); const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT); @@ -1315,7 +1315,7 @@ static int object_select_random_exec(bContext *C, wmOperator *op) BLI_rng_free(rng); WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); - + return OPERATOR_FINISHED; } @@ -1325,15 +1325,15 @@ void OBJECT_OT_select_random(wmOperatorType *ot) ot->name = "Select Random"; ot->description = "Set select on random visible objects"; ot->idname = "OBJECT_OT_select_random"; - + /* api callbacks */ /*ot->invoke = object_select_random_invoke XXX - need a number popup ;*/ ot->exec = object_select_random_exec; ot->poll = objects_selectable_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ WM_operator_properties_select_random(ot); } diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c index 27da607c696..7d7130fdbc7 100644 --- a/source/blender/editors/object/object_shapekey.c +++ b/source/blender/editors/object/object_shapekey.c @@ -35,7 +35,7 @@ #include <unistd.h> #else #include <io.h> -#endif +#endif #include "MEM_guardedalloc.h" @@ -117,7 +117,7 @@ static bool object_shape_key_mirror(bContext *C, Object *ob, key = BKE_key_from_object(ob); if (key == NULL) return 0; - + kb = BLI_findlink(&key->block, ob->shapenr - 1); if (kb) { @@ -209,7 +209,7 @@ static bool object_shape_key_mirror(bContext *C, Object *ob, MEM_freeN(tag_elem); } - + *r_totmirr = totmirr; *r_totfail = totfail; @@ -276,7 +276,7 @@ void OBJECT_OT_shape_key_add(wmOperatorType *ot) ot->name = "Add Shape Key"; ot->idname = "OBJECT_OT_shape_key_add"; ot->description = "Add shape key to the object"; - + /* api callbacks */ ot->poll = shape_key_mode_poll; ot->exec = shape_key_add_exec; @@ -319,7 +319,7 @@ void OBJECT_OT_shape_key_remove(wmOperatorType *ot) ot->name = "Remove Shape Key"; ot->idname = "OBJECT_OT_shape_key_remove"; ot->description = "Remove shape key from the object"; - + /* api callbacks */ ot->poll = shape_key_mode_exists_poll; ot->exec = shape_key_remove_exec; @@ -339,13 +339,13 @@ static int shape_key_clear_exec(bContext *C, wmOperator *UNUSED(op)) if (!key || !kb) return OPERATOR_CANCELLED; - + for (kb = key->block.first; kb; kb = kb->next) kb->curval = 0.0f; DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); - + return OPERATOR_FINISHED; } @@ -355,7 +355,7 @@ void OBJECT_OT_shape_key_clear(wmOperatorType *ot) ot->name = "Clear Shape Keys"; ot->description = "Clear weights for all shape keys"; ot->idname = "OBJECT_OT_shape_key_clear"; - + /* api callbacks */ ot->poll = shape_key_poll; ot->exec = shape_key_clear_exec; diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 080710e0a38..19dad374696 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -118,7 +118,7 @@ static void object_clear_rot(Object *ob, const bool clear_delta) ob->rotAxis[2] = 0.0f; if (clear_delta) ob->drotAxis[2] = 0.0f; } - + /* check validity of axis - axis should never be 0,0,0 (if so, then we make it rotate about y) */ if (IS_EQF(ob->rotAxis[0], ob->rotAxis[1]) && IS_EQF(ob->rotAxis[1], ob->rotAxis[2])) ob->rotAxis[1] = 1.0f; @@ -164,7 +164,7 @@ static void object_clear_rot(Object *ob, const bool clear_delta) /* perform clamping using euler form (3-components) */ /* FIXME: deltas are not handled for these cases yet... */ float eul[3], oldeul[3], quat1[4] = {0}; - + if (ob->rotmode == ROT_MODE_QUAT) { copy_qt_qt(quat1, ob->quat); quat_to_eul(oldeul, ob->quat); @@ -175,16 +175,16 @@ static void object_clear_rot(Object *ob, const bool clear_delta) else { copy_v3_v3(oldeul, ob->rot); } - + eul[0] = eul[1] = eul[2] = 0.0f; - + if (ob->protectflag & OB_LOCK_ROTX) eul[0] = oldeul[0]; if (ob->protectflag & OB_LOCK_ROTY) eul[1] = oldeul[1]; if (ob->protectflag & OB_LOCK_ROTZ) eul[2] = oldeul[2]; - + if (ob->rotmode == ROT_MODE_QUAT) { eul_to_quat(ob->quat, eul); /* quaternions flip w sign to accumulate rotations correctly */ @@ -237,24 +237,24 @@ static void object_clear_scale(Object *ob, const bool clear_delta) /* --------------- */ /* generic exec for clear-transform operators */ -static int object_clear_transform_generic_exec(bContext *C, wmOperator *op, +static int object_clear_transform_generic_exec(bContext *C, wmOperator *op, void (*clear_func)(Object *, const bool), const char default_ksName[]) { Scene *scene = CTX_data_scene(C); KeyingSet *ks; const bool clear_delta = RNA_boolean_get(op->ptr, "clear_delta"); - + /* sanity checks */ if (ELEM(NULL, clear_func, default_ksName)) { BKE_report(op->reports, RPT_ERROR, "Programming error: missing clear transform function or keying set name"); return OPERATOR_CANCELLED; } - + /* get KeyingSet to use */ ks = ANIM_get_keyingset_for_autokeying(scene, default_ksName); - - /* operate on selected objects only if they aren't in weight-paint mode + + /* operate on selected objects only if they aren't in weight-paint mode * (so that object-transform clearing won't be applied at same time as bone-clearing) */ CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) @@ -262,15 +262,15 @@ static int object_clear_transform_generic_exec(bContext *C, wmOperator *op, if (!(ob->mode & OB_MODE_WEIGHT_PAINT)) { /* run provided clearing function */ clear_func(ob, clear_delta); - + ED_autokeyframe_object(C, scene, ob, ks); - + /* tag for updates */ DAG_id_tag_update(&ob->id, OB_RECALC_OB); } } CTX_DATA_END; - + /* this is needed so children are also updated */ WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); @@ -291,15 +291,15 @@ void OBJECT_OT_location_clear(wmOperatorType *ot) ot->name = "Clear Location"; ot->description = "Clear the object's location"; ot->idname = "OBJECT_OT_location_clear"; - + /* api callbacks */ ot->exec = object_location_clear_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - - + + /* properties */ ot->prop = RNA_def_boolean(ot->srna, "clear_delta", false, "Clear Delta", "Clear delta location in addition to clearing the normal location transform"); @@ -316,14 +316,14 @@ void OBJECT_OT_rotation_clear(wmOperatorType *ot) ot->name = "Clear Rotation"; ot->description = "Clear the object's rotation"; ot->idname = "OBJECT_OT_rotation_clear"; - + /* api callbacks */ ot->exec = object_rotation_clear_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_boolean(ot->srna, "clear_delta", false, "Clear Delta", "Clear delta rotation in addition to clearing the normal rotation transform"); @@ -340,14 +340,14 @@ void OBJECT_OT_scale_clear(wmOperatorType *ot) ot->name = "Clear Scale"; ot->description = "Clear the object's scale"; ot->idname = "OBJECT_OT_scale_clear"; - + /* api callbacks */ ot->exec = object_scale_clear_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_boolean(ot->srna, "clear_delta", false, "Clear Delta", "Clear delta scale in addition to clearing the normal scale transform"); @@ -366,7 +366,7 @@ static int object_origin_clear_exec(bContext *C, wmOperator *UNUSED(op)) /* vectors pointed to by v1 and v3 will get modified */ v1 = ob->loc; v3 = ob->parentinv[3]; - + copy_m3_m4(mat, ob->parentinv); negate_v3_v3(v3, v1); mul_m3_v3(mat, v3); @@ -377,7 +377,7 @@ static int object_origin_clear_exec(bContext *C, wmOperator *UNUSED(op)) CTX_DATA_END; WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); - + return OPERATOR_FINISHED; } @@ -387,11 +387,11 @@ void OBJECT_OT_origin_clear(wmOperatorType *ot) ot->name = "Clear Origin"; ot->description = "Clear the object's origin"; ot->idname = "OBJECT_OT_origin_clear"; - + /* api callbacks */ ot->exec = object_origin_clear_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -404,7 +404,7 @@ static void ignore_parent_tx(Main *bmain, Scene *scene, Object *ob) { Object workob; Object *ob_child; - + /* a change was made, adjust the children to compensate */ for (ob_child = bmain->object.first; ob_child; ob_child = ob_child->id.next) { if (ob_child->parent == ob) { @@ -424,7 +424,7 @@ static int apply_objects_internal( Scene *scene = CTX_data_scene(C); float rsmat[3][3], obmat[3][3], iobmat[3][3], mat[4][4], scale; bool changed = true; - + /* first check if we can execute */ CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { @@ -487,7 +487,7 @@ static int apply_objects_internal( } } CTX_DATA_END; - + if (!changed) return OPERATOR_CANCELLED; @@ -539,10 +539,10 @@ static int apply_objects_internal( if (apply_scale) multiresModifier_scale_disp(scene, ob); - + /* adjust data */ BKE_mesh_transform(me, mat, true); - + /* update normals */ BKE_mesh_calc_normals(me); } @@ -594,12 +594,12 @@ static int apply_objects_internal( BKE_tracking_reconstruction_scale(&clip->tracking, ob->size); } else if (ob->type == OB_EMPTY) { - /* It's possible for empties too, even though they don't + /* It's possible for empties too, even though they don't * really have obdata, since we can simply apply the maximum * scaling to the empty's drawsize. * * Core Assumptions: - * 1) Most scaled empties have uniform scaling + * 1) Most scaled empties have uniform scaling * (i.e. for visibility reasons), AND/OR * 2) Preserving non-uniform scaling is not that important, * and is something that many users would be willing to @@ -670,7 +670,7 @@ static int visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); bool changed = false; - + CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { BKE_object_where_is_calc(scene, ob); @@ -679,7 +679,7 @@ static int visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op)) /* update for any children that may get moved */ DAG_id_tag_update(&ob->id, OB_RECALC_OB); - + changed = true; } CTX_DATA_END; @@ -697,11 +697,11 @@ void OBJECT_OT_visual_transform_apply(wmOperatorType *ot) ot->name = "Apply Visual Transform"; ot->description = "Apply the object's visual transformation to its data"; ot->idname = "OBJECT_OT_visual_transform_apply"; - + /* api callbacks */ ot->exec = visual_transform_apply_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -791,7 +791,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) BMEditMesh *em = me->edit_btmesh; BMVert *eve; BMIter iter; - + if (centermode == ORIGIN_TO_CURSOR) { copy_v3_v3(cent, cursor); invert_m4_m4(obedit->imat, obedit->obmat); @@ -815,7 +815,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) mid_v3_v3v3(cent, min, max); } } - + BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { sub_v3_v3(eve->co, cent); } @@ -868,7 +868,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) invert_m4_m4(ob->imat, ob->obmat); mul_m4_v3(ob->imat, cent); } - + if (ob->data == NULL) { /* special support for dupligroups */ if ((ob->transflag & OB_DUPLIGROUP) && ob->dup_group && (ob->dup_group->id.tag & LIB_TAG_DOIT) == 0) { @@ -888,7 +888,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) invert_m4_m4(ob->imat, ob->obmat); mul_m4_v3(ob->imat, cent); } - + add_v3_v3(ob->dup_group->dupli_ofs, cent); tot_change++; @@ -1065,7 +1065,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) } ignore_parent_tx(bmain, scene, ob); - + /* other users? */ //CTX_DATA_BEGIN (C, Object *, ob_other, selected_editable_objects) //{ @@ -1136,27 +1136,27 @@ void OBJECT_OT_origin_set(wmOperatorType *ot) "Calculate the center of mass from the volume (must be manifold geometry with consistent normals)"}, {0, NULL, 0, NULL, NULL} }; - + static const EnumPropertyItem prop_set_bounds_types[] = { {V3D_AROUND_CENTER_MEAN, "MEDIAN", 0, "Median Center", ""}, {V3D_AROUND_CENTER_BOUNDS, "BOUNDS", 0, "Bounds Center", ""}, {0, NULL, 0, NULL, NULL} }; - + /* identifiers */ ot->name = "Set Origin"; ot->description = "Set the object's origin, by either moving the data, or set to center of data, or use 3D cursor"; ot->idname = "OBJECT_OT_origin_set"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = object_origin_set_exec; - + ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + ot->prop = RNA_def_enum(ot->srna, "type", prop_set_center_types, 0, "Type", ""); RNA_def_enum(ot->srna, "center", prop_set_bounds_types, V3D_AROUND_CENTER_MEAN, "Center", ""); } diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index c6c20182ac3..fcb2d45f73b 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -769,7 +769,7 @@ static void ED_vgroup_nr_vert_add( /* get the vert */ BKE_object_defgroup_array_get(ob->data, &dvert, &tot); - + if (dvert == NULL) return; @@ -934,7 +934,7 @@ static float get_vert_def_nr(Object *ob, const int def_nr, const int vertnum) dv = <->dvert[vertnum]; } } - + if (dv) { MDeformWeight *dw = defvert_find_index(dv, def_nr); if (dw) { @@ -1021,12 +1021,12 @@ static void vgroup_select_verts(Object *ob, int select) } else if (ob->type == OB_LATTICE) { Lattice *lt = vgroup_edit_lattice(ob); - + if (lt->dvert) { MDeformVert *dv; BPoint *bp, *actbp = BKE_lattice_active_point_get(lt); int a, tot; - + dv = lt->dvert; tot = lt->pntsu * lt->pntsv * lt->pntsw; @@ -1054,7 +1054,7 @@ static void vgroup_duplicate(Object *ob) dg = BLI_findlink(&ob->defbase, (ob->actdef - 1)); if (!dg) return; - + if (!strstr(dg->name, "_copy")) { BLI_snprintf(name, sizeof(name), "%s_copy", dg->name); } @@ -1124,7 +1124,7 @@ static bool vgroup_normalize(Object *ob) if (weight_max > 0.0f) { for (i = 0; i < dvert_tot; i++) { - + /* in case its not selected */ if (!(dv = dvert_array[i])) { continue; @@ -1133,7 +1133,7 @@ static bool vgroup_normalize(Object *ob) dw = defvert_find_index(dv, def_nr); if (dw) { dw->weight /= weight_max; - + /* in case of division errors with very low weights */ CLAMP(dw->weight, 0.0f, 1.0f); } @@ -1458,7 +1458,7 @@ static void moveCloserToDistanceFromPlane( MEM_freeN(dwIndices); } -/* this is used to try to smooth a surface by only adjusting the nonzero weights of a vertex +/* this is used to try to smooth a surface by only adjusting the nonzero weights of a vertex * but it could be used to raise or lower an existing 'bump.' */ static void vgroup_fix(Scene *scene, Object *ob, float distToBe, float strength, float cp) { @@ -1483,7 +1483,7 @@ static void vgroup_fix(Scene *scene, Object *ob, float distToBe, float strength, dm->getVert(dm, verts[k], &m); p[k] = m; } - + if (count >= 3) { float d /*, dist */ /* UNUSED */, mag; float coord[3]; @@ -2638,7 +2638,7 @@ static int vertex_group_add_exec(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob->data); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); - + return OPERATOR_FINISHED; } @@ -2648,7 +2648,7 @@ void OBJECT_OT_vertex_group_add(wmOperatorType *ot) ot->name = "Add Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_add"; ot->description = "Add a new vertex group to the active object"; - + /* api callbacks */ ot->poll = vertex_group_supported_poll; ot->exec = vertex_group_add_exec; @@ -2671,7 +2671,7 @@ static int vertex_group_remove_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob->data); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); - + return OPERATOR_FINISHED; } @@ -2681,7 +2681,7 @@ void OBJECT_OT_vertex_group_remove(wmOperatorType *ot) ot->name = "Remove Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_remove"; ot->description = "Delete the active or all vertex groups from the active object"; - + /* api callbacks */ ot->poll = vertex_group_poll; ot->exec = vertex_group_remove_exec; @@ -2701,11 +2701,11 @@ static int vertex_group_assign_exec(bContext *C, wmOperator *UNUSED(op)) { ToolSettings *ts = CTX_data_tool_settings(C); Object *ob = ED_object_context(C); - + vgroup_assign_verts(ob, ts->vgroup_weight); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); - + return OPERATOR_FINISHED; } @@ -2715,7 +2715,7 @@ void OBJECT_OT_vertex_group_assign(wmOperatorType *ot) ot->name = "Assign to Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_assign"; ot->description = "Assign the selected vertices to the active vertex group"; - + /* api callbacks */ ot->poll = vertex_group_vert_select_unlocked_poll; ot->exec = vertex_group_assign_exec; @@ -2733,7 +2733,7 @@ static int vertex_group_assign_new_exec(bContext *C, wmOperator *op) /* create new group... */ Object *ob = ED_object_context(C); BKE_object_defgroup_add(ob); - + /* assign selection to new group */ return vertex_group_assign_exec(C, op); } @@ -2744,11 +2744,11 @@ void OBJECT_OT_vertex_group_assign_new(wmOperatorType *ot) ot->name = "Assign to New Group"; ot->idname = "OBJECT_OT_vertex_group_assign_new"; ot->description = "Assign the selected vertices to a new vertex group"; - + /* api callbacks */ ot->poll = vertex_group_vert_select_poll; ot->exec = vertex_group_assign_new_exec; - + /* flags */ /* redo operator will fail in this case because vertex group assignment * isn't stored in local edit mode stack and toggling "new" property will @@ -2890,7 +2890,7 @@ void OBJECT_OT_vertex_group_copy(wmOperatorType *ot) static int vertex_group_levels_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_context(C); - + float offset = RNA_float_get(op->ptr, "offset"); float gain = RNA_float_get(op->ptr, "gain"); eVGroupSelect subset_type = RNA_enum_get(op->ptr, "group_select_mode"); @@ -2900,11 +2900,11 @@ static int vertex_group_levels_exec(bContext *C, wmOperator *op) const bool *vgroup_validmap = BKE_object_defgroup_subset_from_select_type(ob, subset_type, &vgroup_tot, &subset_count); vgroup_levels_subset(ob, vgroup_validmap, vgroup_tot, subset_count, offset, gain); MEM_freeN((void *)vgroup_validmap); - + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); - + return OPERATOR_FINISHED; } @@ -2914,14 +2914,14 @@ void OBJECT_OT_vertex_group_levels(wmOperatorType *ot) ot->name = "Vertex Group Levels"; ot->idname = "OBJECT_OT_vertex_group_levels"; ot->description = "Add some offset and multiply with some gain the weights of the active vertex group"; - + /* api callbacks */ ot->poll = vertex_group_poll; ot->exec = vertex_group_levels_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + vgroup_operator_subset_select_props(ot, true); RNA_def_float(ot->srna, "offset", 0.f, -1.0, 1.0, "Offset", "Value to add to weights", -1.0f, 1.f); RNA_def_float(ot->srna, "gain", 1.f, 0.f, FLT_MAX, "Gain", "Value to multiply weights by", 0.0f, 10.f); @@ -3010,7 +3010,7 @@ static int vertex_group_fix_exec(bContext *C, wmOperator *op) { Object *ob = CTX_data_active_object(C); Scene *scene = CTX_data_scene(C); - + float distToBe = RNA_float_get(op->ptr, "dist"); float strength = RNA_float_get(op->ptr, "strength"); float cp = RNA_float_get(op->ptr, "accuracy"); @@ -3022,17 +3022,17 @@ static int vertex_group_fix_exec(bContext *C, wmOperator *op) } md = md->next; } - + if (md && md->type == eModifierType_Mirror) { BKE_report(op->reports, RPT_ERROR_INVALID_CONTEXT, "This operator does not support an active mirror modifier"); return OPERATOR_CANCELLED; } vgroup_fix(scene, ob, distToBe, strength, cp); - + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); - + return OPERATOR_FINISHED; } @@ -3043,11 +3043,11 @@ void OBJECT_OT_vertex_group_fix(wmOperatorType *ot) ot->idname = "OBJECT_OT_vertex_group_fix"; ot->description = "Modify the position of selected vertices by changing only their respective " "groups' weights (this tool may be slow for many vertices)"; - + /* api callbacks */ ot->poll = vertex_group_mesh_poll; ot->exec = vertex_group_fix_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_float(ot->srna, "dist", 0.0f, -FLT_MAX, FLT_MAX, "Distance", "The distance to move to", -10.0f, 10.0f); @@ -3444,16 +3444,16 @@ static int set_active_group_exec(bContext *C, wmOperator *op) } static const EnumPropertyItem *vgroup_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) -{ +{ Object *ob = ED_object_context(C); EnumPropertyItem tmp = {0, "", 0, "", ""}; EnumPropertyItem *item = NULL; bDeformGroup *def; int a, totitem = 0; - + if (!ob) return DummyRNA_NULL_items; - + for (a = 0, def = ob->defbase.first; def; def = def->next, a++) { tmp.value = a; tmp.icon = ICON_GROUP_VERTEX; @@ -3578,7 +3578,7 @@ static int vgroup_do_remap(Object *ob, const char *name_array, wmOperator *op) BLI_assert(sort_map_update[ob->actdef] >= 0); ob->actdef = sort_map_update[ob->actdef]; - + MEM_freeN(sort_map_update); return OPERATOR_FINISHED; @@ -3646,7 +3646,7 @@ static int vertex_group_sort_exec(bContext *C, wmOperator *op) vgroup_sort_bone_hierarchy(ob, NULL); break; } - + /*remap vgroup data to map to correct names*/ ret = vgroup_do_remap(ob, name_array, op); |