Revision: 31309
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31309
Author:   moguri
Date:     2010-08-13 09:14:22 +0200 (Fri, 13 Aug 2010)

Log Message:
-----------
Fixing some issues with saving and loading vector uniforms.

Modified Paths:
--------------
    branches/soc-2010-moguri-2/source/blender/blenloader/intern/readfile.c
    branches/soc-2010-moguri-2/source/blender/blenloader/intern/writefile.c

Modified: branches/soc-2010-moguri-2/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soc-2010-moguri-2/source/blender/blenloader/intern/readfile.c      
2010-08-13 06:45:33 UTC (rev 31308)
+++ branches/soc-2010-moguri-2/source/blender/blenloader/intern/readfile.c      
2010-08-13 07:14:22 UTC (rev 31309)
@@ -2910,6 +2910,7 @@
 static void direct_link_material(FileData *fd, Material *ma)
 {
        int a;
+       CustomUniform *cu;
 
        ma->adt= newdataadr(fd, ma->adt);
        direct_link_animdata(fd, ma->adt);
@@ -2921,6 +2922,18 @@
        ma->ramp_col= newdataadr(fd, ma->ramp_col);
        ma->ramp_spec= newdataadr(fd, ma->ramp_spec);
        link_list(fd, &ma->csi.uniforms);
+               
+       cu = ma->csi.uniforms.first;
+
+       while(cu) {
+               // Sampler2D is handled in lib_link, so only vec* and ivec* 
need special attention here
+               if (cu->type != MA_UNF_FLOAT &&
+                       cu->type != MA_UNF_INT &&
+                       cu->type != MA_UNF_SAMPLER2D)
+                       cu->data= newdataadr(fd, cu->data);
+
+               cu = cu->next;
+       }
        
        ma->nodetree= newdataadr(fd, ma->nodetree);
        if(ma->nodetree)

Modified: 
branches/soc-2010-moguri-2/source/blender/blenloader/intern/writefile.c
===================================================================
--- branches/soc-2010-moguri-2/source/blender/blenloader/intern/writefile.c     
2010-08-13 06:45:33 UTC (rev 31308)
+++ branches/soc-2010-moguri-2/source/blender/blenloader/intern/writefile.c     
2010-08-13 07:14:22 UTC (rev 31309)
@@ -1688,6 +1688,20 @@
        while(cu) {
                writestruct(wd, DATA, "CustomUniform", 1, cu);
 
+               switch(cu->type)
+               {
+                       case MA_UNF_VEC2:
+                       case MA_UNF_VEC3:
+                       case MA_UNF_VEC4:
+                               writedata(wd, DATA, sizeof(float) * cu->size, 
cu->data);
+                               break;
+                       case MA_UNF_IVEC2:
+                       case MA_UNF_IVEC3:
+                       case MA_UNF_IVEC4:
+                               writedata(wd, DATA, sizeof(int) * cu->size, 
cu->data);
+                               break;
+               }
+
                cu= cu->next;
        }
 }


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

Reply via email to