Revision: 14922
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14922
Author:   campbellbarton
Date:     2008-05-22 15:32:51 +0200 (Thu, 22 May 2008)

Log Message:
-----------
experemental ID versioning to know what data has changed to avoid re-exporting 
entire levels. (with py api)
also scriptlinks for lamps and material updates.

Modified Paths:
--------------
    branches/apricot/release/scripts/animation_proto.py
    branches/apricot/source/blender/blenkernel/BKE_library.h
    branches/apricot/source/blender/blenkernel/intern/library.c
    branches/apricot/source/blender/blenkernel/intern/object.c
    branches/apricot/source/blender/makesdna/DNA_ID.h
    branches/apricot/source/blender/python/api2_2x/gen_library.c
    branches/apricot/source/blender/python/api2_2x/gen_library.h
    branches/apricot/source/blender/src/buttons_shading.c

Modified: branches/apricot/release/scripts/animation_proto.py
===================================================================
--- branches/apricot/release/scripts/animation_proto.py 2008-05-22 09:29:42 UTC 
(rev 14921)
+++ branches/apricot/release/scripts/animation_proto.py 2008-05-22 13:32:51 UTC 
(rev 14922)
@@ -190,6 +190,8 @@
                
        def SET_ACTIVE(km):
                blend = 0
+               ok = False
+               
                for s,a in strips:
                        if a.name == km[KMNAME]:
                                ok = True
@@ -385,9 +387,8 @@
        if not ob:
                print 'No Active Object'
                return
-
+       
        animloop(sce, rend, ob)
-               
        
        rend.cFrame = back_cfra
        rend.sFrame = back_sfra

Modified: branches/apricot/source/blender/blenkernel/BKE_library.h
===================================================================
--- branches/apricot/source/blender/blenkernel/BKE_library.h    2008-05-22 
09:29:42 UTC (rev 14921)
+++ branches/apricot/source/blender/blenkernel/BKE_library.h    2008-05-22 
13:32:51 UTC (rev 14922)
@@ -70,5 +70,8 @@
 void flag_listbase_ids(ListBase *lb, short flag, short value);
 void flag_all_listbases_ids(short flag, short value);
 
+/* APRICOT HACK */
+void id_version_bump(struct ID *id);
+/* END APRICOT HACK */
 #endif
 

Modified: branches/apricot/source/blender/blenkernel/intern/library.c
===================================================================
--- branches/apricot/source/blender/blenkernel/intern/library.c 2008-05-22 
09:29:42 UTC (rev 14921)
+++ branches/apricot/source/blender/blenkernel/intern/library.c 2008-05-22 
13:32:51 UTC (rev 14922)
@@ -1105,3 +1105,11 @@
        new_id(lb, id, name);                           
 }
 
+/* APRICOT HACK */
+void id_version_bump(ID *id)
+{
+       id->version++;
+       /*printf("VER %d %s\n", id->version, id->name);*/
+}
+/* END APRICOT HACK */
+

Modified: branches/apricot/source/blender/blenkernel/intern/object.c
===================================================================
--- branches/apricot/source/blender/blenkernel/intern/object.c  2008-05-22 
09:29:42 UTC (rev 14921)
+++ branches/apricot/source/blender/blenkernel/intern/object.c  2008-05-22 
13:32:51 UTC (rev 14922)
@@ -2235,6 +2235,8 @@
                        else
                                where_is_object(ob);
                        if (G.f & G_DOSCRIPTLINKS) BPY_do_pyscript((ID *)ob, 
SCRIPT_OBJECTUPDATE);
+                       
+                       id_version_bump((ID *)ob);
                }
                
                if(ob->recalc & OB_RECALC_DATA) {
@@ -2311,6 +2313,7 @@
                                }
                        }
                        if (G.f & G_DOSCRIPTLINKS) BPY_do_pyscript((ID *)ob, 
SCRIPT_OBDATAUPDATE);
+                       if (ob->data) id_version_bump((ID *)ob->data);
                }
 
                /* the no-group proxy case, we call update */

Modified: branches/apricot/source/blender/makesdna/DNA_ID.h
===================================================================
--- branches/apricot/source/blender/makesdna/DNA_ID.h   2008-05-22 09:29:42 UTC 
(rev 14921)
+++ branches/apricot/source/blender/makesdna/DNA_ID.h   2008-05-22 13:32:51 UTC 
(rev 14922)
@@ -101,6 +101,8 @@
        short flag;
        int icon_id;
        IDProperty *properties;
+       int version; /* if data changes, bump this APRICOT HACK */
+       char pad0[4];
 } ID;
 
 /**

Modified: branches/apricot/source/blender/python/api2_2x/gen_library.c
===================================================================
--- branches/apricot/source/blender/python/api2_2x/gen_library.c        
2008-05-22 09:29:42 UTC (rev 14921)
+++ branches/apricot/source/blender/python/api2_2x/gen_library.c        
2008-05-22 13:32:51 UTC (rev 14922)
@@ -140,6 +140,30 @@
        return PyInt_FromLong(id->us);
 }
 
+/* APRICOT HACK */
+PyObject *GenericLib_getVersion( void *self )
+{      
+       ID *id = ((BPy_GenericLib *)self)->id;
+       if (!id) return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, "data has 
been removed" ) );
+       return PyLong_FromLong(id->version);
+}
+int GenericLib_setVersion( void *self, PyObject *value )
+{
+
+       long param;
+       ID *id = ((BPy_GenericLib *)self)->id;
+       if (!id) return ( EXPP_ReturnIntError( PyExc_RuntimeError, "data has 
been removed" ) );
+       
+       param = PyLong_AsLong( value );
+       if( PyErr_Occurred() )
+               return EXPP_ReturnIntError( PyExc_TypeError,
+                               "could not set the ID version, value not a 
number of too large" );
+       
+       id->version = param;
+       return 0;
+}
+/* END APRICOT HACK */
+
 PyObject *GenericLib_getProperties( void *self )
 {      
        ID *id = ((BPy_GenericLib *)self)->id;

Modified: branches/apricot/source/blender/python/api2_2x/gen_library.h
===================================================================
--- branches/apricot/source/blender/python/api2_2x/gen_library.h        
2008-05-22 09:29:42 UTC (rev 14921)
+++ branches/apricot/source/blender/python/api2_2x/gen_library.h        
2008-05-22 13:32:51 UTC (rev 14922)
@@ -60,6 +60,10 @@
        {"tag",\
         (getter)GenericLib_getTag, (setter)GenericLib_setTag,\
         "temporary tag",\
+        NULL},\
+       {"version",\
+        (getter)GenericLib_getVersion, (setter)GenericLib_setVersion,\
+        "temporary tag",\
         NULL}
 
 /* Dummy struct for getting the ID from a libdata BPyObject */
@@ -78,6 +82,11 @@
 PyObject *GenericLib_getUsers( void *self );
 PyObject *GenericLib_getProperties( void *self );
 
+/* APRICOT HACK */
+PyObject *GenericLib_getVersion( void *self );
+int GenericLib_setVersion( void *self, PyObject *value );
+/* END APRICOT HACK */
+
 /* use this for oldstyle somedata.getName("name") */
 PyObject * GenericLib_setName_with_method( void *self, PyObject *value ); 
 

Modified: branches/apricot/source/blender/src/buttons_shading.c
===================================================================
--- branches/apricot/source/blender/src/buttons_shading.c       2008-05-22 
09:29:42 UTC (rev 14921)
+++ branches/apricot/source/blender/src/buttons_shading.c       2008-05-22 
13:32:51 UTC (rev 14922)
@@ -115,6 +115,10 @@
 
 #include "GPU_material.h"
 
+
+/* APRICOT HACK */
+extern void BPY_do_pyscript( ID * id, short event );
+
 /* -----includes for this file specific----- */
 
 #include "butspace.h" // own module
@@ -3037,12 +3041,23 @@
                // BIF_previewdraw();  push/pop!
                break;
        case B_MATPRV:
-               if(ma) end_render_material(ma); /// temporal... 3d preview
+               if(ma) {
+                       end_render_material(ma); /// temporal... 3d preview
+                       
+                       /* APRICOT HACK */
+                       id_version_bump((ID *)ma);
+                       BPY_do_pyscript((ID *)ma, SCRIPT_OBDATAUPDATE);
+               }
                BIF_preview_changed(ID_MA);
                allqueue(REDRAWBUTSSHADING, 0);
                shade_buttons_change_3d();
                break;
        case B_LAMPPRV:
+               if (OBACT && OBACT->type==OB_LAMP) {
+                       /* APRICOT HACK */
+                       id_version_bump((ID *)OBACT->data);
+                       BPY_do_pyscript((ID *)OBACT, SCRIPT_OBDATAUPDATE);
+               }
                BIF_preview_changed(ID_LA);
                allqueue(REDRAWBUTSSHADING, 0);
                shade_buttons_change_3d();
@@ -3069,6 +3084,12 @@
                }
                break;
        case B_TEXCLEAR:
+               /* APRICOT HACK */
+               if(ma) {                        
+                       id_version_bump((ID *)ma);
+                       BPY_do_pyscript((ID *)ma, SCRIPT_OBDATAUPDATE);
+               }
+       
                mtex= ma->mtex[(int) ma->texact ];
                if(mtex) {
                        if(mtex->tex) mtex->tex->id.us--;
@@ -3082,6 +3103,11 @@
                }
                break;
        case B_MTEXCOPY:
+               /* APRICOT HACK */
+               if(ma) {                        
+                       id_version_bump((ID *)ma);
+                       BPY_do_pyscript((ID *)ma, SCRIPT_OBDATAUPDATE);
+               }
                if(ma && ma->mtex[(int)ma->texact] ) {
                        mtex= ma->mtex[(int)ma->texact];
                        if(mtex->tex==NULL) {
@@ -3094,6 +3120,11 @@
                }
                break;
        case B_MTEXPASTE:
+               /* APRICOT HACK */
+               if(ma) {                        
+                       id_version_bump((ID *)ma);
+                       BPY_do_pyscript((ID *)ma, SCRIPT_OBDATAUPDATE);
+               }
                if(ma && mtexcopied && mtexcopybuf.tex) {
                        if(ma->mtex[(int)ma->texact]==NULL ) 
                                ma->mtex[(int)ma->texact]= 
MEM_mallocN(sizeof(MTex), "mtex"); 
@@ -3109,6 +3140,11 @@
                }
                break;
        case B_MTEXMOVEUP:
+               /* APRICOT HACK */
+               if(ma) {                        
+                       id_version_bump((ID *)ma);
+                       BPY_do_pyscript((ID *)ma, SCRIPT_OBDATAUPDATE);
+               }
                if(ma && (int)ma->texact > 0) {
                        int mtexuse = ma->septex & (1<<((int)ma->texact));
                        ma->septex &= ~(1<<((int)ma->texact));
@@ -3123,6 +3159,11 @@
                }
                break;
        case B_MTEXMOVEDOWN:
+               /* APRICOT HACK */
+               if(ma) {                        
+                       id_version_bump((ID *)ma);
+                       BPY_do_pyscript((ID *)ma, SCRIPT_OBDATAUPDATE);
+               }
                if(ma && (int)ma->texact < MAX_MTEX-1) {
                        int mtexuse = ma->septex & (1<<((int)ma->texact));
                        ma->septex &= ~(1<<((int)ma->texact));
@@ -3137,6 +3178,11 @@
                }
                break;
        case B_MATZTRANSP:
+               /* APRICOT HACK */
+               if(ma) {                        
+                       id_version_bump((ID *)ma);
+                       BPY_do_pyscript((ID *)ma, SCRIPT_OBDATAUPDATE);
+               }
                if(ma) {
                        ma->mode &= ~MA_RAYTRANSP;
                        //BIF_view3d_previewrender_signal(curarea, 
PR_DBASE|PR_DISPRECT);       /// temporal... 3d preview
@@ -3145,6 +3191,11 @@
                }
                break;
        case B_MATRAYTRANSP:
+               /* APRICOT HACK */
+               if(ma) {                        
+                       id_version_bump((ID *)ma);
+                       BPY_do_pyscript((ID *)ma, SCRIPT_OBDATAUPDATE);
+               }
                if(ma) {
                        ma->mode &= ~MA_ZTRA;
                        if(ma) end_render_material(ma); /// temporal... 3d 
preview
@@ -3153,6 +3204,11 @@
                }
                break;
        case B_MATCOLORBAND:
+               /* APRICOT HACK */
+               if(ma) {                        
+                       id_version_bump((ID *)ma);
+                       BPY_do_pyscript((ID *)ma, SCRIPT_OBDATAUPDATE);
+               }
                if(ma) {
                        if(ma->mode & MA_RAMP_COL)
                                if(ma->ramp_col==NULL) ma->ramp_col= 
add_colorband(0);
@@ -3166,6 +3222,11 @@
                }
                break;
        case B_MAT_USENODES:
+               /* APRICOT HACK */
+               if(ma) {                        
+                       id_version_bump((ID *)ma);
+                       BPY_do_pyscript((ID *)ma, SCRIPT_OBDATAUPDATE);
+               }
                ma= G.buts->lockpoin;   /* use base material instead */
                if(ma) {
                        if(ma->use_nodes && ma->nodetree==NULL) {
@@ -3179,6 +3240,11 @@
                }               
                break;
        case B_MAT_VCOL_PAINT:
+               /* APRICOT HACK */
+               if(ma) {                        
+                       id_version_bump((ID *)ma);
+                       BPY_do_pyscript((ID *)ma, SCRIPT_OBDATAUPDATE);
+               }
                if(ma) {
                        ma->mode &= ~MA_VERTEXCOL;
                        BIF_preview_changed(ID_MA);
@@ -3186,6 +3252,11 @@
                }
                break;
        case B_MAT_VCOL_LIGHT:
+               /* APRICOT HACK */
+               if(ma) {                        
+                       id_version_bump((ID *)ma);
+                       BPY_do_pyscript((ID *)ma, SCRIPT_OBDATAUPDATE);
+               }
                if(ma) {
                        ma->mode &= ~MA_VERTEXCOLP;
                        BIF_preview_changed(ID_MA);
@@ -3194,6 +3265,11 @@
                break;
 
        case B_MAT_PARTICLE:
+               /* APRICOT HACK */
+               if(ma) {                        
+                       id_version_bump((ID *)ma);
+                       BPY_do_pyscript((ID *)ma, SCRIPT_OBDATAUPDATE);
+               }
                if(ma) {
                        Base *base;
                        Object *ob;


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

Reply via email to