group instance still didnt work in some cases, now tag ID flag when linking as well as appending so its easy to know if an ID is newly added or not.

This commit is contained in:
Campbell Barton
2010-01-07 16:19:38 +00:00
parent 0983aae019
commit bce42d6b5e
4 changed files with 18 additions and 17 deletions

View File

@@ -1274,13 +1274,13 @@ void all_local(Library *lib, int untagged_only)
id->newid= NULL;
idn= id->next; /* id is possibly being inserted again */
/* The check on the second line (LIB_APPEND_TAG) is done so its
/* The check on the second line (LIB_PRE_EXISTING) is done so its
* possible to tag data you dont want to be made local, used for
* appending data, so any libdata alredy linked wont become local
* (very nasty to discover all your links are lost after appending)
* */
if(id->flag & (LIB_EXTERN|LIB_INDIRECT|LIB_NEW) &&
(untagged_only==0 || !(id->flag & LIB_APPEND_TAG)))
(untagged_only==0 || !(id->flag & LIB_PRE_EXISTING)))
{
if(lib==NULL || id->lib==lib) {
id->flag &= ~(LIB_EXTERN|LIB_INDIRECT|LIB_NEW);

View File

@@ -11591,8 +11591,8 @@ static void give_base_to_objects(Main *mainvar, Scene *sce, Library *lib, int is
if we are appending, but this object wasnt just added allong with a group,
then this is alredy used indirectly in the scene somewhere else and we didnt just append it.
(ob->id.flag & LIB_APPEND_TAG)==0 means that this is a newly appended object - Campbell */
if (is_group_append==0 || (ob->id.flag & LIB_APPEND_TAG)==0) {
(ob->id.flag & LIB_PRE_EXISTING)==0 means that this is a newly appended object - Campbell */
if (is_group_append==0 || (ob->id.flag & LIB_PRE_EXISTING)==0) {
int do_it= 0;
@@ -11619,15 +11619,13 @@ static void give_base_to_objects(Main *mainvar, Scene *sce, Library *lib, int is
}
/* when *lib set, it also does objects that were in the appended group */
static void give_base_to_groups(Main *mainvar, Scene *scene, Library *lib, int flag)
static void give_base_to_groups(Main *mainvar, Scene *scene)
{
Group *group;
/* give all objects which are LIB_INDIRECT a base, or for a group when *lib has been set */
for(group= mainvar->group.first; group; group= group->id.next) {
if( ((flag & FILE_LINK) && (group->id.lib == lib) && (group->id.flag & LIB_INDIRECT)==0) || /* linking, directly */
((flag & FILE_LINK)==0 && (group->id.flag & LIB_APPEND_TAG)==0) /* appending */
) {
if(((group->id.flag & LIB_INDIRECT)==0 && (group->id.flag & LIB_PRE_EXISTING)==0)) {
Base *base;
/* add_object(...) messes with the selection */
@@ -11854,7 +11852,7 @@ static void library_append_end(const bContext *C, Main *mainl, FileData **fd, in
}
if (flag & FILE_GROUP_INSTANCE) {
give_base_to_groups(mainvar, scene, mainl->curlib, flag);
give_base_to_groups(mainvar, scene);
}
} else {
give_base_to_objects(mainvar, scene, NULL, 0);

View File

@@ -212,8 +212,8 @@ typedef struct PreviewImage {
#define LIB_FAKEUSER 512
/* free test flag */
#define LIB_DOIT 1024
/* */
#define LIB_APPEND_TAG 2048
/* tag existing data before linking so we know what is new */
#define LIB_PRE_EXISTING 2048
#ifdef __cplusplus
}

View File

@@ -1240,9 +1240,6 @@ static void wm_link_make_library_local(Main *main, const char *libname)
/* make local */
if(lib) {
all_local(lib, 1);
/* important we unset, otherwise these object wont
* link into other scenes from this blend file */
flag_all_listbases_ids(LIB_APPEND_TAG, 0);
}
}
@@ -1300,9 +1297,11 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
flag = wm_link_append_flag(op);
/* tag everything, all untagged data can be made local */
if((flag & FILE_LINK)==0)
flag_all_listbases_ids(LIB_APPEND_TAG, 1);
/* tag everything, all untagged data can be made local
* its also generally useful to know what is new
*
* take extra care flag_all_listbases_ids(LIB_LINK_TAG, 0) is called after! */
flag_all_listbases_ids(LIB_PRE_EXISTING, 1);
/* here appending/linking starts */
mainl = BLO_library_append_begin(C, &bh, libname);
@@ -1325,6 +1324,10 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
if((flag & FILE_LINK)==0)
wm_link_make_library_local(bmain, libname);
/* important we unset, otherwise these object wont
* link into other scenes from this blend file */
flag_all_listbases_ids(LIB_PRE_EXISTING, 0);
/* recreate dependency graph to include new objects */
DAG_scene_sort(scene);
DAG_ids_flush_update(0);