From e65e6237a2a99df0c48670d704fee33145df7577 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Wed, 14 Dec 2005 15:58:52 +0000 Subject: [PATCH] Orange; Magical Group relink option. :) This is the case: - Empty has Group duplicator - Empty has NLA strips to animate the group On linking the Empty to another group (with button in ObjectButtons), it checks for the current strips in NLA, and tries to find the proper objects in the new Group, based on name matches. If not found, it sets the strip-objects to zero. --- source/blender/blenkernel/BKE_group.h | 1 + source/blender/blenkernel/intern/group.c | 29 ++++++++++++++++++++++++ source/blender/include/butspace.h | 2 ++ source/blender/src/buttons_object.c | 6 ++++- 4 files changed, 37 insertions(+), 1 deletion(-) 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");