[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [41780] trunk/blender: Ocean Sim modifier patch

Lukas Toenne lukas.toenne at googlemail.com
Sun Nov 13 13:17:28 CET 2011


Revision: 41780
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41780
Author:   lukastoenne
Date:     2011-11-13 12:17:27 +0000 (Sun, 13 Nov 2011)
Log Message:
-----------
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

Modified Paths:
--------------
    trunk/blender/CMakeLists.txt
    trunk/blender/SConstruct
    trunk/blender/build_files/scons/tools/btools.py
    trunk/blender/release/scripts/startup/bl_ui/properties_data_modifier.py
    trunk/blender/release/scripts/startup/bl_ui/properties_texture.py
    trunk/blender/source/blender/blenkernel/BKE_texture.h
    trunk/blender/source/blender/blenkernel/CMakeLists.txt
    trunk/blender/source/blender/blenkernel/SConscript
    trunk/blender/source/blender/blenkernel/intern/texture.c
    trunk/blender/source/blender/blenloader/intern/readfile.c
    trunk/blender/source/blender/blenloader/intern/writefile.c
    trunk/blender/source/blender/editors/object/object_intern.h
    trunk/blender/source/blender/editors/object/object_modifier.c
    trunk/blender/source/blender/editors/object/object_ops.c
    trunk/blender/source/blender/makesdna/DNA_modifier_types.h
    trunk/blender/source/blender/makesdna/DNA_texture_types.h
    trunk/blender/source/blender/makesrna/RNA_access.h
    trunk/blender/source/blender/makesrna/SConscript
    trunk/blender/source/blender/makesrna/intern/CMakeLists.txt
    trunk/blender/source/blender/makesrna/intern/rna_modifier.c
    trunk/blender/source/blender/makesrna/intern/rna_texture.c
    trunk/blender/source/blender/modifiers/CMakeLists.txt
    trunk/blender/source/blender/modifiers/MOD_modifiertypes.h
    trunk/blender/source/blender/modifiers/SConscript
    trunk/blender/source/blender/modifiers/intern/MOD_util.c
    trunk/blender/source/blender/render/CMakeLists.txt
    trunk/blender/source/blender/render/intern/source/render_texture.c

Added Paths:
-----------
    trunk/blender/source/blender/blenkernel/BKE_ocean.h
    trunk/blender/source/blender/blenkernel/intern/ocean.c
    trunk/blender/source/blender/modifiers/intern/MOD_ocean.c
    trunk/blender/source/blender/render/intern/include/texture_ocean.h
    trunk/blender/source/blender/render/intern/source/texture_ocean.c

Modified: trunk/blender/CMakeLists.txt
===================================================================
--- trunk/blender/CMakeLists.txt	2011-11-13 11:40:35 UTC (rev 41779)
+++ trunk/blender/CMakeLists.txt	2011-11-13 12:17:27 UTC (rev 41780)
@@ -171,6 +171,7 @@
 option(WITH_MOD_BOOLEAN        	"Enable Boolean Modifier" ON)
 option(WITH_MOD_CLOTH_ELTOPO   	"Enable Experemental cloth solver" OFF)
 mark_as_advanced(WITH_MOD_CLOTH_ELTOPO)
+option(WITH_OCEANSIM            "Enable Ocean Modifier" OFF)
 
 # Image format support
 option(WITH_IMAGE_OPENEXR       "Enable OpenEXR Support (http://www.openexr.com)" ON)
@@ -285,6 +286,10 @@
 						"line if youre a developer who wants to add support.")
 endif()
 
+if(NOT WITH_FFTW3 AND WITH_OCEANSIM)
+	message(FATAL_ERROR "WITH_OCEANSIM requires WITH_FFTW3 to be ON")
+endif()
+
 # may as well build python module without a UI
 if(WITH_PYTHON_MODULE)
 	set(WITH_HEADLESS ON)
@@ -1562,6 +1567,7 @@
 	info_cfg_option(WITH_MOD_BOOLEAN)
 	info_cfg_option(WITH_MOD_DECIMATE)
 	info_cfg_option(WITH_MOD_FLUID)
+	info_cfg_option(WITH_OCEANSIM)
 
 	info_cfg_text("")
 

Modified: trunk/blender/SConstruct
===================================================================
--- trunk/blender/SConstruct	2011-11-13 11:40:35 UTC (rev 41779)
+++ trunk/blender/SConstruct	2011-11-13 12:17:27 UTC (rev 41780)
@@ -254,6 +254,7 @@
     target_env_defs['WITH_BF_BINRELOC'] = False
     target_env_defs['BF_BUILDINFO'] = False
     target_env_defs['WITH_BF_FLUID'] = False
+    target_env_defs['WITH_BF_OCEANSIM'] = False
     target_env_defs['WITH_BF_DECIMATE'] = False
     target_env_defs['WITH_BF_BOOLEAN'] = False
     target_env_defs['WITH_BF_PYTHON'] = False
@@ -329,7 +330,11 @@
 if env['WITH_BF_FLUID'] == 1:
     env['CPPFLAGS'].append('-DWITH_MOD_FLUID')
 
+# build with ocean sim?
+if env['WITH_BF_OCEANSIM'] == 1:
+    env['CPPFLAGS'].append('-DWITH_MOD_OCEANSIM')
 
+
 if btools.ENDIAN == "big":
     env['CPPFLAGS'].append('-D__BIG_ENDIAN__')
 else:

Modified: trunk/blender/build_files/scons/tools/btools.py
===================================================================
--- trunk/blender/build_files/scons/tools/btools.py	2011-11-13 11:40:35 UTC (rev 41779)
+++ trunk/blender/build_files/scons/tools/btools.py	2011-11-13 12:17:27 UTC (rev 41780)
@@ -152,6 +152,7 @@
             'WITH_BF_FLUID',
             'WITH_BF_DECIMATE',
             'WITH_BF_BOOLEAN',
+            'WITH_BF_OCEANSIM',
             'WITH_BF_CXX_GUARDEDALLOC',
             'WITH_BF_JEMALLOC', 'WITH_BF_STATICJEMALLOC', 'BF_JEMALLOC', 'BF_JEMALLOC_INC', 'BF_JEMALLOC_LIBPATH', 'BF_JEMALLOC_LIB', 'BF_JEMALLOC_LIB_STATIC',
             'BUILDBOT_BRANCH',
@@ -259,6 +260,7 @@
         (BoolVariable('WITH_BF_FLUID', 'Build with Fluid simulation (Elbeem)', True)),
         (BoolVariable('WITH_BF_DECIMATE', 'Build with decimate modifier', True)),
         (BoolVariable('WITH_BF_BOOLEAN', 'Build with boolean modifier', True)),
+        (BoolVariable('WITH_BF_OCEANSIM', 'Build with ocean simulation', False)),
         ('BF_PROFILE_FLAGS', 'Profiling compiler flags', ''),
         (BoolVariable('WITH_BF_OPENAL', 'Use OpenAL if true', False)),
         ('BF_OPENAL', 'Base path for OpenAL', ''),

Modified: trunk/blender/release/scripts/startup/bl_ui/properties_data_modifier.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_data_modifier.py	2011-11-13 11:40:35 UTC (rev 41779)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_data_modifier.py	2011-11-13 12:17:27 UTC (rev 41780)
@@ -414,6 +414,74 @@
             row.operator("object.multires_external_save", text="Save External...")
             row.label()
 
+    def OCEAN(self, layout, ob, md):
+        col = layout.column()
+        
+        if not md.build_enabled:
+            col.label("Built without OceanSim modifier")
+            return
+
+        col.prop(md, "geometry_mode")
+        
+        if md.geometry_mode == 'GENERATE':
+            row = col.row()
+            row.prop(md, "repeat_x")
+            row.prop(md, "repeat_y")
+
+        col.separator()
+        
+        col.prop(md, "time")
+        col.prop(md, "resolution")
+        colflow = col.column_flow()
+        colflow.prop(md, "spatial_size")
+        colflow.prop(md, "depth")
+        
+        
+        col.label("Waves:")
+        col.prop(md, "choppiness")
+        col.prop(md, "wave_scale", text="Scale")
+        
+        col.prop(md, "wave_alignment", text="Alignment")
+        row = col.row()
+        row.active = md.wave_alignment > 0
+        row.prop(md, "wave_direction", text="Direction")
+        row.prop(md, "damp")
+        
+        col.prop(md, "smallest_wave")
+        col.prop(md, "wind_velocity")
+        
+        
+        col = layout.column()
+        col.separator()
+        
+        col.prop(md, "generate_normals")
+        
+        split = col.split()
+        split.column().prop(md, "generate_foam")
+        
+        col = split.column()
+        col.active = md.generate_foam
+        col.prop(md, "foam_coverage", text="Coverage")
+        
+        
+        col = layout.column()
+        col.separator()
+        
+        if md.is_cached:
+            col.operator("object.ocean_bake", text="Free Bake").free=True
+        else:
+            col.operator("object.ocean_bake")
+        row = col.row()
+        row.enabled = not md.is_cached
+        row.prop(md, "bake_start", text="Start")
+        row.prop(md, "bake_end", text="End")
+        col.prop(md, "cachepath")
+        
+        #col.prop(md, "bake_foam_fade")
+        
+        
+        
+    
     def PARTICLE_INSTANCE(self, layout, ob, md):
         layout.prop(md, "object")
         layout.prop(md, "particle_system_index", text="Particle System")

Modified: trunk/blender/release/scripts/startup/bl_ui/properties_texture.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_texture.py	2011-11-13 11:40:35 UTC (rev 41779)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_texture.py	2011-11-13 12:17:27 UTC (rev 41780)
@@ -774,6 +774,22 @@
         col.prop(pd, "turbulence_strength")
 
 
+class TEXTURE_PT_ocean(TextureTypePanel, Panel):
+    bl_label = "Ocean"
+    tex_type = 'OCEAN'
+    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
+    
+    def draw(self, context):
+        layout = self.layout
+        
+        tex = context.texture
+        ot = tex.ocean
+    
+        col = layout.column()        
+        col.prop(ot, "ocean_object")
+        col.prop(ot, "output")
+
+
 class TEXTURE_PT_mapping(TextureSlotPanel, Panel):
     bl_label = "Mapping"
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}

Added: trunk/blender/source/blender/blenkernel/BKE_ocean.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_ocean.h	                        (rev 0)
+++ trunk/blender/source/blender/blenkernel/BKE_ocean.h	2011-11-13 12:17:27 UTC (rev 41780)
@@ -0,0 +1,108 @@
+/* 
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * Contributors: Matt Ebb
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef BKE_OCEAN_H
+#define BKE_OCEAN_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct OceanResult {
+	float disp[3];
+    float normal[3];
+	float foam;
+	
+	/* raw eigenvalues/vectors */
+	float Jminus;
+    float Jplus;
+	float Eminus[3];
+    float Eplus[3];
+} OceanResult;
+	
+	
+typedef struct OceanCache {
+	struct ImBuf **ibufs_disp;
+	struct ImBuf **ibufs_foam;
+	struct ImBuf **ibufs_norm;
+	
+	char *bakepath;
+	
+	/* precalculated for time range */
+	float *time;
+	
+	/* constant for time range */
+	float wave_scale;
+	float chop_amount;
+	float foam_coverage;
+	float foam_fade;
+	
+	int start;
+	int end;
+	int duration;
+	int resolution_x;
+	int resolution_y;
+	
+	int baked;
+} OceanCache;
+
+
+#define OCEAN_NOT_CACHED	0
+#define OCEAN_CACHING		1
+#define OCEAN_CACHED		2
+
+	
+struct Ocean *BKE_add_ocean(void);
+void BKE_free_ocean_data(struct Ocean *oc);
+void BKE_free_ocean(struct Ocean *oc);
+
+void BKE_init_ocean(struct Ocean* o, int M,int N, float Lx, float Lz, float V, float l, float A, float w, float damp, 
+					float alignment, float depth, float time, short do_height_field, short do_chop, short do_normals, short do_jacobian, int seed);
+void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount);
+
+/* sampling the ocean surface */
+float BKE_ocean_jminus_to_foam(float jminus, float coverage);
+void BKE_ocean_eval_uv(struct Ocean * oc, struct OceanResult *ocr, float u, float v);
+void BKE_ocean_eval_uv_catrom(struct Ocean * oc, struct OceanResult *ocr, float u, float v);
+void BKE_ocean_eval_xz(struct Ocean * oc, struct OceanResult *ocr, float x, float z);
+void BKE_ocean_eval_xz_catrom(struct Ocean * oc, struct OceanResult *ocr, float x, float z);
+void BKE_ocean_eval_ij(struct Ocean * oc, struct OceanResult *ocr, int i, int j);
+
+
+/* ocean cache handling */
+struct OceanCache *BKE_init_ocean_cache(char *bakepath, int start, int end, float wave_scale, 
+						  float chop_amount, float foam_coverage, float foam_fade, int resolution);
+void BKE_simulate_ocean_cache(struct OceanCache *och, int frame);
+	
+void BKE_bake_ocean(struct Ocean *o, struct OceanCache *och, void (*update_cb)(void *, float progress, int *cancel), void *update_cb_data);
+void BKE_ocean_cache_eval_uv(struct OceanCache *och, struct OceanResult *ocr, int f, float u, float v);
+void BKE_ocean_cache_eval_ij(struct OceanCache *och, struct OceanResult *ocr, int f, int i, int j);
+

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list