Commit: 3c634400a0c28ad975f5207125cb7e8e67a9e661
Author: Bastien Montagne
Date:   Sat Dec 13 15:14:04 2014 +0100
Branches: asset-experiments
https://developer.blender.org/rB3c634400a0c28ad975f5207125cb7e8e67a9e661

Add preview pointers to Object and Group, with read/write logic.

Doing nothing useful yet, though!

Note: ultimately we may want to move that preview stuff to ID struct,
so that we get a real basic generic handling of it, but for now
simpler to keep it as is.

===================================================================

M       source/blender/blenloader/intern/readblenentry.c
M       source/blender/blenloader/intern/readfile.c
M       source/blender/blenloader/intern/writefile.c
M       source/blender/makesdna/DNA_group_types.h
M       source/blender/makesdna/DNA_object_types.h

===================================================================

diff --git a/source/blender/blenloader/intern/readblenentry.c 
b/source/blender/blenloader/intern/readblenentry.c
index 9544015..97dd2ca 100644
--- a/source/blender/blenloader/intern/readblenentry.c
+++ b/source/blender/blenloader/intern/readblenentry.c
@@ -161,6 +161,8 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int 
ofblocktype, int *to
                                case ID_IM: /* fall through */
                                case ID_WO: /* fall through */
                                case ID_LA: /* fall through */
+                               case ID_OB: /* fall through */
+                               case ID_GR: /* fall through */
                                        new_prv = 
MEM_callocN(sizeof(PreviewImage), "newpreview");
                                        BLI_linklist_prepend(&previews, 
new_prv);
                                        tot++;
diff --git a/source/blender/blenloader/intern/readfile.c 
b/source/blender/blenloader/intern/readfile.c
index 14e61ae..751fe55 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -5139,6 +5139,8 @@ static void direct_link_object(FileData *fd, Object *ob)
 
        link_list(fd, &ob->lodlevels);
        ob->currentlod = ob->lodlevels.first;
+
+       ob->preview = direct_link_preview_image(fd, ob->preview);
 }
 
 /* ************ READ SCENE ***************** */
@@ -6890,6 +6892,8 @@ static void lib_link_sound(FileData *fd, Main *main)
 static void direct_link_group(FileData *fd, Group *group)
 {
        link_list(fd, &group->gobject);
+
+       group->preview = direct_link_preview_image(fd, group->preview);
 }
 
 static void lib_link_group(FileData *fd, Main *main)
diff --git a/source/blender/blenloader/intern/writefile.c 
b/source/blender/blenloader/intern/writefile.c
index 3dc1fed..dbea42e 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -588,6 +588,31 @@ void IDP_WriteProperty(IDProperty *prop, void *wd)
        IDP_WriteProperty_OnlyData(prop, wd);
 }
 
+static void write_previews(WriteData *wd, PreviewImage *prv)
+{
+       if (prv) {
+               short w = prv->w[1];
+               short h = prv->h[1];
+               unsigned int *rect = prv->rect[1];
+               /* don't write out large previews if not requested */
+               if (!(U.flag & USER_SAVE_PREVIEWS)) {
+                       prv->w[1] = 0;
+                       prv->h[1] = 0;
+                       prv->rect[1] = NULL;
+               }
+               writestruct(wd, DATA, "PreviewImage", 1, prv);
+               if (prv->rect[0]) writedata(wd, DATA, 
prv->w[0]*prv->h[0]*sizeof(unsigned int), prv->rect[0]);
+               if (prv->rect[1]) writedata(wd, DATA, 
prv->w[1]*prv->h[1]*sizeof(unsigned int), prv->rect[1]);
+
+               /* restore preview, we still want to keep it in memory even if 
not saved to file */
+               if (!(U.flag & USER_SAVE_PREVIEWS) ) {
+                       prv->w[1] = w;
+                       prv->h[1] = h;
+                       prv->rect[1] = rect;
+               }
+       }
+}
+
 static void write_fmodifiers(WriteData *wd, ListBase *fmodifiers)
 {
        FModifier *fcm;
@@ -1654,6 +1679,9 @@ static void write_objects(WriteData *wd, ListBase *idbase)
                        writelist(wd, DATA, "LinkData", &ob->pc_ids);
                        writelist(wd, DATA, "LodLevel", &ob->lodlevels);
                }
+
+               write_previews(wd, ob->preview);
+
                ob= ob->id.next;
        }
 
@@ -2055,31 +2083,6 @@ static void write_lattices(WriteData *wd, ListBase 
*idbase)
        }
 }
 
-static void write_previews(WriteData *wd, PreviewImage *prv)
-{
-       if (prv) {
-               short w = prv->w[1];
-               short h = prv->h[1];
-               unsigned int *rect = prv->rect[1];
-               /* don't write out large previews if not requested */
-               if (!(U.flag & USER_SAVE_PREVIEWS)) {
-                       prv->w[1] = 0;
-                       prv->h[1] = 0;
-                       prv->rect[1] = NULL;
-               }
-               writestruct(wd, DATA, "PreviewImage", 1, prv);
-               if (prv->rect[0]) writedata(wd, DATA, 
prv->w[0]*prv->h[0]*sizeof(unsigned int), prv->rect[0]);
-               if (prv->rect[1]) writedata(wd, DATA, 
prv->w[1]*prv->h[1]*sizeof(unsigned int), prv->rect[1]);
-
-               /* restore preview, we still want to keep it in memory even if 
not saved to file */
-               if (!(U.flag & USER_SAVE_PREVIEWS) ) {
-                       prv->w[1] = w;
-                       prv->h[1] = h;
-                       prv->rect[1] = rect;
-               }
-       }
-}
-
 static void write_images(WriteData *wd, ListBase *idbase)
 {
        Image *ima;
@@ -2933,6 +2936,8 @@ static void write_groups(WriteData *wd, ListBase *idbase)
                        writestruct(wd, ID_GR, "Group", 1, group);
                        if (group->id.properties) 
IDP_WriteProperty(group->id.properties, wd);
 
+                       write_previews(wd, group->preview);
+
                        go= group->gobject.first;
                        while (go) {
                                writestruct(wd, DATA, "GroupObject", 1, go);
diff --git a/source/blender/makesdna/DNA_group_types.h 
b/source/blender/makesdna/DNA_group_types.h
index 2740281..45dd0cb 100644
--- a/source/blender/makesdna/DNA_group_types.h
+++ b/source/blender/makesdna/DNA_group_types.h
@@ -52,7 +52,9 @@ typedef struct Group {
        ID id;
        
        ListBase gobject;       /* GroupObject */
-       
+
+       struct PreviewImage *preview;
+
        /* Bad design, since layers stored in the scenes 'Base'
         * the objects that show in the group can change depending
         * on the last used scene */
diff --git a/source/blender/makesdna/DNA_object_types.h 
b/source/blender/makesdna/DNA_object_types.h
index 0bcc6bf..b31a3c1 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -292,6 +292,8 @@ typedef struct Object {
 
        ListBase lodlevels;             /* contains data for levels of detail */
        LodLevel *currentlod;
+
+       struct PreviewImage *preview;
 } Object;
 
 /* Warning, this is not used anymore because hooks are now modifiers */

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to