diff --git a/source/blender/blenkernel/BKE_group.h b/source/blender/blenkernel/BKE_group.h index db4c83040a8..2a14c2f6ed5 100644 --- a/source/blender/blenkernel/BKE_group.h +++ b/source/blender/blenkernel/BKE_group.h @@ -51,6 +51,7 @@ int object_in_group(struct Object *ob, struct Group *group); void group_tag_recalc(struct Group *group); void group_handle_recalc_and_update(struct Object *parent, struct Group *group); struct Object *group_get_member_with_action(struct Group *group, struct bAction *act); +void group_relink_nla_objects(struct Object *ob); #endif diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index 5e2d0d6fc6d..130e285761a 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -289,3 +289,32 @@ Object *group_get_member_with_action(Group *group, bAction *act) } return NULL; } + +/* if group has NLA, we try to map the used objects in NLA to group members */ +/* this assuming that object has received a new group link */ +void group_relink_nla_objects(Object *ob) +{ + Group *group; + GroupObject *go; + bActionStrip *strip; + + if(ob==NULL || ob->dup_group==NULL) return; + group= ob->dup_group; + + for(strip= ob->nlastrips.first; strip; strip= strip->next) { + if(strip->object) { + for(go= group->gobject.first; go; go= go->next) { + if(go->ob) { + if(strcmp(go->ob->id.name, strip->object->id.name)==0) + break; + } + } + if(go) + strip->object= go->ob; + else + strip->object= NULL; + } + + } +} + diff --git a/source/blender/include/butspace.h b/source/blender/include/butspace.h index 8e72198da52..713f9abf488 100644 --- a/source/blender/include/butspace.h +++ b/source/blender/include/butspace.h @@ -248,6 +248,8 @@ void test_idbutton_cb(void *namev, void *arg2_unused); #define B_FLUIDSIM_SELDIR 1451 #define B_FLUIDSIM_FORCEREDRAW 1452 +#define B_GROUP_RELINK 1460 + /* *********************** */ #define B_WORLDBUTS 1600 diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index ff980a91f89..67bdbf602c1 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -1340,6 +1340,10 @@ void do_object_panels(unsigned short event) allqueue(REDRAWVIEW3D, 0); DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); break; + case B_GROUP_RELINK: + group_relink_nla_objects(OBACT); + allqueue(REDRAWVIEW3D, 0); + break; default: if(event>=B_SELEFFECT && eventtransflag, 0, 0, 0, 0, "Set dupliframes to still, regardless of frame"); uiDefButBitS(block, TOG, OB_DUPLIGROUP, REDRAWVIEW3D, "DupliGroup", 24,110,150,20, &ob->transflag, 0, 0, 0, 0, "Make copy of object for every frame"); - uiDefIDPoinBut(block, test_grouppoin_but, ID_GR, REDRAWVIEW3D, "GR:", 174,110,142,20, &ob->dup_group, "Duplicate this entire Group"); + uiDefIDPoinBut(block, test_grouppoin_but, ID_GR, B_GROUP_RELINK, "GR:", 174,110,142,20, &ob->dup_group, "Duplicate this entire Group"); uiBlockBeginAlign(block); uiDefButS(block, NUM, REDRAWVIEW3D, "DupSta:", 24,85,141,19, &ob->dupsta, 1.0, (MAXFRAMEF - 1.0f), 0, 0, "Specify startframe for Dupliframes");