Ocean Sim modifier patch
[blender.git] / source / blender / blenloader / intern / readfile.c
index 3fd661a52dae058c639f7c8e6a42defa81b2e8a7..9e3feedc5d9f4fb966d15f501028ea5f40a593ec 100644 (file)
 #include "BKE_modifier.h"
 #include "BKE_multires.h"
 #include "BKE_node.h" // for tree type defines
+#include "BKE_ocean.h"
 #include "BKE_object.h"
 #include "BKE_paint.h"
 #include "BKE_particle.h"
@@ -3101,6 +3102,8 @@ static void lib_link_texture(FileData *fd, Main *main)
                        if(tex->pd)
                                tex->pd->object= newlibadr(fd, tex->id.lib, tex->pd->object);
                        if(tex->vd) tex->vd->object= newlibadr(fd, tex->id.lib, tex->vd->object);
+                       if(tex->ot) tex->ot->object= newlibadr(fd, tex->id.lib, tex->ot->object);
+                               
 
                        if(tex->nodetree)
                                lib_link_ntree(fd, &tex->id, tex->nodetree);
@@ -3152,6 +3155,8 @@ static void direct_link_texture(FileData *fd, Tex *tex)
                        tex->vd= MEM_callocN(sizeof(VoxelData), "direct_link_texture VoxelData");
        }
        
+       tex->ot= newdataadr(fd, tex->ot);
+       
        tex->nodetree= newdataadr(fd, tex->nodetree);
        if(tex->nodetree)
                direct_link_nodetree(fd, tex->nodetree);
@@ -4368,6 +4373,12 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
                                                SWITCH_INT(mmd->bindcos[a])
                        }
                }
+               else if (md->type==eModifierType_Ocean) {
+                       OceanModifierData *omd = (OceanModifierData*) md;
+                       omd->oceancache = NULL;
+                       omd->ocean = NULL;
+                       omd->refresh = (MOD_OCEAN_REFRESH_ADD|MOD_OCEAN_REFRESH_RESET|MOD_OCEAN_REFRESH_SIM);
+               }
                else if (md->type==eModifierType_Warp) {
                        WarpModifierData *tmd = (WarpModifierData *) md;
 
@@ -11846,6 +11857,27 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                        }
                }
        }
+
+       /* put compatibility code here until next subversion bump */
+       if (main->versionfile < 255 || (main->versionfile == 255 && main->subversionfile < 3)) {
+               Object *ob;
+               Tex *tex;
+               
+               
+               /* ocean res is now squared, reset old ones - will be massive */
+               for(ob = main->object.first; ob; ob = ob->id.next) {
+                       ModifierData *md;
+                       for(md= ob->modifiers.first; md; md= md->next) {
+                               if (md->type == eModifierType_Ocean) {
+                                       OceanModifierData *omd = (OceanModifierData *)md;
+                                       omd->resolution = 7;
+                                       omd->oceancache = NULL;
+                               }
+                       }
+               }               
+       }
+
+       /* put compatibility code here until next subversion bump */
        
        if (main->versionfile < 256) {
                bScreen *sc;