diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-04-29 15:38:39 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-04-29 15:52:04 +0400 |
commit | 7544961ea5177b61b8f1f07e156cac28afe29764 (patch) | |
tree | 3a89976a66f7cc0bbd19b11a531f8b324a1e1be5 /source/blender/blenkernel/intern/object_dupli.c | |
parent | 182e97a2cd4bdca9709dbbd1a4e6c175aed448a6 (diff) |
Fix T39942: Displacement of group instance objects when switching to textured viewport shading
Usual dupli object issue, sometimes it's needed that all the object in
dupli group have modified obmat.
Made it an utility function now, which is used by convertblender and
dupli draw code now.
Diffstat (limited to 'source/blender/blenkernel/intern/object_dupli.c')
-rw-r--r-- | source/blender/blenkernel/intern/object_dupli.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c index d246a77c0f7..30e2cc253a4 100644 --- a/source/blender/blenkernel/intern/object_dupli.c +++ b/source/blender/blenkernel/intern/object_dupli.c @@ -1245,3 +1245,42 @@ int count_duplilist(Object *ob) } return 1; } + +DupliApplyData *duplilist_apply_matrix(ListBase *duplilist) +{ + DupliApplyData *apply_data = NULL; + int num_objects = BLI_countlist(duplilist); + if (num_objects > 0) { + DupliObject *dob; + int i; + apply_data = MEM_mallocN(sizeof(DupliApplyData), "DupliObject apply data"); + apply_data->num_objects = num_objects; + apply_data->extra = MEM_mallocN(sizeof(DupliExtraData) * (size_t) num_objects, + "DupliObject apply extra data"); + + for (dob = duplilist->first, i = 0; dob; dob = dob->next, ++i) { + copy_m4_m4(apply_data->extra[i].obmat, dob->ob->obmat); + copy_m4_m4(dob->ob->obmat, dob->mat); + } + } + return apply_data; +} + +void duplilist_restore_matrix(ListBase *duplilist, DupliApplyData *apply_data) +{ + DupliObject *dob; + int i; + /* Restore object matrices. + * NOTE: this has to happen in reverse order, since nested + * dupli objects can repeatedly override the obmat. + */ + for (dob = duplilist->last, i = apply_data->num_objects - 1; dob; dob = dob->prev, --i) { + copy_m4_m4(dob->ob->obmat, apply_data->extra[i].obmat); + } +} + +void duplilist_free_apply_data(DupliApplyData *apply_data) +{ + MEM_freeN(apply_data->extra); + MEM_freeN(apply_data); +} |