Ocean Sim modifier patch
[blender.git] / source / blender / blenkernel / intern / texture.c
index c80b2880d12a9672db07b49a44cf5ce6b2739e6d..fcaeacd2eb4c0bcc66d6ee096fc7d17286f17dcc 100644 (file)
@@ -60,6 +60,7 @@
 #include "BKE_utildefines.h"
 #include "BKE_global.h"
 #include "BKE_main.h"
+#include "BKE_ocean.h"
 
 #include "BKE_library.h"
 #include "BKE_image.h"
@@ -71,6 +72,7 @@
 #include "BKE_animsys.h"
 #include "BKE_colortools.h"
 
+
 /* ------------------------------------------------------------------------- */
 
 /* All support for plugin textures: */
@@ -546,6 +548,7 @@ void free_texture(Tex *tex)
        if(tex->env) BKE_free_envmap(tex->env);
        if(tex->pd) BKE_free_pointdensity(tex->pd);
        if(tex->vd) BKE_free_voxeldata(tex->vd);
+       if(tex->ot) BKE_free_oceantex(tex->ot);
        BKE_free_animdata((struct ID *)tex);
        
        BKE_previewimg_free(&tex->preview);
@@ -628,6 +631,11 @@ void default_tex(Tex *tex)
                tex->vd->interp_type=TEX_VD_LINEAR;
                tex->vd->file_format=TEX_VD_SMOKE;
        }
+       
+       if (tex->ot) {
+               tex->ot->output = TEX_OCN_DISPLACEMENT;
+               tex->ot->object = NULL;
+       }
        pit = tex->plugin;
        if (pit) {
                varstr= pit->varstr;
@@ -662,6 +670,10 @@ void tex_set_type(Tex *tex, int type)
                        if (tex->env == NULL)
                                tex->env = BKE_add_envmap();
                        break;
+               case TEX_OCEAN:
+                       if (tex->ot == NULL)
+                               tex->ot = BKE_add_oceantex();
+                       break;
        }
        
        tex->type = type;
@@ -826,6 +838,7 @@ Tex *copy_texture(Tex *tex)
        if(texn->env) texn->env= BKE_copy_envmap(texn->env);
        if(texn->pd) texn->pd= BKE_copy_pointdensity(texn->pd);
        if(texn->vd) texn->vd= MEM_dupallocN(texn->vd);
+       if(texn->ot) texn->ot= BKE_copy_oceantex(texn->ot);
        if(tex->preview) texn->preview = BKE_previewimg_copy(tex->preview);
 
        if(tex->nodetree) {
@@ -864,6 +877,9 @@ Tex *localize_texture(Tex *tex)
                if(texn->vd->dataset)
                        texn->vd->dataset= MEM_dupallocN(texn->vd->dataset);
        }
+       if(texn->ot) {
+               texn->ot= BKE_copy_oceantex(tex->ot);
+       }
        
        texn->preview = NULL;
        
@@ -1039,7 +1055,7 @@ void autotexname(Tex *tex)
        Main *bmain= G.main;
        char texstr[20][15]= {"None"  , "Clouds" , "Wood", "Marble", "Magic"  , "Blend",
                "Stucci", "Noise"  , "Image", "Plugin", "EnvMap" , "Musgrave",
-               "Voronoi", "DistNoise", "Point Density", "Voxel Data", "", "", "", ""};
+               "Voronoi", "DistNoise", "Point Density", "Voxel Data", "Ocean", "", "", ""};
        Image *ima;
        char di[FILE_MAXDIR], fi[FILE_MAXFILE];
        
@@ -1469,6 +1485,7 @@ void BKE_free_pointdensity(PointDensity *pd)
        MEM_freeN(pd);
 }
 
+/* ------------------------------------------------------------------------- */
 
 void BKE_free_voxeldatadata(struct VoxelData *vd)
 {
@@ -1513,6 +1530,31 @@ struct VoxelData *BKE_copy_voxeldata(struct VoxelData *vd)
        return vdn;
 }
 
+/* ------------------------------------------------------------------------- */
+
+struct OceanTex *BKE_add_oceantex(void)
+{
+       OceanTex *ot;
+       
+       ot= MEM_callocN(sizeof(struct OceanTex), "ocean texture");
+       ot->output = TEX_OCN_DISPLACEMENT;
+       ot->object = NULL;
+       
+       return ot;
+}
+
+struct OceanTex *BKE_copy_oceantex(struct OceanTex *ot)
+{
+       OceanTex *otn= MEM_dupallocN(ot);
+       
+       return otn;
+}
+
+void BKE_free_oceantex(struct OceanTex *ot)
+{
+       MEM_freeN(ot);
+}
+
 
 /* ------------------------------------------------------------------------- */
 int BKE_texture_dependsOnTime(const struct Tex *texture)