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.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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 && event<B_SELEFFECT+MAX_EFFECT) {
|
||||
@@ -1510,7 +1514,7 @@ static void object_panel_anim(Object *ob)
|
||||
uiDefButBitS(block, TOG, OB_DUPLINOSPEED, REDRAWVIEW3D, "No Speed", 234,130,82,20, &ob->transflag, 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");
|
||||
|
||||
Reference in New Issue
Block a user