From 11c83d843206648a33bcc8b4d754577ec0a51d2a Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Sun, 13 Nov 2011 12:17:27 +0000 Subject: Ocean Sim modifier patch by Matt Ebb, Hamed Zaghaghi This adds a new Modifier "Ocean" to simulate large-scale wave motion. Details can be found in the wiki documentation [1], the project homepage [2] and the patch tracker [3] The modifier is disabled by default for now. To enable it, the WITH_OCEANSIM (cmake) / WITH_BF_OCEANSIM (scons) flags have to be set. The code depends on fftw3, so this also has to be enabled. [1] http://wiki.blender.org/index.php/Doc:2.6/Manual/Modifiers/Simulation/Ocean [2] http://www.savetheoceansim.com [3] http://projects.blender.org/tracker/?group_id=9&atid=127&func=detail&aid=28338 --- source/blender/blenkernel/intern/texture.c | 44 +++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern/texture.c') diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index c80b2880d12..fcaeacd2eb4 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -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) -- cgit v1.2.3