diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-12-19 14:39:40 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-12-19 14:39:40 +0400 |
commit | 737648a0bf6aa38707adf0d444902cab981f86cf (patch) | |
tree | 9911809833f690eec95ef9e259729d29160d7a02 /source/blender/editors/object | |
parent | 5d15d8d2eebc98d7122e811dae2979b9a6c38b9d (diff) | |
parent | 90ef435145416313596cafa6f8c4c6c6aebe4e44 (diff) |
Merging r42648 through r42722 from trunk into soc-2011-tomato
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r-- | source/blender/editors/object/object_add.c | 37 | ||||
-rw-r--r-- | source/blender/editors/object/object_constraint.c | 2 | ||||
-rw-r--r-- | source/blender/editors/object/object_hook.c | 2 | ||||
-rw-r--r-- | source/blender/editors/object/object_relations.c | 16 | ||||
-rw-r--r-- | source/blender/editors/object/object_vgroup.c | 6 |
5 files changed, 37 insertions, 26 deletions
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 8c60a4d5868..1547c5daf54 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -47,9 +47,10 @@ #include "DNA_speaker_types.h" #include "DNA_vfont_types.h" +#include "BLI_ghash.h" +#include "BLI_listbase.h" #include "BLI_math.h" #include "BLI_string.h" -#include "BLI_listbase.h" #include "BLI_utildefines.h" #include "BKE_anim.h" @@ -1050,11 +1051,17 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, { ListBase *lb; DupliObject *dob; - + GHash *dupli_gh= NULL, *parent_gh= NULL; + if(!(base->object->transflag & OB_DUPLI)) return; lb= object_duplilist(scene, base->object); + + if(use_hierarchy || use_base_parent) { + dupli_gh= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "make_object_duplilist_real dupli_gh"); + parent_gh= BLI_ghash_new(BLI_ghashutil_pairhash, BLI_ghashutil_paircmp, "make_object_duplilist_real parent_gh"); + } for(dob= lb->first; dob; dob= dob->next) { Base *basen; @@ -1083,6 +1090,11 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, copy_m4_m4(ob->obmat, dob->mat); object_apply_mat4(ob, ob->obmat, FALSE, FALSE); + + if(dupli_gh) + BLI_ghash_insert(dupli_gh, dob, ob); + if(parent_gh) + BLI_ghash_insert(parent_gh, BLI_ghashutil_pairalloc(dob->ob, dob->index), ob); } if (use_hierarchy) { @@ -1091,12 +1103,17 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, Object *ob_src= dob->ob; Object *ob_src_par= ob_src->parent; - Object *ob_dst= (Object *)ob_src->id.newid; + Object *ob_dst= BLI_ghash_lookup(dupli_gh, dob); + Object *ob_dst_par= NULL; - 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; + /* find parent that was also made real */ + if(ob_src_par) { + GHashPair *pair = BLI_ghashutil_pairalloc(ob_src_par, dob->index); + ob_dst_par = BLI_ghash_lookup(parent_gh, pair); + BLI_ghashutil_pairfree(pair); + } + if (ob_dst_par) { /* allow for all possible parent types */ ob_dst->partype= ob_src->partype; BLI_strncpy(ob_dst->parsubstr, ob_src->parsubstr, sizeof(ob_dst->parsubstr)); @@ -1130,8 +1147,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, * 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; + Object *ob_dst= BLI_ghash_lookup(dupli_gh, dob); ob_dst->parent= base->object; ob_dst->partype= PAROBJECT; @@ -1145,6 +1161,11 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, } } + if(dupli_gh) + BLI_ghash_free(dupli_gh, NULL, NULL); + if(parent_gh) + BLI_ghash_free(parent_gh, BLI_ghashutil_pairfree, NULL); + copy_object_set_idnew(C, 0); free_object_duplilist(lb); diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index fa4f50e240f..8266f3501c5 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -754,7 +754,7 @@ static void child_get_inverse_matrix (Scene *scene, Object *ob, bConstraint *con * the effect of the constraint */ invert_m4_m4(imat, pchan->pose_mat); - mul_m4_m4m4(tmat, imat, pmat); + mult_m4_m4m4(tmat, pmat, imat); invert_m4_m4(invmat, tmat); /* 5. restore constraints */ diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 773974d0cc0..7bb91c1fc4b 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -646,7 +646,7 @@ static int object_hook_reset_exec(bContext *C, wmOperator *op) float imat[4][4], mat[4][4]; /* calculate the world-space matrix for the pose-channel target first, then carry on as usual */ - mul_m4_m4m4(mat, pchan->pose_mat, hmd->object->obmat); + mult_m4_m4m4(mat, hmd->object->obmat, pchan->pose_mat); invert_m4_m4(imat, mat); mul_serie_m4(hmd->parentinv, imat, ob->obmat, NULL, NULL, NULL, NULL, NULL, NULL); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 6b517b6eeb0..1ba0157e8d3 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -512,19 +512,9 @@ static EnumPropertyItem prop_make_parent_types[] = { {0, NULL, 0, NULL, NULL} }; -static int test_parent_loop(Object *par, Object *ob) -{ - /* test if 'ob' is a parent somewhere in par's parents */ - - if(par == NULL) return 0; - if(ob == par) return 1; - - return test_parent_loop(par->parent, ob); -} - void ED_object_parent(Object *ob, Object *par, int type, const char *substr) { - if(!par || test_parent_loop(par, ob)) { + if (!par || BKE_object_parent_loop_check(par, ob)) { ob->parent= NULL; ob->partype= PAROBJECT; ob->parsubstr[0]= 0; @@ -593,7 +583,7 @@ static int parent_set_exec(bContext *C, wmOperator *op) if(ob!=par) { - if( test_parent_loop(par, ob) ) { + if (BKE_object_parent_loop_check(par, ob)) { BKE_report(op->reports, RPT_ERROR, "Loop in parents"); } else { @@ -766,7 +756,7 @@ static int parent_noinv_set_exec(bContext *C, wmOperator *op) /* context iterator */ CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { if (ob != par) { - if (test_parent_loop(par, ob)) { + if (BKE_object_parent_loop_check(par, ob)) { BKE_report(op->reports, RPT_ERROR, "Loop in parents"); } else { diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 50fe9d26cf9..bfb5d166e6f 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -892,7 +892,7 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in int totweight = dvert->totweight; float oldw = 0; float oldPos[3] = {0}; - float vc, hc, dist; + float vc, hc, dist = 0.0f; int i, k; float (*changes)[2] = MEM_mallocN(sizeof(float *)*totweight*2, "vertHorzChange"); float *dists = MEM_mallocN(sizeof(float)*totweight, "distance"); @@ -2599,8 +2599,8 @@ static int set_active_group_exec(bContext *C, wmOperator *op) Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; int nr= RNA_enum_get(op->ptr, "group"); + BLI_assert(nr+1 >= 0); ob->actdef= nr+1; - BLI_assert(ob->actdef >= 0); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob); @@ -2733,8 +2733,8 @@ static int vgroup_do_remap(Object *ob, char *name_array, wmOperator *op) sort_map_update[0]= 0; vgroup_remap_update_users(ob, sort_map_update); + BLI_assert(sort_map_update[ob->actdef] >= 0); ob->actdef= sort_map_update[ob->actdef]; - BLI_assert(ob->actdef >= 0); MEM_freeN(sort_map_update); |