diff options
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r-- | source/blender/editors/object/object_add.c | 89 | ||||
-rw-r--r-- | source/blender/editors/object/object_constraint.c | 20 | ||||
-rw-r--r-- | source/blender/editors/object/object_edit.c | 18 | ||||
-rw-r--r-- | source/blender/editors/object/object_lattice.c | 3 | ||||
-rw-r--r-- | source/blender/editors/object/object_modifier.c | 4 | ||||
-rw-r--r-- | source/blender/editors/object/object_relations.c | 4 | ||||
-rw-r--r-- | source/blender/editors/object/object_transform.c | 2 |
7 files changed, 115 insertions, 25 deletions
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 7ff233fa609..8d4d29dbe50 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -48,12 +48,14 @@ #include "DNA_vfont_types.h" #include "BLI_math.h" +#include "BLI_string.h" #include "BLI_listbase.h" #include "BLI_utildefines.h" #include "BKE_anim.h" #include "BKE_animsys.h" #include "BKE_armature.h" +#include "BKE_camera.h" #include "BKE_constraint.h" #include "BKE_context.h" #include "BKE_curve.h" @@ -62,6 +64,7 @@ #include "BKE_displist.h" #include "BKE_effect.h" #include "BKE_group.h" +#include "BKE_lamp.h" #include "BKE_lattice.h" #include "BKE_library.h" #include "BKE_key.h" @@ -1006,23 +1009,21 @@ static void copy_object_set_idnew(bContext *C, int dupflag) /********************* Make Duplicates Real ************************/ -static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base) +static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, + const short use_base_parent, + const short use_hierarchy) { - Base *basen; - Object *ob; ListBase *lb; DupliObject *dob; - - if(!base && !(base = BASACT)) - return; - + if(!(base->object->transflag & OB_DUPLI)) return; lb= object_duplilist(scene, base->object); for(dob= lb->first; dob; dob= dob->next) { - ob= copy_object(dob->ob); + Base *basen; + Object *ob= copy_object(dob->ob); /* font duplis can have a totcol without material, we get them from parent * should be implemented better... */ @@ -1049,22 +1050,85 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base) object_apply_mat4(ob, ob->obmat, FALSE, FALSE); } + if (use_hierarchy) { + for(dob= lb->first; dob; dob= dob->next) { + /* original parents */ + Object *ob_src= dob->ob; + Object *ob_src_par= ob_src->parent; + + Object *ob_dst= (Object *)ob_src->id.newid; + + if (ob_src_par && ob_src_par->id.newid) { + /* the parent was also made real, parent newly real duplis */ + Object *ob_dst_par= (Object *)ob_src_par->id.newid; + + /* allow for all possible parent types */ + ob_dst->partype= ob_src->partype; + BLI_strncpy(ob_dst->parsubstr, ob_src->parsubstr, sizeof(ob_dst->parsubstr)); + ob_dst->par1= ob_src->par1; + ob_dst->par2= ob_src->par2; + ob_dst->par3= ob_src->par3; + + copy_m4_m4(ob_dst->parentinv, ob_src->parentinv); + + ob_dst->parent= ob_dst_par; + } + else if (use_base_parent) { + ob_dst->parent= base->object; + ob_dst->partype= PAROBJECT; + } + + if (ob_dst->parent) { + invert_m4_m4(ob_dst->parentinv, dob->mat); + + /* note, this may be the parent of other objects, but it should + * still work out ok */ + object_apply_mat4(ob_dst, dob->mat, FALSE, TRUE); + + /* to set ob_dst->orig and incase theres any other discrepicies */ + DAG_id_tag_update(&ob_dst->id, OB_RECALC_OB); + } + } + } + else if (use_base_parent) { + /* since we are ignoring the internal hierarchy - parent all to the + * base object */ + for(dob= lb->first; dob; dob= dob->next) { + /* original parents */ + Object *ob_src= dob->ob; + Object *ob_dst= (Object *)ob_src->id.newid; + + ob_dst->parent= base->object; + ob_dst->partype= PAROBJECT; + + /* similer to the code above, see comments */ + invert_m4_m4(ob_dst->parentinv, dob->mat); + object_apply_mat4(ob_dst, dob->mat, FALSE, TRUE); + DAG_id_tag_update(&ob_dst->id, OB_RECALC_OB); + + + } + } + copy_object_set_idnew(C, 0); free_object_duplilist(lb); - base->object->transflag &= ~OB_DUPLI; + base->object->transflag &= ~OB_DUPLI; } -static int object_duplicates_make_real_exec(bContext *C, wmOperator *UNUSED(op)) +static int object_duplicates_make_real_exec(bContext *C, wmOperator *op) { Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); + + const short use_base_parent= RNA_boolean_get(op->ptr, "use_base_parent"); + const short use_hierarchy= RNA_boolean_get(op->ptr, "use_hierarchy"); clear_id_newpoins(); CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { - make_object_duplilist_real(C, scene, base); + make_object_duplilist_real(C, scene, base, use_base_parent, use_hierarchy); /* dependencies were changed */ WM_event_add_notifier(C, NC_OBJECT|ND_PARENT, base->object); @@ -1094,6 +1158,9 @@ void OBJECT_OT_duplicates_make_real(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + RNA_def_boolean(ot->srna, "use_base_parent", 0, "Parent", "Parent newly created objects to the original duplicator"); + RNA_def_boolean(ot->srna, "use_hierarchy", 0, "Keep Hierarchy", "Maintain parent child relationships"); } /**************************** Convert **************************/ diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 50b798c5bea..b36416151a9 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -55,6 +55,7 @@ #include "BKE_main.h" #include "BKE_object.h" #include "BKE_report.h" +#include "BKE_tracking.h" #include "BIK_api.h" #ifdef WITH_PYTHON @@ -402,6 +403,23 @@ static void test_constraints (Object *owner, bPoseChannel *pchan) data->flag &= ~CONSTRAINT_SPLINEIK_BOUND; } } + else if (curcon->type == CONSTRAINT_TYPE_FOLLOWTRACK) { + bFollowTrackConstraint *data = curcon->data; + + if((data->flag&CAMERASOLVER_ACTIVECLIP)==0) { + if(data->clip != NULL && data->track[0]) { + if (!BKE_tracking_named_track(&data->clip->tracking, data->track)) + curcon->flag |= CONSTRAINT_DISABLE; + } + else curcon->flag |= CONSTRAINT_DISABLE; + } + } + else if (curcon->type == CONSTRAINT_TYPE_CAMERASOLVER) { + bCameraSolverConstraint *data = curcon->data; + + if((data->flag&CAMERASOLVER_ACTIVECLIP)==0 && data->clip == NULL) + curcon->flag |= CONSTRAINT_DISABLE; + } /* Check targets for constraints */ if (cti && cti->get_constraint_targets) { @@ -1368,7 +1386,9 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase BPY_pyconstraint_update(ob, con); } #endif + break; } + default: break; } diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index f2997dc743d..4fbb5e0d51c 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1130,19 +1130,19 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) base->object->recalc |= OB_RECALC_OB; if(event==1) { /* loc */ - VECCOPY(base->object->loc, ob->loc); - VECCOPY(base->object->dloc, ob->dloc); + copy_v3_v3(base->object->loc, ob->loc); + copy_v3_v3(base->object->dloc, ob->dloc); } else if(event==2) { /* rot */ - VECCOPY(base->object->rot, ob->rot); - VECCOPY(base->object->drot, ob->drot); + copy_v3_v3(base->object->rot, ob->rot); + copy_v3_v3(base->object->drot, ob->drot); - QUATCOPY(base->object->quat, ob->quat); - QUATCOPY(base->object->dquat, ob->dquat); + copy_qt_qt(base->object->quat, ob->quat); + copy_qt_qt(base->object->dquat, ob->dquat); } else if(event==3) { /* size */ - VECCOPY(base->object->size, ob->size); - VECCOPY(base->object->dsize, ob->dsize); + copy_v3_v3(base->object->size, ob->size); + copy_v3_v3(base->object->dsize, ob->dsize); } else if(event==4) { /* drawtype */ base->object->dt= ob->dt; @@ -1331,7 +1331,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) base->object->index= ob->index; } else if(event==31) { /* object color */ - QUATCOPY(base->object->col, ob->col); + copy_v4_v4(base->object->col, ob->col); } } } diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c index 25c1e32f4ae..cac167ad84f 100644 --- a/source/blender/editors/object/object_lattice.c +++ b/source/blender/editors/object/object_lattice.c @@ -35,6 +35,7 @@ #include "MEM_guardedalloc.h" #include "BLI_listbase.h" +#include "BLI_math.h" #include "BLI_utildefines.h" #include "DNA_curve_types.h" @@ -132,7 +133,7 @@ void load_editLatt(Object *obedit) bp= editlt->def; while(tot--) { - VECCOPY(fp, bp->vec); + copy_v3_v3(fp, bp->vec); fp+= 3; bp++; } diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 129d9df86a5..ad2280baba2 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -357,7 +357,7 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene * key= cache[a]; kmax= key->steps; for(k=0; k<=kmax; k++,key++,cvert++,mvert++) { - VECCOPY(mvert->co,key->co); + copy_v3_v3(mvert->co,key->co); if(k) { medge->v1= cvert-1; medge->v2= cvert; @@ -376,7 +376,7 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene * key=cache[a]; kmax=key->steps; for(k=0; k<=kmax; k++,key++,cvert++,mvert++) { - VECCOPY(mvert->co,key->co); + copy_v3_v3(mvert->co,key->co); if(k) { medge->v1=cvert-1; medge->v2=cvert; diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 74da705965a..94e2f0aae00 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -56,6 +56,7 @@ #include "BKE_action.h" #include "BKE_animsys.h" #include "BKE_armature.h" +#include "BKE_camera.h" #include "BKE_context.h" #include "BKE_constraint.h" #include "BKE_curve.h" @@ -63,6 +64,7 @@ #include "BKE_displist.h" #include "BKE_global.h" #include "BKE_fcurve.h" +#include "BKE_lamp.h" #include "BKE_lattice.h" #include "BKE_library.h" #include "BKE_main.h" @@ -653,7 +655,7 @@ static int parent_set_exec(bContext *C, wmOperator *op) data = con->data; data->tar = par; - get_constraint_target_matrix(scene, con, 0, CONSTRAINT_OBTYPE_OBJECT, NULL, cmat, scene->r.cfra - give_timeoffset(ob)); + get_constraint_target_matrix(scene, con, 0, CONSTRAINT_OBTYPE_OBJECT, NULL, cmat, scene->r.cfra); sub_v3_v3v3(vec, ob->obmat[3], cmat[3]); ob->loc[0] = vec[0]; diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index a82ed95079f..e2039739be2 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -133,7 +133,7 @@ static void object_clear_rot(Object *ob) float eul[3], oldeul[3], quat1[4] = {0}; if (ob->rotmode == ROT_MODE_QUAT) { - QUATCOPY(quat1, ob->quat); + copy_qt_qt(quat1, ob->quat); quat_to_eul(oldeul, ob->quat); } else if (ob->rotmode == ROT_MODE_AXISANGLE) { |