svn merge -r 21508:22111 https://svn.blender.org/svnroot/bf-blender/branches/blender2...
authorAndre Susano Pinto <andresusanopinto@gmail.com>
Sat, 1 Aug 2009 10:21:26 +0000 (10:21 +0000)
committerAndre Susano Pinto <andresusanopinto@gmail.com>
Sat, 1 Aug 2009 10:21:26 +0000 (10:21 +0000)
659 files changed:
CMakeLists.txt
blenderplayer/CMakeLists.txt
config/darwin-config.py
config/irix6-config.py
config/linux2-config.py
config/linuxcross-config.py
config/openbsd3-config.py
config/sunos5-config.py
config/win32-mingw-config.py
config/win32-vc-config.py
config/win64-vc-config.py
extern/binreloc/CMakeLists.txt
extern/binreloc/Makefile
extern/bullet2/src/SConscript
extern/libopenjpeg/SConscript
intern/CMakeLists.txt
intern/Makefile
intern/SConscript
intern/elbeem/SConscript
intern/elbeem/intern/solver_init.cpp
intern/ghost/intern/GHOST_SystemX11.cpp
intern/ghost/intern/GHOST_WindowWin32.cpp
intern/smoke/CMakeLists.txt [moved from release/beos-5.0-i386/specific.sh with 68% similarity, mode: 0644]
intern/smoke/Makefile [new file with mode: 0644]
intern/smoke/SConscript [new file with mode: 0644]
intern/smoke/extern/smoke_API.h [new file with mode: 0644]
intern/smoke/intern/EIGENVALUE_HELPER.h [new file with mode: 0644]
intern/smoke/intern/FFT_NOISE.h [new file with mode: 0644]
intern/smoke/intern/FLUID_3D.cpp [new file with mode: 0644]
intern/smoke/intern/FLUID_3D.h [new file with mode: 0644]
intern/smoke/intern/FLUID_3D_SOLVERS.cpp [new file with mode: 0644]
intern/smoke/intern/FLUID_3D_STATIC.cpp [new file with mode: 0644]
intern/smoke/intern/IMAGE.h [new file with mode: 0644]
intern/smoke/intern/INTERPOLATE.h [new file with mode: 0644]
intern/smoke/intern/LICENSE.txt [new file with mode: 0644]
intern/smoke/intern/LU_HELPER.h [new file with mode: 0644]
intern/smoke/intern/MERSENNETWISTER.h [new file with mode: 0644]
intern/smoke/intern/Makefile [moved from release/beos-4.5-i386/specific.sh with 68% similarity, mode: 0644]
intern/smoke/intern/Makefile.FFT [new file with mode: 0644]
intern/smoke/intern/Makefile.cygwin [new file with mode: 0644]
intern/smoke/intern/Makefile.linux [new file with mode: 0644]
intern/smoke/intern/Makefile.mac [new file with mode: 0644]
intern/smoke/intern/OBSTACLE.h [new file with mode: 0644]
intern/smoke/intern/SPHERE.cpp [new file with mode: 0644]
intern/smoke/intern/SPHERE.h [new file with mode: 0644]
intern/smoke/intern/VEC3.h [new file with mode: 0644]
intern/smoke/intern/WAVELET_NOISE.h [new file with mode: 0644]
intern/smoke/intern/WTURBULENCE.cpp [new file with mode: 0644]
intern/smoke/intern/WTURBULENCE.h [new file with mode: 0644]
intern/smoke/intern/smoke_API.cpp [new file with mode: 0644]
intern/smoke/intern/tnt/jama_eig.h [new file with mode: 0644]
intern/smoke/intern/tnt/jama_lu.h [new file with mode: 0644]
intern/smoke/intern/tnt/tnt.h [new file with mode: 0644]
intern/smoke/intern/tnt/tnt_array1d.h [new file with mode: 0644]
intern/smoke/intern/tnt/tnt_array1d_utils.h [new file with mode: 0644]
intern/smoke/intern/tnt/tnt_array2d.h [new file with mode: 0644]
intern/smoke/intern/tnt/tnt_array2d_utils.h [new file with mode: 0644]
intern/smoke/intern/tnt/tnt_array3d.h [new file with mode: 0644]
intern/smoke/intern/tnt/tnt_array3d_utils.h [new file with mode: 0644]
intern/smoke/intern/tnt/tnt_cmat.h [new file with mode: 0644]
intern/smoke/intern/tnt/tnt_fortran_array1d.h [new file with mode: 0644]
intern/smoke/intern/tnt/tnt_fortran_array1d_utils.h [new file with mode: 0644]
intern/smoke/intern/tnt/tnt_fortran_array2d.h [new file with mode: 0644]
intern/smoke/intern/tnt/tnt_fortran_array2d_utils.h [new file with mode: 0644]
intern/smoke/intern/tnt/tnt_fortran_array3d.h [new file with mode: 0644]
intern/smoke/intern/tnt/tnt_fortran_array3d_utils.h [new file with mode: 0644]
intern/smoke/intern/tnt/tnt_i_refvec.h [new file with mode: 0644]
intern/smoke/intern/tnt/tnt_math_utils.h [new file with mode: 0644]
intern/smoke/intern/tnt/tnt_sparse_matrix_csr.h [new file with mode: 0644]
intern/smoke/intern/tnt/tnt_stopwatch.h [new file with mode: 0644]
intern/smoke/intern/tnt/tnt_subscript.h [new file with mode: 0644]
intern/smoke/intern/tnt/tnt_vec.h [new file with mode: 0644]
intern/smoke/intern/tnt/tnt_version.h [new file with mode: 0644]
projectfiles_vc9/blender/BPY_python/BPY_python.vcproj
projectfiles_vc9/blender/blender.sln
projectfiles_vc9/blender/blender.vcproj
projectfiles_vc9/blender/blenkernel/BKE_blenkernel.vcproj
projectfiles_vc9/blender/blenlib/BLI_blenlib.vcproj
projectfiles_vc9/blender/editors/ED_editors.vcproj
projectfiles_vc9/blender/loader/BLO_loader.vcproj
projectfiles_vc9/blender/makesdna/DNA_makesdna.vcproj
projectfiles_vc9/blender/makesrna/RNA_makesrna.vcproj
projectfiles_vc9/blender/makesrna/RNA_rna.vcproj
projectfiles_vc9/blender/nodes/nodes.vcproj
projectfiles_vc9/blender/render/BRE_render.vcproj
release/datafiles/blenderbuttons
release/datafiles/preview.blend
release/datafiles/splash.jpg
release/io/engine_render_pov.py [new file with mode: 0644]
release/io/export_ply.py
release/scripts/bvh_import.py
release/scripts/export_dxf.py
release/scripts/export_fbx.py
release/scripts/export_map.py
release/scripts/export_obj.py
release/scripts/import_dxf.py
release/scripts/import_obj.py
release/scripts/object_active_to_other.py
release/scripts/vertexpaint_selfshadow_ao.py
release/ui/bpy_ops.py [new file with mode: 0644]
release/ui/buttons_data_armature.py
release/ui/buttons_data_bone.py
release/ui/buttons_data_camera.py
release/ui/buttons_data_curve.py
release/ui/buttons_data_empty.py
release/ui/buttons_data_lamp.py
release/ui/buttons_data_lattice.py
release/ui/buttons_data_mesh.py
release/ui/buttons_data_metaball.py [new file with mode: 0644]
release/ui/buttons_data_modifier.py
release/ui/buttons_data_text.py
release/ui/buttons_game.py [new file with mode: 0644]
release/ui/buttons_material.py
release/ui/buttons_object.py [moved from release/ui/buttons_objects.py with 55% similarity]
release/ui/buttons_object_constraint.py
release/ui/buttons_particle.py
release/ui/buttons_physics_cloth.py [moved from release/ui/buttons_physic_cloth.py with 55% similarity]
release/ui/buttons_physics_field.py
release/ui/buttons_physics_fluid.py
release/ui/buttons_physics_softbody.py
release/ui/buttons_scene.py
release/ui/buttons_texture.py
release/ui/buttons_world.py
release/ui/space_buttons.py
release/ui/space_console.py [new file with mode: 0644]
release/ui/space_filebrowser.py
release/ui/space_image.py
release/ui/space_info.py
release/ui/space_logic.py
release/ui/space_outliner.py
release/ui/space_sequencer.py
release/ui/space_text.py
release/ui/space_view3d.py [new file with mode: 0644]
release/ui/space_view3d_toolbar.py
source/Makefile
source/blender/avi/intern/avi.c
source/blender/blenfont/BLF_api.h
source/blender/blenfont/intern/blf.c
source/blender/blenfont/intern/blf_font.c
source/blender/blenfont/intern/blf_glyph.c
source/blender/blenfont/intern/blf_internal.h
source/blender/blenkernel/BKE_action.h
source/blender/blenkernel/BKE_animsys.h
source/blender/blenkernel/BKE_blender.h
source/blender/blenkernel/BKE_boids.h [new file with mode: 0644]
source/blender/blenkernel/BKE_cloth.h
source/blender/blenkernel/BKE_colortools.h
source/blender/blenkernel/BKE_context.h
source/blender/blenkernel/BKE_fcurve.h
source/blender/blenkernel/BKE_modifier.h
source/blender/blenkernel/BKE_nla.h
source/blender/blenkernel/BKE_object.h
source/blender/blenkernel/BKE_particle.h
source/blender/blenkernel/BKE_pointcache.h
source/blender/blenkernel/BKE_property.h
source/blender/blenkernel/BKE_report.h
source/blender/blenkernel/BKE_screen.h
source/blender/blenkernel/BKE_sketch.h [new file with mode: 0644]
source/blender/blenkernel/BKE_smoke.h [new file with mode: 0644]
source/blender/blenkernel/BKE_softbody.h
source/blender/blenkernel/BKE_utildefines.h
source/blender/blenkernel/BKE_writeffmpeg.h
source/blender/blenkernel/CMakeLists.txt
source/blender/blenkernel/SConscript
source/blender/blenkernel/intern/Makefile
source/blender/blenkernel/intern/action.c
source/blender/blenkernel/intern/anim_sys.c
source/blender/blenkernel/intern/armature.c
source/blender/blenkernel/intern/blender.c
source/blender/blenkernel/intern/boids.c [new file with mode: 0644]
source/blender/blenkernel/intern/colortools.c
source/blender/blenkernel/intern/context.c
source/blender/blenkernel/intern/depsgraph.c
source/blender/blenkernel/intern/effect.c
source/blender/blenkernel/intern/exotic.c
source/blender/blenkernel/intern/fcurve.c
source/blender/blenkernel/intern/fluidsim.c
source/blender/blenkernel/intern/fmodifier.c [new file with mode: 0644]
source/blender/blenkernel/intern/image.c
source/blender/blenkernel/intern/ipo.c
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/mesh.c
source/blender/blenkernel/intern/modifier.c
source/blender/blenkernel/intern/multires.c
source/blender/blenkernel/intern/nla.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/particle_system.c
source/blender/blenkernel/intern/pointcache.c
source/blender/blenkernel/intern/property.c
source/blender/blenkernel/intern/report.c
source/blender/blenkernel/intern/scene.c
source/blender/blenkernel/intern/screen.c
source/blender/blenkernel/intern/sequence.c
source/blender/blenkernel/intern/sketch.c [new file with mode: 0644]
source/blender/blenkernel/intern/smoke.c [new file with mode: 0644]
source/blender/blenkernel/intern/softbody.c
source/blender/blenkernel/intern/texture.c
source/blender/blenkernel/intern/world.c
source/blender/blenkernel/intern/writeavi.c
source/blender/blenkernel/intern/writeffmpeg.c
source/blender/blenkernel/nla_private.h [new file with mode: 0644]
source/blender/blenlib/BLI_arithb.h
source/blender/blenlib/BLI_dlrbTree.h [new file with mode: 0644]
source/blender/blenlib/BLI_editVert.h
source/blender/blenlib/BLI_fileops.h
source/blender/blenlib/BLI_kdopbvh.h
source/blender/blenlib/BLI_kdtree.h
source/blender/blenlib/BLI_storage_types.h
source/blender/blenlib/BLI_util.h
source/blender/blenlib/SConscript
source/blender/blenlib/intern/BLI_kdopbvh.c
source/blender/blenlib/intern/BLI_kdtree.c
source/blender/blenlib/intern/DLRB_tree.c [new file with mode: 0644]
source/blender/blenlib/intern/arithb.c
source/blender/blenlib/intern/fileops.c
source/blender/blenlib/intern/storage.c
source/blender/blenlib/intern/util.c
source/blender/blenloader/CMakeLists.txt
source/blender/blenloader/SConscript
source/blender/blenloader/intern/Makefile
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/editors/CMakeLists.txt
source/blender/editors/Makefile
source/blender/editors/SConscript
source/blender/editors/animation/anim_channels.c
source/blender/editors/animation/anim_deps.c
source/blender/editors/animation/anim_draw.c
source/blender/editors/animation/anim_filter.c
source/blender/editors/animation/anim_markers.c
source/blender/editors/animation/anim_ops.c
source/blender/editors/animation/drivers.c
source/blender/editors/animation/fmodifier_ui.c [new file with mode: 0644]
source/blender/editors/animation/keyframes_draw.c
source/blender/editors/animation/keyframes_edit.c
source/blender/editors/animation/keyframes_general.c
source/blender/editors/animation/keyframing.c
source/blender/editors/animation/keyingsets.c
source/blender/editors/armature/armature_intern.h
source/blender/editors/armature/armature_ops.c
source/blender/editors/armature/editarmature.c
source/blender/editors/armature/editarmature_retarget.c
source/blender/editors/armature/editarmature_sketch.c
source/blender/editors/armature/meshlaplacian.c
source/blender/editors/armature/poselib.c
source/blender/editors/armature/poseobject.c
source/blender/editors/curve/curve_intern.h
source/blender/editors/curve/curve_ops.c
source/blender/editors/curve/editcurve.c
source/blender/editors/curve/editfont.c
source/blender/editors/datafiles/B.blend.c
source/blender/editors/datafiles/blenderbuttons.c
source/blender/editors/datafiles/preview.blend.c
source/blender/editors/gpencil/gpencil_edit.c
source/blender/editors/include/BIF_glutil.h
source/blender/editors/include/ED_anim_api.h
source/blender/editors/include/ED_armature.h
source/blender/editors/include/ED_curve.h
source/blender/editors/include/ED_fileselect.h
source/blender/editors/include/ED_keyframes_draw.h
source/blender/editors/include/ED_keyframing.h
source/blender/editors/include/ED_mball.h [moved from source/blender/makesrna/intern/rna_scriptlink.c with 57% similarity]
source/blender/editors/include/ED_mesh.h
source/blender/editors/include/ED_object.h
source/blender/editors/include/ED_physics.h
source/blender/editors/include/ED_previewrender.h
source/blender/editors/include/ED_screen.h
source/blender/editors/include/ED_screen_types.h
source/blender/editors/include/ED_space_api.h
source/blender/editors/include/ED_transform.h
source/blender/editors/include/ED_util.h
source/blender/editors/include/UI_icons.h
source/blender/editors/include/UI_interface.h
source/blender/editors/include/UI_view2d.h
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_anim.c
source/blender/editors/interface/interface_draw.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_intern.h
source/blender/editors/interface/interface_layout.c
source/blender/editors/interface/interface_panel.c
source/blender/editors/interface/interface_regions.c
source/blender/editors/interface/interface_style.c
source/blender/editors/interface/interface_templates.c
source/blender/editors/interface/interface_utils.c
source/blender/editors/interface/interface_widgets.c
source/blender/editors/interface/resources.c
source/blender/editors/interface/view2d.c
source/blender/editors/interface/view2d_ops.c
source/blender/editors/mesh/editmesh.c
source/blender/editors/mesh/editmesh_add.c
source/blender/editors/mesh/editmesh_loop.c
source/blender/editors/mesh/editmesh_mods.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/mesh/mesh_intern.h
source/blender/editors/mesh/mesh_ops.c
source/blender/editors/mesh/meshtools.c
source/blender/editors/metaball/Makefile [new file with mode: 0644]
source/blender/editors/metaball/SConscript [new file with mode: 0644]
source/blender/editors/metaball/editmball.c [new file with mode: 0644]
source/blender/editors/metaball/mball_intern.h [new file with mode: 0644]
source/blender/editors/metaball/mball_ops.c [new file with mode: 0644]
source/blender/editors/object/editconstraint.c
source/blender/editors/object/editgroup.c
source/blender/editors/object/editkey.c
source/blender/editors/object/object_edit.c
source/blender/editors/object/object_intern.h
source/blender/editors/object/object_ops.c
source/blender/editors/object/object_vgroup.c
source/blender/editors/physics/ed_fluidsim.c
source/blender/editors/physics/editparticle.c
source/blender/editors/physics/physics_boids.c [new file with mode: 0644]
source/blender/editors/preview/previewrender.c
source/blender/editors/screen/area.c
source/blender/editors/screen/glutil.c
source/blender/editors/screen/screen_context.c
source/blender/editors/screen/screen_edit.c
source/blender/editors/screen/screen_intern.h
source/blender/editors/screen/screen_ops.c
source/blender/editors/screen/screendump.c
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/editors/sculpt_paint/sculpt.c
source/blender/editors/space_action/action_draw.c
source/blender/editors/space_action/action_edit.c
source/blender/editors/space_action/action_header.c
source/blender/editors/space_action/action_intern.h
source/blender/editors/space_action/action_ops.c
source/blender/editors/space_action/action_select.c
source/blender/editors/space_action/space_action.c
source/blender/editors/space_api/spacetypes.c
source/blender/editors/space_buttons/buttons_context.c
source/blender/editors/space_buttons/buttons_header.c
source/blender/editors/space_buttons/buttons_intern.h
source/blender/editors/space_buttons/buttons_ops.c
source/blender/editors/space_buttons/space_buttons.c
source/blender/editors/space_console/Makefile [new file with mode: 0644]
source/blender/editors/space_console/SConscript [new file with mode: 0644]
source/blender/editors/space_console/console_draw.c [new file with mode: 0644]
source/blender/editors/space_console/console_intern.h [new file with mode: 0644]
source/blender/editors/space_console/console_ops.c [new file with mode: 0644]
source/blender/editors/space_console/console_report.c [new file with mode: 0644]
source/blender/editors/space_console/space_console.c [new file with mode: 0644]
source/blender/editors/space_file/file_draw.c
source/blender/editors/space_file/file_intern.h
source/blender/editors/space_file/file_ops.c
source/blender/editors/space_file/file_panels.c
source/blender/editors/space_file/filelist.c
source/blender/editors/space_file/filesel.c
source/blender/editors/space_file/fsmenu.c
source/blender/editors/space_file/space_file.c
source/blender/editors/space_file/writeimage.c
source/blender/editors/space_graph/graph_buttons.c
source/blender/editors/space_graph/graph_draw.c
source/blender/editors/space_graph/graph_edit.c
source/blender/editors/space_graph/graph_header.c
source/blender/editors/space_graph/graph_intern.h
source/blender/editors/space_graph/graph_ops.c
source/blender/editors/space_graph/graph_select.c
source/blender/editors/space_graph/graph_utils.c [new file with mode: 0644]
source/blender/editors/space_graph/space_graph.c
source/blender/editors/space_image/image_buttons.c
source/blender/editors/space_image/image_draw.c
source/blender/editors/space_image/image_header.c
source/blender/editors/space_image/image_ops.c
source/blender/editors/space_image/image_render.c
source/blender/editors/space_image/space_image.c
source/blender/editors/space_info/info_ops.c
source/blender/editors/space_info/space_info.c
source/blender/editors/space_logic/logic_buttons.c
source/blender/editors/space_logic/logic_header.c
source/blender/editors/space_logic/logic_window.c
source/blender/editors/space_logic/space_logic.c
source/blender/editors/space_nla/nla_buttons.c [new file with mode: 0644]
source/blender/editors/space_nla/nla_channels.c [new file with mode: 0644]
source/blender/editors/space_nla/nla_draw.c [new file with mode: 0644]
source/blender/editors/space_nla/nla_edit.c [new file with mode: 0644]
source/blender/editors/space_nla/nla_header.c
source/blender/editors/space_nla/nla_intern.h
source/blender/editors/space_nla/nla_ops.c [new file with mode: 0644]
source/blender/editors/space_nla/nla_select.c [new file with mode: 0644]
source/blender/editors/space_nla/space_nla.c
source/blender/editors/space_node/SConscript
source/blender/editors/space_node/node_draw.c
source/blender/editors/space_node/node_edit.c
source/blender/editors/space_node/node_header.c
source/blender/editors/space_node/node_select.c
source/blender/editors/space_node/node_state.c
source/blender/editors/space_node/space_node.c
source/blender/editors/space_outliner/outliner.c
source/blender/editors/space_outliner/outliner_header.c
source/blender/editors/space_outliner/outliner_intern.h
source/blender/editors/space_outliner/outliner_ops.c
source/blender/editors/space_outliner/space_outliner.c
source/blender/editors/space_sequencer/sequencer_add.c
source/blender/editors/space_sequencer/sequencer_edit.c
source/blender/editors/space_sequencer/sequencer_ops.c
source/blender/editors/space_sequencer/space_sequencer.c
source/blender/editors/space_text/space_text.c
source/blender/editors/space_text/text_draw.c
source/blender/editors/space_text/text_intern.h
source/blender/editors/space_text/text_ops.c
source/blender/editors/space_text/text_python.c
source/blender/editors/space_time/space_time.c
source/blender/editors/space_time/time_header.c
source/blender/editors/space_view3d/Makefile
source/blender/editors/space_view3d/SConscript
source/blender/editors/space_view3d/drawarmature.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/space_view3d.c
source/blender/editors/space_view3d/view3d_buttons.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/editors/space_view3d/view3d_edit.c
source/blender/editors/space_view3d/view3d_header.c
source/blender/editors/space_view3d/view3d_select.c
source/blender/editors/space_view3d/view3d_toolbar.c
source/blender/editors/space_view3d/view3d_view.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform.h
source/blender/editors/transform/transform_constraints.c
source/blender/editors/transform/transform_conversions.c
source/blender/editors/transform/transform_generics.c
source/blender/editors/transform/transform_input.c
source/blender/editors/transform/transform_manipulator.c
source/blender/editors/transform/transform_ops.c
source/blender/editors/transform/transform_orientations.c
source/blender/editors/util/editmode_undo.c
source/blender/editors/util/undo.c
source/blender/editors/util/util_intern.h
source/blender/editors/uvedit/uvedit_ops.c
source/blender/gpu/GPU_draw.h
source/blender/gpu/intern/gpu_draw.c
source/blender/imbuf/IMB_imbuf.h
source/blender/imbuf/IMB_imbuf_types.h
source/blender/imbuf/intern/IMB_targa.h
source/blender/imbuf/intern/divers.c
source/blender/imbuf/intern/filter.c
source/blender/imbuf/intern/iris.c
source/blender/imbuf/intern/readimage.c
source/blender/imbuf/intern/targa.c
source/blender/imbuf/intern/util.c
source/blender/makesdna/DNA_action_types.h
source/blender/makesdna/DNA_actuator_types.h
source/blender/makesdna/DNA_anim_types.h
source/blender/makesdna/DNA_armature_types.h
source/blender/makesdna/DNA_boid_types.h [new file with mode: 0644]
source/blender/makesdna/DNA_brush_types.h
source/blender/makesdna/DNA_camera_types.h
source/blender/makesdna/DNA_curve_types.h
source/blender/makesdna/DNA_lamp_types.h
source/blender/makesdna/DNA_material_types.h
source/blender/makesdna/DNA_meshdata_types.h
source/blender/makesdna/DNA_meta_types.h
source/blender/makesdna/DNA_modifier_types.h
source/blender/makesdna/DNA_object_force.h
source/blender/makesdna/DNA_object_types.h
source/blender/makesdna/DNA_particle_types.h
source/blender/makesdna/DNA_property_types.h
source/blender/makesdna/DNA_scene_types.h
source/blender/makesdna/DNA_screen_types.h
source/blender/makesdna/DNA_scriptlink_types.h [deleted file]
source/blender/makesdna/DNA_smoke_types.h [new file with mode: 0644]
source/blender/makesdna/DNA_space_types.h
source/blender/makesdna/DNA_texture_types.h
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesdna/DNA_view2d_types.h
source/blender/makesdna/DNA_windowmanager_types.h
source/blender/makesdna/DNA_world_types.h
source/blender/makesdna/intern/makesdna.c
source/blender/makesrna/RNA_access.h
source/blender/makesrna/RNA_define.h
source/blender/makesrna/RNA_enum_types.h
source/blender/makesrna/RNA_types.h
source/blender/makesrna/SConscript
source/blender/makesrna/intern/CMakeLists.txt
source/blender/makesrna/intern/Makefile
source/blender/makesrna/intern/SConscript
source/blender/makesrna/intern/makesrna.c
source/blender/makesrna/intern/rna_ID.c
source/blender/makesrna/intern/rna_access.c
source/blender/makesrna/intern/rna_animation.c
source/blender/makesrna/intern/rna_armature.c
source/blender/makesrna/intern/rna_boid.c [new file with mode: 0644]
source/blender/makesrna/intern/rna_brush.c
source/blender/makesrna/intern/rna_camera.c
source/blender/makesrna/intern/rna_cloth.c
source/blender/makesrna/intern/rna_color.c
source/blender/makesrna/intern/rna_constraint.c
source/blender/makesrna/intern/rna_context.c
source/blender/makesrna/intern/rna_curve.c
source/blender/makesrna/intern/rna_define.c
source/blender/makesrna/intern/rna_fcurve.c
source/blender/makesrna/intern/rna_fluidsim.c
source/blender/makesrna/intern/rna_internal.h
source/blender/makesrna/intern/rna_internal_types.h
source/blender/makesrna/intern/rna_key.c
source/blender/makesrna/intern/rna_lamp.c
source/blender/makesrna/intern/rna_lattice.c
source/blender/makesrna/intern/rna_material.c
source/blender/makesrna/intern/rna_mesh.c
source/blender/makesrna/intern/rna_meta.c
source/blender/makesrna/intern/rna_modifier.c
source/blender/makesrna/intern/rna_nla.c [new file with mode: 0644]
source/blender/makesrna/intern/rna_nodetree.c
source/blender/makesrna/intern/rna_object.c
source/blender/makesrna/intern/rna_object_api.c
source/blender/makesrna/intern/rna_object_force.c
source/blender/makesrna/intern/rna_particle.c
source/blender/makesrna/intern/rna_pose.c
source/blender/makesrna/intern/rna_property.c
source/blender/makesrna/intern/rna_render.c [new file with mode: 0644]
source/blender/makesrna/intern/rna_rna.c
source/blender/makesrna/intern/rna_scene.c
source/blender/makesrna/intern/rna_screen.c
source/blender/makesrna/intern/rna_sculpt_paint.c [new file with mode: 0644]
source/blender/makesrna/intern/rna_smoke.c [new file with mode: 0644]
source/blender/makesrna/intern/rna_space.c
source/blender/makesrna/intern/rna_texture.c
source/blender/makesrna/intern/rna_ui.c
source/blender/makesrna/intern/rna_ui_api.c
source/blender/makesrna/intern/rna_userdef.c
source/blender/makesrna/intern/rna_vpaint.c [deleted file]
source/blender/makesrna/intern/rna_wm.c
source/blender/makesrna/intern/rna_world.c
source/blender/nodes/CMakeLists.txt
source/blender/nodes/SConscript
source/blender/nodes/intern/CMP_nodes/CMP_image.c
source/blender/nodes/intern/CMP_nodes/CMP_lummaMatte.c
source/blender/nodes/intern/CMP_nodes/CMP_mapUV.c
source/blender/nodes/intern/CMP_nodes/Makefile
source/blender/nodes/intern/Makefile
source/blender/nodes/intern/SHD_nodes/Makefile
source/blender/nodes/intern/TEX_nodes/Makefile
source/blender/python/BPY_extern.h
source/blender/python/SConscript
source/blender/python/epy_doc_gen.py
source/blender/python/generic/BGL.h [changed mode: 0755->0644]
source/blender/python/generic/Mathutils.c
source/blender/python/generic/bpy_internal_import.c
source/blender/python/intern/bpy_interface.c
source/blender/python/intern/bpy_operator.c
source/blender/python/intern/bpy_operator_wrap.c
source/blender/python/intern/bpy_rna.c
source/blender/python/intern/bpy_rna.h
source/blender/python/intern/bpy_scriptlink.c [deleted file]
source/blender/python/intern/bpy_ui.c
source/blender/python/intern/bpy_util.c
source/blender/python/intern/bpy_util.h
source/blender/python/intern/stubs.c
source/blender/render/CMakeLists.txt
source/blender/render/SConscript
source/blender/render/extern/include/RE_pipeline.h
source/blender/render/intern/include/shading.h
source/blender/render/intern/source/Makefile
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/imagetexture.c
source/blender/render/intern/source/initrender.c
source/blender/render/intern/source/occlusion.c
source/blender/render/intern/source/pipeline.c
source/blender/render/intern/source/pixelshading.c
source/blender/render/intern/source/rayshade.c
source/blender/render/intern/source/rendercore.c
source/blender/render/intern/source/shadbuf.c
source/blender/render/intern/source/shadeinput.c
source/blender/render/intern/source/shadeoutput.c
source/blender/render/intern/source/sss.c
source/blender/render/intern/source/strand.c
source/blender/render/intern/source/texture.c
source/blender/render/intern/source/zbuf.c
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/WM_types.h
source/blender/windowmanager/intern/wm.c
source/blender/windowmanager/intern/wm_cursors.c
source/blender/windowmanager/intern/wm_draw.c
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_files.c
source/blender/windowmanager/intern/wm_gesture.c
source/blender/windowmanager/intern/wm_init_exit.c
source/blender/windowmanager/intern/wm_jobs.c
source/blender/windowmanager/intern/wm_keymap.c
source/blender/windowmanager/intern/wm_operators.c
source/blender/windowmanager/intern/wm_subwindow.c
source/blender/windowmanager/intern/wm_window.c
source/blender/windowmanager/wm.h
source/blender/windowmanager/wm_event_types.h
source/blender/windowmanager/wm_window.h
source/creator/CMakeLists.txt
source/creator/creator.c
source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h
source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp
source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp
source/gameengine/BlenderRoutines/SConscript
source/gameengine/Converter/BL_ActionActuator.cpp
source/gameengine/Converter/BL_ActionActuator.h
source/gameengine/Converter/BL_ArmatureObject.h
source/gameengine/Converter/BL_BlenderDataConversion.cpp
source/gameengine/Converter/BL_BlenderDataConversion.h
source/gameengine/Converter/BL_MeshDeformer.h
source/gameengine/Converter/BL_SkinMeshObject.cpp
source/gameengine/Converter/BL_SkinMeshObject.h
source/gameengine/Converter/KX_BlenderSceneConverter.cpp
source/gameengine/Converter/KX_BlenderSceneConverter.h
source/gameengine/Converter/KX_ConvertActuators.cpp
source/gameengine/Converter/KX_ConvertSensors.cpp
source/gameengine/Converter/KX_ConvertSensors.h
source/gameengine/Expressions/SConscript
source/gameengine/Expressions/Value.cpp
source/gameengine/GameLogic/CMakeLists.txt
source/gameengine/GameLogic/SCA_IScene.h
source/gameengine/GameLogic/SConscript
source/gameengine/GamePlayer/common/SConscript
source/gameengine/GamePlayer/ghost/GPG_Application.cpp
source/gameengine/GamePlayer/ghost/SConscript
source/gameengine/Ketsji/CMakeLists.txt
source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp
source/gameengine/Ketsji/KXNetwork/SConscript
source/gameengine/Ketsji/KX_BlenderMaterial.cpp
source/gameengine/Ketsji/KX_BlenderMaterial.h
source/gameengine/Ketsji/KX_BulletPhysicsController.cpp
source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
source/gameengine/Ketsji/KX_GameObject.cpp
source/gameengine/Ketsji/KX_GameObject.h
source/gameengine/Ketsji/KX_ISceneConverter.h
source/gameengine/Ketsji/KX_KetsjiEngine.cpp
source/gameengine/Ketsji/KX_MeshProxy.cpp
source/gameengine/Ketsji/KX_MeshProxy.h
source/gameengine/Ketsji/KX_NearSensor.cpp
source/gameengine/Ketsji/KX_NearSensor.h
source/gameengine/Ketsji/KX_PolygonMaterial.cpp
source/gameengine/Ketsji/KX_PythonInit.cpp
source/gameengine/Ketsji/KX_RadarSensor.cpp
source/gameengine/Ketsji/KX_RadarSensor.h
source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp
source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h
source/gameengine/Ketsji/KX_Scene.cpp
source/gameengine/Ketsji/KX_Scene.h
source/gameengine/Ketsji/KX_SoundActuator.cpp
source/gameengine/Ketsji/SConscript
source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
source/gameengine/Physics/Bullet/CcdPhysicsController.h
source/gameengine/Physics/Bullet/SConscript
source/gameengine/Physics/common/SConscript
source/gameengine/PyDoc/API_intro.py
source/gameengine/PyDoc/GameTypes.py
source/gameengine/Rasterizer/RAS_Deformer.h
source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp
source/gameengine/Rasterizer/RAS_IPolygonMaterial.h
source/gameengine/Rasterizer/RAS_MeshObject.cpp
source/gameengine/Rasterizer/RAS_MeshObject.h
source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript
source/gameengine/Rasterizer/SConscript
source/gameengine/SceneGraph/SConscript
source/gameengine/VideoTexture/SConscript
source/nan_definitions.mk
tools/Blender.py

index a4796c2eee90555a4c9de5d372a0e1cebab530ca..d2595bd0138649ddcf419bac8750e7e9c916abb6 100644 (file)
@@ -63,6 +63,7 @@ OPTION(WITH_OPENEXR           "Enable OpenEXR Support (http://www.openexr.com)"       ON)
 OPTION(WITH_DDS                        "Enable DDS Support"                                    ON)
 OPTION(WITH_FFMPEG             "Enable FFMPeg Support (http://ffmpeg.mplayerhq.hu/)"   OFF)
 OPTION(WITH_PYTHON             "Enable Embedded Python API"                            ON)
+OPTION(WITH_SDL                        "Enable SDL for sound and joystick support"                             ON)
 OPTION(WITH_OPENJPEG           "Enable OpenJpeg Support (http://www.openjpeg.org/)"    OFF)
 OPTION(WITH_OPENAL             "Enable OpenAL Support (http://www.openal.org)"         ON)
 OPTION(WITH_OPENMP             "Enable OpenMP (has to be supported by the compiler)"   OFF)
@@ -133,9 +134,11 @@ IF(UNIX AND NOT APPLE)
   SET(PYTHON_BINARY ${PYTHON_EXECUTABLE} CACHE STRING "")
   SET(PYTHON_LINKFLAGS "-Xlinker -export-dynamic")
 
-  FIND_PACKAGE(SDL)
-  SET(SDL_INC ${SDL_INCLUDE_DIR})
-  SET(SDL_LIB ${SDL_LIBRARY})
+  IF(WITH_SDL)
+    FIND_PACKAGE(SDL)
+    SET(SDL_INC ${SDL_INCLUDE_DIR})
+    SET(SDL_LIB ${SDL_LIBRARY})
+  ENDIF(WITH_SDL)
 
   FIND_PATH(OPENEXR_INC
     ImfXdr.h
@@ -336,17 +339,29 @@ IF(APPLE)
     ENDIF(OPENAL_FOUND)
   ENDIF(WITH_OPENAL)
 
-  SET(PYTHON /System/Library/Frameworks/Python.framework/Versions/)
-  SET(PYTHON_VERSION 2.5)
-  SET(PYTHON_INC "${PYTHON}${PYTHON_VERSION}/include/python${PYTHON_VERSION}" CACHE STRING "")
-  SET(PYTHON_BINARY ${PYTHON}${PYTHON_VERSION}/bin/python${PYTHON_VERSION} CACHE STRING "")
-  SET(PYTHON_LIB "")
-  SET(PYTHON_LIBPATH ${PYTHON}${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config CACHE STRING "")
-  IF(CMAKE_SYSTEM_VERSION GREATER 10.4)
-       SET(PYTHON_LINKFLAGS "-u _PyMac_Error -framework System -framework Python")
-  ELSE(CMAKE_SYSTEM_VERSION GREATER 10.4)
+
+  SET(PYTHON_VERSION 3.1)
+
+  IF(PYTHON_VERSION MATCHES 3.1)
+    # we use precompiled libraries for py 3.1 and up by default
+
+    SET(PYTHON ${LIBDIR}/python)
+    SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}" CACHE STRING "")
+    SET(PYTHON_BINARY "${PYTHON}/bin/python${PYTHON_VERSION}" CACHE STRING "")
+    SET(PYTHON_LIB python${PYTHON_VERSION})
+    SET(PYTHON_LIBPATH "${PYTHON}/lib/python${PYTHON_VERSION}" CACHE STRING "")
+    #    SET(PYTHON_LINKFLAGS "-u _PyMac_Error")  # won't  build with this enabled
+  ELSE(PYTHON_VERSION MATCHES 3.1)
+    # otherwise, use custom system framework
+
+    SET(PYTHON /System/Library/Frameworks/Python.framework/Versions/)
+    SET(PYTHON_VERSION 2.5)
+    SET(PYTHON_INC "${PYTHON}${PYTHON_VERSION}/include/python${PYTHON_VERSION}" CACHE STRING "")
+    SET(PYTHON_BINARY ${PYTHON}${PYTHON_VERSION}/bin/python${PYTHON_VERSION} CACHE STRING "")
+    SET(PYTHON_LIB "")
+    SET(PYTHON_LIBPATH ${PYTHON}${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config CACHE STRING "")
     SET(PYTHON_LINKFLAGS "-u _PyMac_Error -framework System -framework Python")
-  ENDIF(CMAKE_SYSTEM_VERSION GREATER 10.4)
+  ENDIF(PYTHON_VERSION MATCHES 3.1)
 
   SET(GETTEXT ${LIBDIR}/gettext)
   SET(GETTEXT_INC "${GETTEXT}/include")
@@ -367,11 +382,7 @@ IF(APPLE)
 
   SET(OPENEXR ${LIBDIR}/openexr)
   SET(OPENEXR_INC ${OPENEXR}/include/OpenEXR ${OPENEXR}/include)
-  IF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
-    SET(OPENEXR_LIB Iex Half IlmImf Imath IlmThread)
-  ELSE(CMAKE_OSX_ARCHITECTURES MATCHES i386)
-    SET(OPENEXR_LIB Iex Half IlmImf Imath)
-  ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
+  SET(OPENEXR_LIB Iex Half IlmImf Imath IlmThread)
   SET(OPENEXR_LIBPATH ${OPENEXR}/lib)
 
   SET(LLIBS stdc++ SystemStubs)
index 5b13a5f45212a770e1c6ea6e28ce8767f66f2689..28fe13cbf64e68c198183b6055e11e5ecb0852da 100644 (file)
@@ -32,10 +32,10 @@ IF(WITH_QUICKTIME)
   ADD_DEFINITIONS(-DWITH_QUICKTIME)
 ENDIF(WITH_QUICKTIME)
 
-IF(LINUX)
+IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
   ADD_DEFINITIONS(-DWITH_BINRELOC)
   INCLUDE_DIRECTORIES(${BINRELOC_INC})
-endif(LINUX)
+ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
 
 ADD_CUSTOM_COMMAND(
   OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dna.c
@@ -69,7 +69,6 @@ IF(UNIX)
     bf_blenkernel 
     verse 
     bf_blenkernel 
-    bf_decimation 
     bf_blenloader 
     bf_blenpluginapi 
     bf_blroutines 
index 785f1cb42a2e4068e28aec8a22c40ca3f15319d0..decf1a206d55e11eaea1c6c7611c17bb61719ba1 100644 (file)
@@ -10,8 +10,6 @@ import commands
 # IMPORTANT NOTE : OFFICIAL BUILDS SHOULD BE DONE WITH SDKs
 USE_SDK=True
 
-BF_PYTHON_VERSION = '2.3'
-
 cmd = 'uname -p'
 MAC_PROC=commands.getoutput(cmd) 
 cmd = 'uname -r'
@@ -32,9 +30,12 @@ LIBDIR = '${LCGDIR}'
 if MAC_PROC== 'powerpc' and BF_PYTHON_VERSION == '2.3':
        MAC_MIN_VERS = '10.3'
        MACOSX_SDK='/Developer/SDKs/MacOSX10.3.9.sdk'
-else:
+elif MAC_CUR_VER=='10.4':
        MAC_MIN_VERS = '10.4'
        MACOSX_SDK='/Developer/SDKs/MacOSX10.4u.sdk'
+else:
+       MAC_MIN_VERS = '10.5'
+       MACOSX_SDK='/Developer/SDKs/MacOSX10.5.sdk'
 
 
 # enable ffmpeg  support
@@ -46,24 +47,35 @@ if USE_SDK==True:
 #BF_FFMPEG_LIBPATH='${BF_FFMPEG}/lib'
 #BF_FFMPEG_LIB = 'avformat.a avcodec.a avutil.a'
 
-# python.org libs install in /library we want to use that for 2.5 
-#
-# if you want py2.5 on leopard without installing
-# change value to BF_PYTHON = '/Library/Frameworks/Python.framework/Versions/'
-# BEWARE: in that case it will work only on leopard
+BF_PYTHON_VERSION = '3.1'
 
-if BF_PYTHON_VERSION=='2.3':
-       BF_PYTHON = '/System/Library/Frameworks/Python.framework/Versions/'
+if BF_PYTHON_VERSION=='3.1':
+       # python 3.1 uses precompiled libraries in bf svn /lib by default
+
+       BF_PYTHON = LIBDIR + '/python'
+       BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}'
+       # BF_PYTHON_BINARY = '${BF_PYTHON}/bin/python${BF_PYTHON_VERSION}'
+       BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION}'
+       BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib/python${BF_PYTHON_VERSION}'
+       # BF_PYTHON_LINKFLAGS = '-u _PyMac_Error -framework System'
 else:
-       BF_PYTHON = '/Library/Frameworks/Python.framework/Versions/'
-
-BF_PYTHON_INC = '${BF_PYTHON}${BF_PYTHON_VERSION}/include/python${BF_PYTHON_VERSION}'
-BF_PYTHON_BINARY = '${BF_PYTHON}${BF_PYTHON_VERSION}/bin/python${BF_PYTHON_VERSION}'
-BF_PYTHON_LIB = ''
-BF_PYTHON_LIBPATH = '${BF_PYTHON}${BF_PYTHON_VERSION}/lib/python${BF_PYTHON_VERSION}/config'
-BF_PYTHON_LINKFLAGS = '-u _PyMac_Error -framework System -framework Python'
-if MAC_CUR_VER=='10.3' or  MAC_CUR_VER=='10.4':
-       BF_PYTHON_LINKFLAGS ='-u __dummy '+BF_PYTHON_LINKFLAGS
+       # python 2.5 etc. uses built-in framework
+
+       # python.org libs install in /library we want to use that for 2.5 
+       #
+       # if you want py2.5 on leopard without installing
+       # change value to BF_PYTHON = '/Library/Frameworks/Python.framework/Versions/'
+       # BEWARE: in that case it will work only on leopard
+
+       BF_PYTHON = '/System/Library/Frameworks/Python.framework/Versions/'
+
+       BF_PYTHON_INC = '${BF_PYTHON}${BF_PYTHON_VERSION}/include/python${BF_PYTHON_VERSION}'
+       BF_PYTHON_BINARY = '${BF_PYTHON}${BF_PYTHON_VERSION}/bin/python${BF_PYTHON_VERSION}'
+       BF_PYTHON_LIB = ''
+       BF_PYTHON_LIBPATH = '${BF_PYTHON}${BF_PYTHON_VERSION}/lib/python${BF_PYTHON_VERSION}/config'
+       BF_PYTHON_LINKFLAGS = '-u _PyMac_Error -framework System -framework Python'
+       if MAC_CUR_VER=='10.3' or  MAC_CUR_VER=='10.4':
+               BF_PYTHON_LINKFLAGS ='-u __dummy '+BF_PYTHON_LINKFLAGS
        
 BF_QUIET = '1'
 WITH_BF_OPENMP = '0'
@@ -139,7 +151,7 @@ BF_GETTEXT_LIB = 'intl'
 BF_GETTEXT_LIBPATH = '${BF_GETTEXT}/lib'
 
 WITH_BF_GAMEENGINE=True
-WITH_BF_PLAYER=True
+WITH_BF_PLAYER = False
 
 WITH_BF_BULLET = True
 BF_BULLET = '#extern/bullet2/src'
index 87af6b29eb18b21ffd29b7e5d14d341cfd79b600..93d6506ccc74cbdb54bf4dc02b48ff67d3a01204 100644 (file)
@@ -73,6 +73,7 @@ BF_GETTEXT_LIB = 'gettextpo intl'
 BF_GETTEXT_LIBPATH = '${BF_GETTEXT}/lib'
 
 WITH_BF_GAMEENGINE='false'
+WITH_BF_PLAYER = 'false'
 
 WITH_BF_BULLET = 'true'
 BF_BULLET = '#extern/bullet2/src'
index 86de10c8fb39531eddf8374aa76508ddae114d0a..6b6373bb00128888396ddffb01dff916c9439e15 100644 (file)
@@ -1,17 +1,9 @@
 LCGDIR = '../lib/linux2'
 LIBDIR = "${LCGDIR}"
 
-def py_version_string():
-       '''
-       returns py version - "2.5", "2.6" etc
-       '''
-       import platform
-       ver = platform.python_version_tuple()
-       return '%d.%d' % (int(ver[0]), int(ver[1])) # py2.5 uses strings, 2.6 ints
-
 BF_PYTHON = '/usr'
 BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib'
-BF_PYTHON_VERSION = py_version_string()
+BF_PYTHON_VERSION = '3.1'
 WITH_BF_STATICPYTHON = False
 BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}'
 BF_PYTHON_BINARY = '${BF_PYTHON}/bin/python${BF_PYTHON_VERSION}'
@@ -75,7 +67,7 @@ BF_GETTEXT_LIB = 'gettextlib'
 BF_GETTEXT_LIBPATH = '${BF_GETTEXT}/lib'
 
 WITH_BF_GAMEENGINE = True
-WITH_BF_PLAYER = True
+WITH_BF_PLAYER = False
 
 WITH_BF_BULLET = True
 BF_BULLET = '#extern/bullet2/src'
index 5e5c44ecd69a310131fffbf3456cd7bac45a7e84..88ad0ddd14e9756899a5c86976df4639a67adfe9 100644 (file)
@@ -73,6 +73,7 @@ BF_GETTEXT_LIB = 'gnu_gettext'
 BF_GETTEXT_LIBPATH = '${BF_GETTEXT}/lib'
 
 WITH_BF_GAMEENGINE = False
+WITH_BF_PLAYER = False
 
 WITH_BF_BULLET = True
 BF_BULLET = '#extern/bullet2/src'
index 2b0621e2ed3251e4bc6dae34c374661d451a566f..92f044394d6975da96cf10b474d5ecd30f74442b 100644 (file)
@@ -60,6 +60,7 @@ BF_GETTEXT_LIB = 'intl iconv'
 BF_GETTEXT_LIBPATH = '${BF_GETTEXT}/lib'
 
 WITH_BF_GAMEENGINE=False
+WITH_BF_PLAYER = False
 
 WITH_BF_BULLET = True
 BF_BULLET = '#extern/bullet2/src'
index dc067b6f568f254dc084058ef51e7bfd6c1dfb2e..6e970b9cab2ed0bab895f15d680b6d2f02e47840 100644 (file)
@@ -68,6 +68,7 @@ BF_GETTEXT_LIB = 'gettextlib'
 BF_GETTEXT_LIBPATH = '${BF_GETTEXT}/lib'
 
 WITH_BF_GAMEENGINE=False
+WITH_BF_PLAYER = False
 
 WITH_BF_BULLET = True
 BF_BULLET = '#extern/bullet2/src'
index eab373d25533270a9dde98cdf1287580d5eb1bfb..51cd120dc724fa784dde962f9ce340135b7ff4f6 100644 (file)
@@ -2,7 +2,8 @@ LCGDIR = '#../lib/windows'
 LIBDIR = "${LCGDIR}"
 
 BF_PYTHON = LIBDIR + '/python'
-BF_PYTHON_VERSION = '2.5'
+BF_PYTHON_VERSION = '3.1'
+#BF_PYTHON_VERSION = '2.6'
 #BF_PYTHON_VERSION = '2.6'
 WITH_BF_STATICPYTHON = False
 BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}'
@@ -80,6 +81,7 @@ BF_GETTEXT_LIB = 'gnu_gettext'
 BF_GETTEXT_LIBPATH = '${BF_GETTEXT}/lib'
 
 WITH_BF_GAMEENGINE = False
+WITH_BF_PLAYER = False
 
 WITH_BF_BULLET = True
 BF_BULLET = '#extern/bullet2/src'
@@ -148,7 +150,7 @@ LLIBS = ['-lshell32', '-lshfolder', '-lgdi32', '-lmsvcrt', '-lwinmm', '-lmingw32
 BF_DEBUG = False
 BF_DEBUG_CCFLAGS= ['-g']
 
-BF_PROFILE_CCFLAGS = ['-pg', '-g ']
+BF_PROFILE_CCFLAGS = ['-pg', '-g']
 BF_PROFILE_LINKFLAGS = ['-pg']
 BF_PROFILE_FLAGS = BF_PROFILE_CCFLAGS
 BF_PROFILE = False
index 82babeb1a3a7b36039671c52aef81be77d706d27..4df15c691c2b9010b3c616d07a7a98f92da2f2a3 100644 (file)
@@ -9,10 +9,10 @@ BF_FFMPEG_LIBPATH='${BF_FFMPEG}/lib'
 BF_FFMPEG_LIB = 'avformat-52.lib avcodec-52.lib avdevice-52.lib avutil-50.lib swscale-0.lib'
 
 BF_PYTHON = LIBDIR + '/python'
-BF_PYTHON_VERSION = '2.6'
+BF_PYTHON_VERSION = '3.1'
 BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}'
 BF_PYTHON_BINARY = 'python'
-BF_PYTHON_LIB = 'python26'
+BF_PYTHON_LIB = 'python31'
 BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib'
 
 WITH_BF_OPENAL = True
@@ -88,7 +88,7 @@ BF_GETTEXT_LIB = 'gnu_gettext'
 BF_GETTEXT_LIBPATH = '${BF_GETTEXT}/lib'
 
 WITH_BF_GAMEENGINE = True
-WITH_BF_PLAYER = True
+WITH_BF_PLAYER = False
 
 WITH_BF_BULLET = True
 BF_BULLET = '#extern/bullet2/src'
@@ -149,7 +149,7 @@ BF_OPENGL_LIB_STATIC = [ '${BF_OPENGL}/lib/libGL.a', '${BF_OPENGL}/lib/libGLU.a'
 CC = 'cl.exe'
 CXX = 'cl.exe'
 
-CCFLAGS = ['/nologo', '/Ob1', '/J', '/W3', '/Gd', '/MT']
+CCFLAGS = ['/nologo', '/Ob1', '/J', '/W3', '/Gd', '/wd4244', '/wd4305', '/wd4800', '/wd4065', '/wd4267']
 CXXFLAGS = ['/EHsc']
 
 BF_DEBUG_CCFLAGS = ['/Zi', '/FR${TARGET}.sbr']
@@ -165,7 +165,7 @@ CXX_WARN = []
 
 LLIBS = ['ws2_32', 'vfw32', 'winmm', 'kernel32', 'user32', 'gdi32', 'comdlg32', 'advapi32', 'shfolder', 'shell32', 'ole32', 'oleaut32', 'uuid']
 
-PLATFORM_LINKFLAGS = ['/SUBSYSTEM:CONSOLE','/MACHINE:IX86','/ENTRY:mainCRTStartup','/INCREMENTAL:NO','/NODEFAULTLIB:"msvcprt.lib"','/NODEFAULTLIB:"glut32.lib"','/NODEFAULTLIB:"libc.lib"','/NODEFAULTLIB:"libcd.lib"','/NODEFAULTLIB:"libcpd.lib"','/NODEFAULTLIB:"libcp.lib"','/LARGEADDRESSAWARE']
+PLATFORM_LINKFLAGS = ['/SUBSYSTEM:CONSOLE','/MACHINE:IX86','/INCREMENTAL:NO','/NODEFAULTLIB:"msvcprt.lib"','/NODEFAULTLIB:"msvcprtd.lib"','/NODEFAULTLIB:"glut32.lib"','/NODEFAULTLIB:"libc.lib"','/NODEFAULTLIB:"libcd.lib"','/NODEFAULTLIB:"libcpd.lib"','/NODEFAULTLIB:"libcp.lib"','/NODEFAULTLIB:"msvcrt.lib"', '/NODEFAULTLIB:"msvcrtd.lib"', '/NODEFAULTLIB:"msvcmrt.lib"', '/NODEFAULTLIB:"msvcurt.lib"', '/LARGEADDRESSAWARE']
 
 # # Todo
 # BF_PROFILE_CCFLAGS = ['-pg', '-g ']
index 83e27a855740d214c5ea7a57b7b7ae41f89e697e..a8be162ea97bf42cfc54b4b09f56c9a3082104d0 100644 (file)
@@ -9,10 +9,10 @@ BF_FFMPEG_LIBPATH='${BF_FFMPEG}/lib'
 BF_FFMPEG_LIB = 'avformat-52.lib avcodec-51.lib avdevice-52.lib avutil-49.lib swscale-0.lib'
 
 BF_PYTHON = LIBDIR + '/python'
-BF_PYTHON_VERSION = '3.0'
+BF_PYTHON_VERSION = '3.1'
 BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}'
 BF_PYTHON_BINARY = 'python'
-BF_PYTHON_LIB = 'python30'
+BF_PYTHON_LIB = 'python31'
 BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib'
 
 WITH_BF_OPENAL = False 
@@ -152,7 +152,8 @@ BF_OPENGL_LIB_STATIC = [ '${BF_OPENGL}/lib/libGL.a', '${BF_OPENGL}/lib/libGLU.a'
 CC = 'cl.exe'
 CXX = 'cl.exe'
 
-CCFLAGS = ['/nologo', '/Ob1', '/J', '/W3', '/Gd', '/MT']
+CFLAGS = []
+CCFLAGS = ['/nologo', '/Ob1', '/J', '/W3', '/Gd', '/wd4244', '/wd4305', '/wd4800', '/wd4065', '/wd4267']
 CXXFLAGS = ['/EHsc']
 
 BF_DEBUG_CCFLAGS = ['/Zi', '/FR${TARGET}.sbr']
@@ -172,16 +173,13 @@ WITH_BF_DOCS=False
 
 BF_DEBUG=False
 BF_BSC=False
-CFLAGS = []
-CCFLAGS = ['/nologo', '/Ob1', '/J', '/W3', '/Gd', '/MT']
-CXXFLAGS = ['/EHsc']
 
 if BF_DEBUG:
        BF_NUMJOBS=1
 else:
        BF_NUMJOBS=6
 
-PLATFORM_LINKFLAGS = ['/SUBSYSTEM:CONSOLE','/MACHINE:X64','/ENTRY:mainCRTStartup','/INCREMENTAL:NO','/NODEFAULTLIB:"msvcprt.lib"','/NODEFAULTLIB:"glut32.lib"','/NODEFAULTLIB:"libc.lib"','/NODEFAULTLIB:"libcd.lib"','/NODEFAULTLIB:"libcpd.lib"','/NODEFAULTLIB:"libcp.lib"']
+PLATFORM_LINKFLAGS = ['/SUBSYSTEM:CONSOLE','/MACHINE:X64','/INCREMENTAL:NO','/NODEFAULTLIB:"msvcprt.lib"','/NODEFAULTLIB:"msvcprtd.lib"','/NODEFAULTLIB:"glut32.lib"','/NODEFAULTLIB:"libc.lib"','/NODEFAULTLIB:"libcd.lib"','/NODEFAULTLIB:"libcpd.lib"','/NODEFAULTLIB:"libcp.lib"','/NODEFAULTLIB:"msvcrt.lib"', '/NODEFAULTLIB:"msvcrtd.lib"', '/NODEFAULTLIB:"msvcmrt.lib"', '/NODEFAULTLIB:"msvcurt.lib"']
 
 BF_BUILDDIR = '..\\build\\blender25-win64-vc'
 BF_INSTALLDIR='..\\install\\blender25-win64-vc'
index 78dc65d81124e887aae49247d78964e7ffe954bd..7bdc93fc978c9e3a27b9697dfd5362e8c0c86512 100644 (file)
@@ -18,8 +18,8 @@
 # All rights reserved.
 #
 
-SET(INC ./include ${WINTAB_INC})
-ADD_DEFINITIONS(-DWITH_BINRELOC)
+SET(INC ./include )
+ADD_DEFINITIONS(-DENABLE_BINRELOC)
 FILE(GLOB SRC *.c)
 
 BLENDERLIB(extern_binreloc "${SRC}" "${INC}")
index d303ab3afcc59d32051221ee38c465e32519449c..21343ab4803f567f13b22db05e73029389b4f913 100644 (file)
@@ -27,7 +27,7 @@ DIR = $(OCGDIR)/extern/$(LIBNAME)
 
 include nan_definitions.mk
 
-CPPFLAGS += -I./include
+CPPFLAGS += -DENABLE_BINRELOC -I./include
 
 
 include nan_compile.mk
index bd7fb87b01f75000d0abd2fd2dc0e2d559c36a1c..319cc57ce5555509e864b156985e9717695449e6 100644 (file)
@@ -10,7 +10,7 @@ cflags = []
 if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
     defs += ' WIN32 NDEBUG _WINDOWS _LIB'
     #cflags += ['/MT', '/W3', '/GX', '/O2', '/Op']
-    cflags += ['/MT', '/W3', '/GX', '/Og', '/Ot', '/Ob1', '/Op', '/G6', '/O3']
+    cflags += ['/MT', '/W3', '/GX', '/Og', '/Ot', '/Ob1', '/Op', '/G6', '/O3', '/EHcs']
 elif env['OURPLATFORM']=='win32-mingw':
     defs += ' NDEBUG'
     cflags += ['-O2']
index 13a34bf5598e541c0138ade6debaccf265e70f61..693fee15c91c54553105244ae1cf81f4b37f8bc8 100644 (file)
@@ -10,14 +10,14 @@ incs = '.'
 flags = []
 defs = []
 
-if env['OURPLATFORM'] == 'win32-vc':
+if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
        flags = []
        defs.append('OPJ_STATIC')
 else:
        flags = ['-Wall', '-O3', '-ffast-math', '-std=c99']
 
 oj_env = env.Clone()
-if not env['OURPLATFORM'] == 'win32-vc':
+if not env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
        oj_env.Replace(CCFLAGS = '')
        oj_env.Replace(BF_DEBUG_FLAGS = '')
 
index 697d0b6b575ce6b1e7a06b586ace7e1eaed86c89..71bd00f71eed0bfbedba17ddd4e96aed2771e432 100644 (file)
@@ -35,6 +35,7 @@ ADD_SUBDIRECTORY(decimation)
 ADD_SUBDIRECTORY(iksolver)
 ADD_SUBDIRECTORY(boolop)
 ADD_SUBDIRECTORY(opennl)
+ADD_SUBDIRECTORY(smoke)
 
 IF(WITH_ELBEEM)
   ADD_SUBDIRECTORY(elbeem)
index 995dc56c7d3cebcfa1b5b16367d857bd721a0716..b559ce6978aa7addab0319dd2bd08b2d2eaface8 100644 (file)
@@ -32,7 +32,7 @@ SOURCEDIR = intern
 # include nan_subdirs.mk
 
 ALLDIRS = string ghost guardedalloc moto container memutil
-ALLDIRS += decimation iksolver bsp SoundSystem opennl elbeem boolop
+ALLDIRS += decimation iksolver bsp SoundSystem opennl elbeem boolop smoke
 
 all::
        @for i in $(ALLDIRS); do \
index bb8525d5ce5c89a0da97a30c87995e03961a9543..bdbdc7fd6e93e45364c5356403b4e4839c829422 100644 (file)
@@ -11,7 +11,8 @@ SConscript(['SoundSystem/SConscript',
             'decimation/SConscript',
             'iksolver/SConscript',
             'boolop/SConscript',
-            'opennl/SConscript'])
+            'opennl/SConscript',
+            'smoke/SConscript'])
 
 # NEW_CSG was intended for intern/csg, but
 # getting it to compile is difficult
index 92e80c36cea7ec364e3c29a0ace3f94171176e60..0900ab1db5c53a35468bd8ddda297fc6b77ae5ab 100644 (file)
@@ -10,7 +10,7 @@ defs = 'NOGUI ELBEEM_BLENDER=1'
 if env['WITH_BF_OPENMP']:
     defs += ' PARALLEL'
 
-if env['OURPLATFORM']=='win32-vc':
+if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
     defs += ' USE_MSVC6FIXES'
 incs = env['BF_PNG_INC'] + ' ' + env['BF_ZLIB_INC'] 
 incs += ' extern '
index ce54adb48ee4b913a8fe9a0aeabffb560d5c4914..fee011a70aec6caf290159177975753170a3495d 100644 (file)
@@ -1464,7 +1464,7 @@ void LbmFsgrSolver::initMovingObstacles(bool staticInit) {
                                obj->applyTransformation(targetTime, &mMOIVertices,NULL /* no old normals needed */, 0, mMOIVertices.size(), false );
                        } else {
                                // only do transform update
-                               obj->getMovingPoints(mMOIVertices,pNormals);
+                               obj->getMovingPoints(mMOIVertices,pNormals); // mMOIVertices = mCachedMovPoints
                                mMOIVerticesOld = mMOIVertices;
                                // WARNING - assumes mSimulationTime is global!?
                                obj->applyTransformation(targetTime, &mMOIVertices,pNormals, 0, mMOIVertices.size(), false );
index fcf78d9ad200df42c059426525d2dbebd4e4f832..e5e88502f45a1e55b91a4393fd34faf9680716d0 100644 (file)
@@ -534,11 +534,28 @@ GHOST_SystemX11::processEvent(XEvent *xe)
                                                                      window, data);
                                }
                        } else if (((Atom)xcme.data.l[0]) == m_wm_take_focus) {
+                               XWindowAttributes attr;
+                               Window fwin;
+                               int revert_to;
+
                                /* as ICCCM say, we need reply this event
                                 * with a SetInputFocus, the data[1] have
                                 * the valid timestamp (send by the wm).
+                                *
+                                * Some WM send this event before the
+                                * window is really mapped (for example
+                                * change from virtual desktop), so we need
+                                * to be sure that our windows is mapped
+                                * or this call fail and close blender.
                                 */
-                               XSetInputFocus(m_display, xcme.window, RevertToParent, xcme.data.l[1]);
+                               if (XGetWindowAttributes(m_display, xcme.window, &attr) == True) {
+                                       if (XGetInputFocus(m_display, &fwin, &revert_to) == True) {
+                                               if (attr.map_state == IsViewable) {
+                                                       if (fwin != xcme.window)
+                                                               XSetInputFocus(m_display, xcme.window, RevertToParent, xcme.data.l[1]);
+                                               }
+                                       }
+                               }
                        } else {
                                /* Unknown client message, ignore */
                        }
index 759951802af37414c2d16341aef03e7283415370..366adb3ab8640857e1c2c8cccc91f8506d9955a5 100644 (file)
@@ -117,18 +117,34 @@ GHOST_WindowWin32::GHOST_WindowWin32(
        m_maxPressure(0)
 {
        if (state != GHOST_kWindowStateFullScreen) {
-               // take taskbar into account
                RECT rect;
+               GHOST_TUns32 tw, th; 
+
+               width += GetSystemMetrics(SM_CXSIZEFRAME)*2;
+               height += GetSystemMetrics(SM_CYSIZEFRAME)*2 + GetSystemMetrics(SM_CYCAPTION);
+
+               // take taskbar into account
                SystemParametersInfo(SPI_GETWORKAREA,0,&rect,0);
-               height = rect.bottom - rect.top;
-               width = rect.right - rect.left;
+               th = rect.bottom - rect.top;
+               tw = rect.right - rect.left;
+
+               if(tw < width)
+               {
+                       width = tw;
+                       left = rect.left;
+               }
+               if(th < height)
+               {
+                       height = th;
+                       top = rect.top;
+               }
 
                m_hWnd = ::CreateWindow(
                        s_windowClassName,                      // pointer to registered class name
                        title,                                          // pointer to window name
                        WS_OVERLAPPEDWINDOW,            // window style
-                       rect.left,                                      // horizontal position of window
-                       rect.top,                                       // vertical position of window
+                       left,                                   // horizontal position of window
+                       top,                                    // vertical position of window
                        width,                                          // window width
                        height,                                         // window height
                        0,                                                      // handle to parent or owner window
old mode 100755 (executable)
new mode 100644 (file)
similarity index 68%
rename from release/beos-5.0-i386/specific.sh
rename to intern/smoke/CMakeLists.txt
index 9ce063b..90768e5
@@ -1,7 +1,4 @@
-#!/bin/sh
-#
 # $Id$
-#
 # ***** BEGIN GPL LICENSE BLOCK *****
 #
 # This program is free software; you can redistribute it and/or
 # along with this program; if not, write to the Free Software Foundation,
 # Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #
-# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+# The Original Code is Copyright (C) 2006, Blender Foundation
 # All rights reserved.
 #
 # The Original Code is: all of this file.
 #
-# Contributor(s): none yet.
+# Contributor(s): Daniel Genrich
 #
 # ***** END GPL LICENSE BLOCK *****
-#
-# OS specific stuff for the package, only to be executed by ../Makefile
 
-# Add Python .so to package
-cp -f $NAN_PYTHON/lib/libpython$NAN_PYTHON_VERSION.so $DISTDIR/
+SET(INC ${PNG_INC} ${ZLIB_INC} intern ../../extern/bullet2/src ../memutil ../guardealloc)
+# ${FFTW3_INC}
+
+FILE(GLOB SRC intern/*.cpp)
+
+IF(WITH_OPENMP)
+    ADD_DEFINITIONS(-DPARALLEL=1)
+ENDIF(WITH_OPENMP)
+
 
-# And create a drag'n'drop symlink for it
-cd $DISTDIR && ln -s /boot/home/config/lib Drag_libpython$NAN_PYTHON_VERSION.so_here
+BLENDERLIB(bf_smoke "${SRC}" "${INC}")
+#, libtype='blender', priority = 0 )
diff --git a/intern/smoke/Makefile b/intern/smoke/Makefile
new file mode 100644 (file)
index 0000000..e5144a9
--- /dev/null
@@ -0,0 +1,54 @@
+# -*- mode: gnumakefile; tab-width: 8; indent-tabs-mode: t; -*-
+# vim: tabstop=8
+#
+# $Id$
+#
+# ***** 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+# All rights reserved.
+#
+# The Original Code is: all of this file.
+#
+# Contributor(s): Hans Lambermont, GSR
+#
+# ***** END GPL LICENSE BLOCK *****
+# smoke main makefile.
+#
+
+include nan_definitions.mk
+
+unexport NAN_QUIET
+
+LIBNAME = smoke
+SOURCEDIR = intern/$(LIBNAME)
+DIR = $(OCGDIR)/$(SOURCEDIR)
+DIRS = intern
+#not ready yet TESTDIRS = test
+
+include nan_subdirs.mk
+
+install: $(ALL_OR_DEBUG)
+       @[ -d $(NAN_SMOKE) ] || mkdir $(NAN_SMOKE)
+       @[ -d $(NAN_SMOKE)/include ] || mkdir $(NAN_SMOKE)/include
+       @[ -d $(NAN_SMOKE)/lib/$(DEBUG_DIR) ] || mkdir $(NAN_SMOKE)/lib/$(DEBUG_DIR)
+       @../tools/cpifdiff.sh $(DIR)/$(DEBUG_DIR)lib$(LIBNAME).a $(NAN_SMOKE)/lib/$(DEBUG_DIR)
+ifeq ($(OS),darwin)
+       ranlib $(NAN_SMOKE)/lib/$(DEBUG_DIR)lib$(LIBNAME).a
+endif
+       @../tools/cpifdiff.sh extern/*.h $(NAN_SMOKE)/include/
+
diff --git a/intern/smoke/SConscript b/intern/smoke/SConscript
new file mode 100644 (file)
index 0000000..c427764
--- /dev/null
@@ -0,0 +1,15 @@
+#!/usr/bin/python
+Import ('env')
+
+sources = env.Glob('intern/*.cpp')
+
+defs = ''
+
+if env['WITH_BF_OPENMP']:
+    defs += ' PARALLEL=1'
+
+incs = env['BF_PNG_INC'] + ' ' + env['BF_ZLIB_INC'] 
+incs += ' intern ../../extern/bullet2/src ../memutil ../guardealloc '
+# incs += env['BF_FFTW3_INC'] 
+
+env.BlenderLib ('bf_smoke', sources, Split(incs), Split(defs), libtype=['intern'], priority=[40] )
diff --git a/intern/smoke/extern/smoke_API.h b/intern/smoke/extern/smoke_API.h
new file mode 100644 (file)
index 0000000..b7819d0
--- /dev/null
@@ -0,0 +1,62 @@
+/**
+ * $Id$
+ *
+ * ***** 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2009 by Daniel Genrich
+ * All rights reserved.
+ *
+ * Contributor(s): None
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef SMOKE_API_H_
+#define SMOKE_API_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct FLUID_3D *smoke_init(int *res, int amplify, float *p0, float *p1, float dt);
+void smoke_free(struct FLUID_3D *fluid);
+
+void smoke_initBlenderRNA(struct FLUID_3D *fluid, float *alpha, float *beta);
+
+void smoke_step(struct FLUID_3D *fluid);
+
+float *smoke_get_density(struct FLUID_3D *fluid);
+float *smoke_get_bigdensity(struct FLUID_3D *fluid);
+float *smoke_get_heat(struct FLUID_3D *fluid);
+float *smoke_get_velocity_x(struct FLUID_3D *fluid);
+float *smoke_get_velocity_y(struct FLUID_3D *fluid);
+float *smoke_get_velocity_z(struct FLUID_3D *fluid);
+
+unsigned char *smoke_get_obstacle(struct FLUID_3D *fluid);
+
+size_t smoke_get_index(int x, int max_x, int y, int max_y, int z);
+size_t smoke_get_index2d(int x, int max_x, int y);
+
+void smoke_set_noise(struct FLUID_3D *fluid, int type);
+
+void smoke_get_bigres(struct FLUID_3D *fluid, int *res);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* SMOKE_API_H_ */
\ No newline at end of file
diff --git a/intern/smoke/intern/EIGENVALUE_HELPER.h b/intern/smoke/intern/EIGENVALUE_HELPER.h
new file mode 100644 (file)
index 0000000..6ff61c5
--- /dev/null
@@ -0,0 +1,47 @@
+//////////////////////////////////////////////////////////////////////
+// This file is part of Wavelet Turbulence.
+// 
+// Wavelet Turbulence 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 3 of the License, or
+// (at your option) any later version.
+// 
+// Wavelet Turbulence 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 Wavelet Turbulence.  If not, see <http://www.gnu.org/licenses/>.
+// 
+// Copyright 2008 Theodore Kim and Nils Thuerey
+// 
+//////////////////////////////////////////////////////////////////////
+// Helper function, compute eigenvalues of 3x3 matrix
+//////////////////////////////////////////////////////////////////////
+
+#include "tnt/jama_eig.h"
+
+//////////////////////////////////////////////////////////////////////
+// eigenvalues of 3x3 non-symmetric matrix
+//////////////////////////////////////////////////////////////////////
+int inline computeEigenvalues3x3(
+               float dout[3], 
+               float a[3][3])
+{
+  TNT::Array2D<float> A = TNT::Array2D<float>(3,3, &a[0][0]);
+  TNT::Array1D<float> eig = TNT::Array1D<float>(3);
+  TNT::Array1D<float> eigImag = TNT::Array1D<float>(3);
+  JAMA::Eigenvalue<float> jeig = JAMA::Eigenvalue<float>(A);
+  jeig.getRealEigenvalues(eig);
+
+  // complex ones
+  jeig.getImagEigenvalues(eigImag);
+  dout[0]  = sqrt(eig[0]*eig[0] + eigImag[0]*eigImag[0]);
+  dout[1]  = sqrt(eig[1]*eig[1] + eigImag[1]*eigImag[1]);
+  dout[2]  = sqrt(eig[2]*eig[2] + eigImag[2]*eigImag[2]);
+  return 0;
+}
+
+#undef rfabs 
+#undef ROT
diff --git a/intern/smoke/intern/FFT_NOISE.h b/intern/smoke/intern/FFT_NOISE.h
new file mode 100644 (file)
index 0000000..9ae9682
--- /dev/null
@@ -0,0 +1,178 @@
+//////////////////////////////////////////////////////////////////////
+// This file is part of Wavelet Turbulence.
+// 
+// Wavelet Turbulence 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 3 of the License, or
+// (at your option) any later version.
+// 
+// Wavelet Turbulence 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 Wavelet Turbulence.  If not, see <http://www.gnu.org/licenses/>.
+// 
+// Copyright 2008 Theodore Kim and Nils Thuerey
+// 
+/////////////////////////////////////////////////////////////////////////
+//
+
+#ifndef FFT_NOISE_H_
+#define FFT_NOISE_H_
+
+#if 0
+#include <iostream>
+#include <fftw3.h>
+#include <MERSENNETWISTER.h>
+
+#include "WAVELET_NOISE.h"
+
+#ifndef M_PI
+#define M_PI 3.14159265
+#endif
+
+/////////////////////////////////////////////////////////////////////////
+// shift spectrum to the format that FFTW expects
+/////////////////////////////////////////////////////////////////////////
+static void shift3D(float*& field, int xRes, int yRes, int zRes)
+{
+  int xHalf = xRes / 2;
+  int yHalf = yRes / 2;
+  int zHalf = zRes / 2;
+  int slabSize = xRes * yRes;
+  for (int z = 0; z < zHalf; z++)
+    for (int y = 0; y < yHalf; y++)
+      for (int x = 0; x < xHalf; x++)
+      {
+        int index = x + y * xRes + z * xRes * yRes;
+        float temp;
+        int xSwap = xHalf;
+        int ySwap = yHalf * xRes;
+        int zSwap = zHalf * xRes * yRes;
+        
+        // [0,0,0] to [1,1,1]
+        temp = field[index];
+        field[index] = field[index + xSwap + ySwap + zSwap];
+        field[index + xSwap + ySwap + zSwap] = temp;
+
+        // [1,0,0] to [0,1,1]
+        temp = field[index + xSwap];
+        field[index + xSwap] = field[index + ySwap + zSwap];
+        field[index + ySwap + zSwap] = temp;
+
+        // [0,1,0] to [1,0,1]
+        temp = field[index + ySwap];
+        field[index + ySwap] = field[index + xSwap + zSwap];
+        field[index + xSwap + zSwap] = temp;
+        
+        // [0,0,1] to [1,1,0]
+        temp = field[index + zSwap];
+        field[index + zSwap] = field[index + xSwap + ySwap];
+        field[index + xSwap + ySwap] = temp;
+      }
+}
+
+static void generatTile_FFT(float* const noiseTileData, std::string filename)
+{
+       if (loadTile(noiseTileData, filename)) return;
+       
+       int res = NOISE_TILE_SIZE;
+       int xRes = res;
+       int yRes = res;
+       int zRes = res;
+       int totalCells = xRes * yRes * zRes;
+       
+       // create and shift the filter
+       float* filter = new float[totalCells];
+       for (int z = 0; z < zRes; z++)
+               for (int y = 0; y < yRes; y++)
+                       for (int x = 0; x < xRes; x++)
+                       {
+                               int index = x + y * xRes + z * xRes * yRes;
+                               float diff[] = {abs(x - xRes/2), 
+                               abs(y - yRes/2), 
+                               abs(z - zRes/2)};
+                               float radius = sqrtf(diff[0] * diff[0] + 
+                               diff[1] * diff[1] + 
+                               diff[2] * diff[2]) / (xRes / 2);
+                               radius *= M_PI;
+                               float H = cos((M_PI / 2.0f) * log(4.0f * radius / M_PI) / log(2.0f));
+                               H = H * H;
+                               float filtered = H;
+                               
+                               // clamp everything outside the wanted band
+                               if (radius >= M_PI / 2.0f)
+                                       filtered = 0.0f;
+                               
+                               // make sure to capture all low frequencies
+                               if (radius <= M_PI / 4.0f)
+                                       filtered = 1.0f;
+                               
+                               filter[index] = filtered;
+                       }
+       shift3D(filter, xRes, yRes, zRes);
+       
+       // create the noise
+       float* noise = new float[totalCells];
+       int index = 0;
+       MTRand twister;
+       for (int z = 0; z < zRes; z++)
+       for (int y = 0; y < yRes; y++)
+         for (int x = 0; x < xRes; x++, index++)
+               noise[index] = twister.randNorm();
+       
+       // create padded field
+       fftw_complex* forward = (fftw_complex*)fftw_malloc(sizeof(fftw_complex) * totalCells);
+       
+       // init padded field
+       index = 0;
+       for (int z = 0; z < zRes; z++)
+       for (int y = 0; y < yRes; y++)
+         for (int x = 0; x < xRes; x++, index++)
+         {
+               forward[index][0] = noise[index];
+               forward[index][1] = 0.0f;
+         }
+       
+       // forward FFT 
+       fftw_complex* backward = (fftw_complex*)fftw_malloc(sizeof(fftw_complex) * totalCells);
+       fftw_plan forwardPlan = fftw_plan_dft_3d(xRes, yRes, zRes, forward, backward, FFTW_FORWARD, FFTW_ESTIMATE);  
+       fftw_execute(forwardPlan);
+       fftw_destroy_plan(forwardPlan);
+       
+       // apply filter
+       index = 0;
+       for (int z = 0; z < zRes; z++)
+               for (int y = 0; y < yRes; y++)
+                       for (int x = 0; x < xRes; x++, index++)
+                       {
+                               backward[index][0] *= filter[index];
+                               backward[index][1] *= filter[index];
+                       }
+       
+       // backward FFT
+       fftw_plan backwardPlan = fftw_plan_dft_3d(xRes, yRes, zRes, backward, forward, FFTW_BACKWARD, FFTW_ESTIMATE);  
+       fftw_execute(backwardPlan);
+       fftw_destroy_plan(backwardPlan);
+       
+       // subtract out the low frequency components
+       index = 0;
+       for (int z = 0; z < zRes; z++)
+               for (int y = 0; y < yRes; y++)
+                       for (int x = 0; x < xRes; x++, index++)
+                               noise[index] -= forward[index][0] / totalCells;
+
+       // save out the noise tile
+       saveTile(noise, filename);
+       
+       fftw_free(forward);
+       fftw_free(backward);
+       delete[] filter;
+       delete[] noise;
+}
+
+#endif
+
+#endif /* FFT_NOISE_H_ */
diff --git a/intern/smoke/intern/FLUID_3D.cpp b/intern/smoke/intern/FLUID_3D.cpp
new file mode 100644 (file)
index 0000000..2822fca
--- /dev/null
@@ -0,0 +1,672 @@
+//////////////////////////////////////////////////////////////////////
+// This file is part of Wavelet Turbulence.
+//
+// Wavelet Turbulence 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 3 of the License, or
+// (at your option) any later version.
+//
+// Wavelet Turbulence 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 Wavelet Turbulence.  If not, see <http://www.gnu.org/licenses/>.
+//
+// Copyright 2008 Theodore Kim and Nils Thuerey
+//
+// FLUID_3D.cpp: implementation of the FLUID_3D class.
+//
+//////////////////////////////////////////////////////////////////////
+
+#include "FLUID_3D.h"
+#include "IMAGE.h"
+#include <INTERPOLATE.h>
+#include "SPHERE.h"
+#include <zlib.h>
+
+// boundary conditions of the fluid domain
+#define DOMAIN_BC_FRONT  1
+#define DOMAIN_BC_TOP    0
+#define DOMAIN_BC_LEFT   1
+#define DOMAIN_BC_BACK   DOMAIN_BC_FRONT
+#define DOMAIN_BC_BOTTOM DOMAIN_BC_TOP
+#define DOMAIN_BC_RIGHT  DOMAIN_BC_LEFT
+
+//////////////////////////////////////////////////////////////////////
+// Construction/Destruction
+//////////////////////////////////////////////////////////////////////
+
+FLUID_3D::FLUID_3D(int *res, int amplify, float *p0, float dt) :
+       _xRes(res[0]), _yRes(res[1]), _zRes(res[2]), _res(0.0f), _dt(dt)
+{
+       // set simulation consts
+       // _dt = dt; // 0.10
+       
+       // start point of array
+       _p0[0] = p0[0];
+       _p0[1] = p0[1];
+       _p0[2] = p0[2];
+
+       _iterations = 100;
+       _tempAmb = 0; 
+       _heatDiffusion = 1e-3;
+       _vorticityEps = 2.0;
+       _totalTime = 0.0f;
+       _totalSteps = 0;
+       _res = Vec3Int(_xRes,_yRes,_zRes);
+       _maxRes = MAX3(_xRes, _yRes, _zRes);
+       
+       // initialize wavelet turbulence
+       _wTurbulence = new WTURBULENCE(_res[0],_res[1],_res[2], amplify);
+       
+       // scale the constants according to the refinement of the grid
+       _dx = 1.0f / (float)_maxRes;
+       float scaling = 64.0f / _maxRes;
+       scaling = (scaling < 1.0f) ? 1.0f : scaling;
+       _vorticityEps /= scaling;
+
+       // allocate arrays
+       _totalCells   = _xRes * _yRes * _zRes;
+       _slabSize = _xRes * _yRes;
+       _divergence   = new float[_totalCells];
+       _pressure     = new float[_totalCells];
+       _xVelocity    = new float[_totalCells];
+       _yVelocity    = new float[_totalCells];
+       _zVelocity    = new float[_totalCells];
+       _xVelocityOld = new float[_totalCells];
+       _yVelocityOld = new float[_totalCells];
+       _zVelocityOld = new float[_totalCells];
+       _xForce       = new float[_totalCells];
+       _yForce       = new float[_totalCells];
+       _zForce       = new float[_totalCells];
+       _vorticity    = new float[_totalCells];
+       _density      = new float[_totalCells];
+       _densityOld   = new float[_totalCells];
+       _heat         = new float[_totalCells];
+       _heatOld      = new float[_totalCells];
+       _residual     = new float[_totalCells];
+       _direction    = new float[_totalCells];
+       _q            = new float[_totalCells];
+       _obstacles    = new unsigned char[_totalCells];
+       _xVorticity   = new float[_totalCells];
+       _yVorticity   = new float[_totalCells];
+       _zVorticity   = new float[_totalCells];
+
+       for (int x = 0; x < _totalCells; x++)
+       {
+               _density[x]      = 0.0f;
+               _densityOld[x]   = 0.0f;
+               _heat[x]         = 0.0f;
+               _heatOld[x]      = 0.0f;
+               _divergence[x]   = 0.0f;
+               _pressure[x]     = 0.0f;
+               _xVelocity[x]    = 0.0f;
+               _yVelocity[x]    = 0.0f;
+               _zVelocity[x]    = 0.0f;
+               _xVelocityOld[x] = 0.0f;
+               _yVelocityOld[x] = 0.0f;
+               _zVelocityOld[x] = 0.0f;
+               _xForce[x]       = 0.0f;
+               _yForce[x]       = 0.0f;
+               _zForce[x]       = 0.0f;
+               _xVorticity[x]   = 0.0f;
+               _yVorticity[x]   = 0.0f;
+               _zVorticity[x]   = 0.0f;
+               _residual[x]     = 0.0f;
+               _obstacles[x]    = false;
+       }
+
+       // set side obstacles
+  int index;
+  for (int y = 0; y < _yRes; y++)
+    for (int x = 0; x < _xRes; x++)
+    {
+      // front slab
+      index = x + y * _xRes;
+      if(DOMAIN_BC_FRONT==1) _obstacles[index] = 1;
+
+      // back slab
+      index += _totalCells - _slabSize;
+      if(DOMAIN_BC_BACK==1) _obstacles[index] = 1;
+    }
+  for (int z = 0; z < _zRes; z++)
+    for (int x = 0; x < _xRes; x++)
+    {
+      // bottom slab
+      index = x + z * _slabSize;
+      if(DOMAIN_BC_BOTTOM==1) _obstacles[index] = 1;
+
+      // top slab
+      index += _slabSize - _xRes;
+      if(DOMAIN_BC_TOP==1) _obstacles[index] = 1;
+    }
+  for (int z = 0; z < _zRes; z++)
+    for (int y = 0; y < _yRes; y++)
+    {
+      // left slab
+      index = y * _xRes + z * _slabSize;
+      if(DOMAIN_BC_LEFT==1) _obstacles[index] = 1;
+
+      // right slab
+      index += _xRes - 1;
+      if(DOMAIN_BC_RIGHT==1) _obstacles[index] = 1;
+    }
+
+       /*
+       SPHERE *obsSphere = NULL;
+       obsSphere = new SPHERE(0.375,0.5,0.375, 0.1); // for 4 to 3 domain
+       addObstacle(obsSphere);
+       delete obsSphere;
+       */
+}
+
+FLUID_3D::~FLUID_3D()
+{
+       if (_divergence) delete[] _divergence;
+       if (_pressure) delete[] _pressure;
+       if (_xVelocity) delete[] _xVelocity;
+       if (_yVelocity) delete[] _yVelocity;
+       if (_zVelocity) delete[] _zVelocity;
+       if (_xVelocityOld) delete[] _xVelocityOld;
+       if (_yVelocityOld) delete[] _yVelocityOld;
+       if (_zVelocityOld) delete[] _zVelocityOld;
+       if (_xForce) delete[] _xForce;
+       if (_yForce) delete[] _yForce;
+       if (_zForce) delete[] _zForce;
+       if (_residual) delete[] _residual;
+       if (_direction) delete[] _direction;
+       if (_q)       delete[] _q;
+       if (_density) delete[] _density;
+       if (_densityOld) delete[] _densityOld;
+       if (_heat) delete[] _heat;
+       if (_heatOld) delete[] _heatOld;
+       if (_xVorticity) delete[] _xVorticity;
+       if (_yVorticity) delete[] _yVorticity;
+       if (_zVorticity) delete[] _zVorticity;
+       if (_vorticity) delete[] _vorticity;
+       if (_obstacles) delete[] _obstacles;
+    if (_wTurbulence) delete _wTurbulence;
+
+    printf("deleted fluid\n");
+}
+
+// init direct access functions from blender
+void FLUID_3D::initBlenderRNA(float *alpha, float *beta)
+{
+       _alpha = alpha;
+       _beta = beta;
+       
+       // XXX TODO DEBUG
+       // *_alpha = 0;
+       // *_beta = 0;
+}
+
+//////////////////////////////////////////////////////////////////////
+// step simulation once
+//////////////////////////////////////////////////////////////////////
+void FLUID_3D::step()
+{
+       // wipe forces
+       for (int i = 0; i < _totalCells; i++)
+               _xForce[i] = _yForce[i] = _zForce[i] = 0.0f;
+
+       wipeBoundaries();
+
+       // run the solvers
+  addVorticity();
+  addBuoyancy(_heat, _density);
+       addForce();
+       project();
+  diffuseHeat();
+
+       // advect everything
+       advectMacCormack();
+
+       if(_wTurbulence) {
+               _wTurbulence->stepTurbulenceFull(_dt/_dx,
+                               _xVelocity, _yVelocity, _zVelocity, _obstacles);
+               // _wTurbulence->stepTurbulenceReadable(_dt/_dx,
+               //  _xVelocity, _yVelocity, _zVelocity, _obstacles);
+       }
+/*
+ // no file output
+  float *src = _density;
+       string prefix = string("./original.preview/density_fullxy_");
+       writeImageSliceXY(src,_res, _res[2]/2, prefix, _totalSteps);
+*/
+       // artificial damping -- this is necessary because we use a
+  // collated grid, and at very coarse grid resolutions, banding
+  // artifacts can occur
+       artificialDamping(_xVelocity);
+       artificialDamping(_yVelocity);
+       artificialDamping(_zVelocity);
+/*
+// no file output
+  string pbrtPrefix = string("./pbrt/density_small_");
+  IMAGE::dumpPBRT(_totalSteps, pbrtPrefix, _density, _res[0],_res[1],_res[2]);
+  */
+       _totalTime += _dt;
+       _totalSteps++;
+}
+
+//////////////////////////////////////////////////////////////////////
+// helper function to dampen co-located grid artifacts of given arrays in intervals
+// (only needed for velocity, strength (w) depends on testcase...
+//////////////////////////////////////////////////////////////////////
+void FLUID_3D::artificialDamping(float* field) {
+       const float w = 0.9;
+       if(_totalSteps % 4 == 1) {
+               for (int z = 1; z < _res[2]-1; z++)
+                       for (int y = 1; y < _res[1]-1; y++)
+                               for (int x = 1+(y+z)%2; x < _res[0]-1; x+=2) {
+                                       const int index = x + y*_res[0] + z * _slabSize;
+                                       field[index] = (1-w)*field[index] + 1./6. * w*(
+                                                       field[index+1] + field[index-1] +
+                                                       field[index+_res[0]] + field[index-_res[0]] +
+                                                       field[index+_slabSize] + field[index-_slabSize] );
+                               }
+       }
+       if(_totalSteps % 4 == 3) {
+               for (int z = 1; z < _res[2]-1; z++)
+                       for (int y = 1; y < _res[1]-1; y++)
+                               for (int x = 1+(y+z+1)%2; x < _res[0]-1; x+=2) {
+                                       const int index = x + y*_res[0] + z * _slabSize;
+                                       field[index] = (1-w)*field[index] + 1./6. * w*(
+                                                       field[index+1] + field[index-1] +
+                                                       field[index+_res[0]] + field[index-_res[0]] +
+                                                       field[index+_slabSize] + field[index-_slabSize] );
+                               }
+       }
+}
+
+//////////////////////////////////////////////////////////////////////
+// copy out the boundary in all directions
+//////////////////////////////////////////////////////////////////////
+void FLUID_3D::copyBorderAll(float* field)
+{
+       int index;
+       for (int y = 0; y < _yRes; y++)
+               for (int x = 0; x < _xRes; x++)
+               {
+                       // front slab
+                       index = x + y * _xRes;
+                       field[index] = field[index + _slabSize];
+
+                       // back slab
+                       index += _totalCells - _slabSize;
+                       field[index] = field[index - _slabSize];
+    }
+
+       for (int z = 0; z < _zRes; z++)
+               for (int x = 0; x < _xRes; x++)
+    {
+                       // bottom slab
+                       index = x + z * _slabSize;
+                       field[index] = field[index + _xRes];
+
+                       // top slab
+                       index += _slabSize - _xRes;
+                       field[index] = field[index - _xRes];
+    }
+
+       for (int z = 0; z < _zRes; z++)
+               for (int y = 0; y < _yRes; y++)
+    {
+                       // left slab
+                       index = y * _xRes + z * _slabSize;
+                       field[index] = field[index + 1];
+
+                       // right slab
+                       index += _xRes - 1;
+                       field[index] = field[index - 1];
+               }
+}
+
+//////////////////////////////////////////////////////////////////////
+// wipe boundaries of velocity and density
+//////////////////////////////////////////////////////////////////////
+void FLUID_3D::wipeBoundaries()
+{
+       setZeroBorder(_xVelocity, _res);
+       setZeroBorder(_yVelocity, _res);
+       setZeroBorder(_zVelocity, _res);
+       setZeroBorder(_density, _res);
+}
+
+//////////////////////////////////////////////////////////////////////
+// add forces to velocity field
+//////////////////////////////////////////////////////////////////////
+void FLUID_3D::addForce()
+{
+       for (int i = 0; i < _totalCells; i++)
+       {
+               _xVelocity[i] += _dt * _xForce[i];
+               _yVelocity[i] += _dt * _yForce[i];
+               _zVelocity[i] += _dt * _zForce[i];
+       }
+}
+
+//////////////////////////////////////////////////////////////////////
+// project into divergence free field
+//////////////////////////////////////////////////////////////////////
+void FLUID_3D::project()
+{
+       int index, x, y, z;
+       setObstacleBoundaries();
+
+       // copy out the boundaries
+       if(DOMAIN_BC_LEFT == 0)  setNeumannX(_xVelocity, _res);
+       else setZeroX(_xVelocity, _res);
+
+       if(DOMAIN_BC_TOP == 0)   setNeumannY(_yVelocity, _res);
+       else setZeroY(_yVelocity, _res);
+
+       if(DOMAIN_BC_FRONT == 0) setNeumannZ(_zVelocity, _res);
+       else setZeroZ(_zVelocity, _res);
+
+       // calculate divergence
+       index = _slabSize + _xRes + 1;
+       for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes)
+               for (y = 1; y < _yRes - 1; y++, index += 2)
+                       for (x = 1; x < _xRes - 1; x++, index++)
+                       {
+                               float xright = _xVelocity[index + 1];
+                               float xleft  = _xVelocity[index - 1];
+                               float yup    = _yVelocity[index + _xRes];
+                               float ydown  = _yVelocity[index - _xRes];
+                               float ztop   = _zVelocity[index + _slabSize];
+                               float zbottom = _zVelocity[index - _slabSize];
+
+                               if(_obstacles[index+1]) xright = - _xVelocity[index];
+                               if(_obstacles[index-1]) xleft  = - _xVelocity[index];
+                               if(_obstacles[index+_xRes]) yup    = - _yVelocity[index];
+                               if(_obstacles[index-_xRes]) ydown  = - _yVelocity[index];
+                               if(_obstacles[index+_slabSize]) ztop    = - _zVelocity[index];
+                               if(_obstacles[index-_slabSize]) zbottom = - _zVelocity[index];
+
+                               _divergence[index] = -_dx * 0.5f * (
+                                               xright - xleft +
+                                               yup - ydown +
+                                               ztop - zbottom );
+                               _pressure[index] = 0.0f;
+                       }
+       copyBorderAll(_pressure);
+
+       // solve Poisson equation
+       solvePressure(_pressure, _divergence, _obstacles);
+
+       // project out solution
+       float invDx = 1.0f / _dx;
+       index = _slabSize + _xRes + 1;
+       for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes)
+               for (y = 1; y < _yRes - 1; y++, index += 2)
+                       for (x = 1; x < _xRes - 1; x++, index++)
+                       {
+                               _xVelocity[index] -= 0.5f * (_pressure[index + 1]     - _pressure[index - 1])     * invDx;
+                               _yVelocity[index] -= 0.5f * (_pressure[index + _xRes]  - _pressure[index - _xRes]) * invDx;
+                               _zVelocity[index] -= 0.5f * (_pressure[index + _slabSize] - _pressure[index - _slabSize]) * invDx;
+                       }
+}
+
+//////////////////////////////////////////////////////////////////////
+// diffuse heat
+//////////////////////////////////////////////////////////////////////
+void FLUID_3D::diffuseHeat()
+{
+       SWAP_POINTERS(_heat, _heatOld);
+
+       copyBorderAll(_heatOld);
+       solveHeat(_heat, _heatOld, _obstacles);
+
+       // zero out inside obstacles
+       for (int x = 0; x < _totalCells; x++)
+               if (_obstacles[x])
+                       _heat[x] = 0.0f;
+}
+
+//////////////////////////////////////////////////////////////////////
+// stamp an obstacle in the _obstacles field
+//////////////////////////////////////////////////////////////////////
+void FLUID_3D::addObstacle(OBSTACLE* obstacle)
+{
+       int index = 0;
+       for (int z = 0; z < _zRes; z++)
+               for (int y = 0; y < _yRes; y++)
+                       for (int x = 0; x < _xRes; x++, index++)
+                               if (obstacle->inside(x * _dx, y * _dx, z * _dx)) {
+                                       _obstacles[index] = true;
+        }
+}
+
+//////////////////////////////////////////////////////////////////////
+// calculate the obstacle directional types
+//////////////////////////////////////////////////////////////////////
+void FLUID_3D::setObstacleBoundaries()
+{
+       // cull degenerate obstacles , move to addObstacle?
+       for (int z = 1, index = _slabSize + _xRes + 1;
+                       z < _zRes - 1; z++, index += 2 * _xRes)
+               for (int y = 1; y < _yRes - 1; y++, index += 2)
+                       for (int x = 1; x < _xRes - 1; x++, index++)
+                               if (_obstacles[index] != EMPTY)
+                               {
+                                       const int top   = _obstacles[index + _slabSize];
+                                       const int bottom= _obstacles[index - _slabSize];
+                                       const int up    = _obstacles[index + _xRes];
+                                       const int down  = _obstacles[index - _xRes];
+                                       const int left  = _obstacles[index - 1];
+                                       const int right = _obstacles[index + 1];
+
+                                       int counter = 0;
+                                       if (up)    counter++;
+                                       if (down)  counter++;
+                                       if (left)  counter++;
+                                       if (right) counter++;
+                                       if (top)  counter++;
+                                       if (bottom) counter++;
+
+                                       if (counter < 3)
+                                               _obstacles[index] = EMPTY;
+                               }
+
+       // tag remaining obstacle blocks
+       for (int z = 1, index = _slabSize + _xRes + 1;
+                       z < _zRes - 1; z++, index += 2 * _xRes)
+               for (int y = 1; y < _yRes - 1; y++, index += 2)
+                       for (int x = 1; x < _xRes - 1; x++, index++)
+               {
+                       // could do cascade of ifs, but they are a pain
+                       if (_obstacles[index] != EMPTY)
+                       {
+                               const int top   = _obstacles[index + _slabSize];
+                               const int bottom= _obstacles[index - _slabSize];
+                               const int up    = _obstacles[index + _xRes];
+                               const int down  = _obstacles[index - _xRes];
+                               const int left  = _obstacles[index - 1];
+                               const int right = _obstacles[index + 1];
+
+                               // unused
+                               // const bool fullz = (top && bottom);
+                               // const bool fully = (up && down);
+                               //const bool fullx = (left && right);
+
+                               _xVelocity[index] =
+                               _yVelocity[index] =
+                               _zVelocity[index] = 0.0f;
+                               _pressure[index] = 0.0f;
+
+                               // average pressure neighbors
+                               float pcnt = 0.;
+                               if (left && !right) {
+                                       _pressure[index] += _pressure[index + 1];
+                                       pcnt += 1.;
+                               }
+                               if (!left && right) {
+                                       _pressure[index] += _pressure[index - 1];
+                                       pcnt += 1.;
+                               }
+                               if (up && !down) {
+                                       _pressure[index] += _pressure[index - _xRes];
+                                       pcnt += 1.;
+                               }
+                               if (!up && down) {
+                                       _pressure[index] += _pressure[index + _xRes];
+                                       pcnt += 1.;
+                               }
+                               if (top && !bottom) {
+                                       _pressure[index] += _pressure[index - _xRes];
+                                       pcnt += 1.;
+                               }
+                               if (!top && bottom) {
+                                       _pressure[index] += _pressure[index + _xRes];
+                                       pcnt += 1.;
+                               }
+                               _pressure[index] /= pcnt;
+
+                               // TODO? set correct velocity bc's
+                               // velocities are only set to zero right now
+                               // this means it's not a full no-slip boundary condition
+                               // but a "half-slip" - still looks ok right now
+                       }
+               }
+}
+
+//////////////////////////////////////////////////////////////////////
+// add buoyancy forces
+//////////////////////////////////////////////////////////////////////
+void FLUID_3D::addBuoyancy(float *heat, float *density)
+{
+       int index = 0;
+
+       for (int z = 0; z < _zRes; z++)
+               for (int y = 0; y < _yRes; y++)
+                       for (int x = 0; x < _xRes; x++, index++)
+                       {
+                               _zForce[index] += *_alpha * density[index] + (*_beta * (heat[index] - _tempAmb)); // DG: was _yForce, changed for Blender
+                       }
+}
+
+//////////////////////////////////////////////////////////////////////
+// add vorticity to the force field
+//////////////////////////////////////////////////////////////////////
+void FLUID_3D::addVorticity()
+{
+       int x,y,z,index;
+       if(_vorticityEps<=0.) return;
+
+       // calculate vorticity
+       float gridSize = 0.5f / _dx;
+       index = _slabSize + _xRes + 1;
+       for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes)
+               for (y = 1; y < _yRes - 1; y++, index += 2)
+                       for (x = 1; x < _xRes - 1; x++, index++)
+                       {
+                               int up    = _obstacles[index + _xRes] ? index : index + _xRes;
+                               int down  = _obstacles[index - _xRes] ? index : index - _xRes;
+                               float dy  = (up == index || down == index) ? 1.0f / _dx : gridSize;
+                               int out   = _obstacles[index + _slabSize] ? index : index + _slabSize;
+                               int in    = _obstacles[index - _slabSize] ? index : index - _slabSize;
+                               float dz  = (out == index || in == index) ? 1.0f / _dx : gridSize;
+                               int right = _obstacles[index + 1] ? index : index + 1;
+                               int left  = _obstacles[index - 1] ? index : index - 1;
+                               float dx  = (right == index || right == index) ? 1.0f / _dx : gridSize;
+
+                               _xVorticity[index] = (_zVelocity[up] - _zVelocity[down]) * dy + (-_yVelocity[out] + _yVelocity[in]) * dz;
+                               _yVorticity[index] = (_xVelocity[out] - _xVelocity[in]) * dz + (-_zVelocity[right] + _zVelocity[left]) * dx;
+                               _zVorticity[index] = (_yVelocity[right] - _yVelocity[left]) * dx + (-_xVelocity[up] + _xVelocity[down])* dy;
+
+                               _vorticity[index] = sqrtf(_xVorticity[index] * _xVorticity[index] +
+                                               _yVorticity[index] * _yVorticity[index] +
+                                               _zVorticity[index] * _zVorticity[index]);
+                       }
+
+       // calculate normalized vorticity vectors
+       float eps = _vorticityEps;
+       index = _slabSize + _xRes + 1;
+       for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes)
+               for (y = 1; y < _yRes - 1; y++, index += 2)
+                       for (x = 1; x < _xRes - 1; x++, index++)
+                               if (!_obstacles[index])
+                               {
+                                       float N[3];
+
+                                       int up    = _obstacles[index + _xRes] ? index : index + _xRes;
+                                       int down  = _obstacles[index - _xRes] ? index : index - _xRes;
+                                       float dy  = (up == index || down == index) ? 1.0f / _dx : gridSize;
+                                       int out   = _obstacles[index + _slabSize] ? index : index + _slabSize;
+                                       int in    = _obstacles[index - _slabSize] ? index : index - _slabSize;
+                                       float dz  = (out == index || in == index) ? 1.0f / _dx : gridSize;
+                                       int right = _obstacles[index + 1] ? index : index + 1;
+                                       int left  = _obstacles[index - 1] ? index : index - 1;
+                                       float dx  = (right == index || right == index) ? 1.0f / _dx : gridSize;
+                                       N[0] = (_vorticity[right] - _vorticity[left]) * dx;
+                                       N[1] = (_vorticity[up] - _vorticity[down]) * dy;
+                                       N[2] = (_vorticity[out] - _vorticity[in]) * dz;
+
+                                       float magnitude = sqrtf(N[0] * N[0] + N[1] * N[1] + N[2] * N[2]);
+                                       if (magnitude > 0.0f)
+                                       {
+                                               magnitude = 1.0f / magnitude;
+                                               N[0] *= magnitude;
+                                               N[1] *= magnitude;
+                                               N[2] *= magnitude;
+
+                                               _xForce[index] += (N[1] * _zVorticity[index] - N[2] * _yVorticity[index]) * _dx * eps;
+                                               _yForce[index] -= (N[0] * _zVorticity[index] - N[2] * _xVorticity[index]) * _dx * eps;
+                                               _zForce[index] += (N[0] * _yVorticity[index] - N[1] * _xVorticity[index]) * _dx * eps;
+                                       }
+                               }
+}
+
+//////////////////////////////////////////////////////////////////////
+// Advect using the MacCormack method from the Selle paper
+//////////////////////////////////////////////////////////////////////
+void FLUID_3D::advectMacCormack()
+{
+       Vec3Int res = Vec3Int(_xRes,_yRes,_zRes);
+
+       if(DOMAIN_BC_LEFT == 0) copyBorderX(_xVelocity, res);
+       else setZeroX(_xVelocity, res);
+
+       if(DOMAIN_BC_TOP == 0) copyBorderY(_yVelocity, res);
+       else setZeroY(_yVelocity, res);
+
+       if(DOMAIN_BC_FRONT == 0) copyBorderZ(_zVelocity, res);
+       else setZeroZ(_zVelocity, res);
+
+       SWAP_POINTERS(_xVelocity, _xVelocityOld);
+       SWAP_POINTERS(_yVelocity, _yVelocityOld);
+       SWAP_POINTERS(_zVelocity, _zVelocityOld);
+       SWAP_POINTERS(_density, _densityOld);
+       SWAP_POINTERS(_heat, _heatOld);
+
+       const float dt0 = _dt / _dx;
+       // use force arrays as temp arrays
+  for (int x = 0; x < _totalCells; x++)
+    _xForce[x] = _yForce[x] = 0.0;
+       float* t1 = _xForce;
+       float* t2 = _yForce;
+
+       advectFieldMacCormack(dt0, _xVelocityOld, _yVelocityOld, _zVelocityOld, _densityOld, _density, t1,t2, res, NULL);
+       advectFieldMacCormack(dt0, _xVelocityOld, _yVelocityOld, _zVelocityOld, _heatOld, _heat, t1,t2, res, NULL);
+       advectFieldMacCormack(dt0, _xVelocityOld, _yVelocityOld, _zVelocityOld, _xVelocityOld, _xVelocity, t1,t2, res, NULL);
+       advectFieldMacCormack(dt0, _xVelocityOld, _yVelocityOld, _zVelocityOld, _yVelocityOld, _yVelocity, t1,t2, res, NULL);
+       advectFieldMacCormack(dt0, _xVelocityOld, _yVelocityOld, _zVelocityOld, _zVelocityOld, _zVelocity, t1,t2, res, NULL);
+
+       if(DOMAIN_BC_LEFT == 0) copyBorderX(_xVelocity, res);
+       else setZeroX(_xVelocity, res);
+
+       if(DOMAIN_BC_TOP == 0) copyBorderY(_yVelocity, res);
+       else setZeroY(_yVelocity, res);
+
+       if(DOMAIN_BC_FRONT == 0) copyBorderZ(_zVelocity, res);
+       else setZeroZ(_zVelocity, res);
+
+       setZeroBorder(_density, res);
+       setZeroBorder(_heat, res);
+
+  for (int x = 0; x < _totalCells; x++)
+    t1[x] = t2[x] = 0.0;
+}
diff --git a/intern/smoke/intern/FLUID_3D.h b/intern/smoke/intern/FLUID_3D.h
new file mode 100644 (file)
index 0000000..2d212ca
--- /dev/null
@@ -0,0 +1,175 @@
+//////////////////////////////////////////////////////////////////////
+// This file is part of Wavelet Turbulence.
+// 
+// Wavelet Turbulence 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 3 of the License, or
+// (at your option) any later version.
+// 
+// Wavelet Turbulence 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 Wavelet Turbulence.  If not, see <http://www.gnu.org/licenses/>.
+// 
+// Copyright 2008 Theodore Kim and Nils Thuerey
+// 
+// FLUID_3D.h: interface for the FLUID_3D class.
+//
+//////////////////////////////////////////////////////////////////////
+
+#ifndef FLUID_3D_H
+#define FLUID_3D_H
+
+#include <cstdlib>
+#include <cmath>
+#include <iostream>
+#include "OBSTACLE.h"
+#include "WTURBULENCE.h"
+#include "VEC3.h"
+
+using namespace std;
+using namespace BasicVector;
+class WTURBULENCE;
+
+class FLUID_3D  
+{
+       public:
+               FLUID_3D(int *res, int amplify, float *p0, float dt);
+               FLUID_3D() {};
+               virtual ~FLUID_3D();
+
+               void initBlenderRNA(float *alpha, float *beta);
+               
+               // create & allocate vector noise advection 
+               void initVectorNoise(int amplify);
+
+               void addSmokeColumn();
+               static void addSmokeTestCase(float* field, Vec3Int res, float value);
+
+               void step();
+               void addObstacle(OBSTACLE* obstacle);
+
+               const float* xVelocity() { return _xVelocity; }; 
+               const float* yVelocity() { return _yVelocity; }; 
+               const float* zVelocity() { return _zVelocity; }; 
+
+               int xRes() const { return _xRes; };
+               int yRes() const { return _yRes; };
+               int zRes() const { return _zRes; };
+
+       public:  
+               // dimensions
+               int _xRes, _yRes, _zRes, _maxRes;
+               Vec3Int _res;
+               int _totalCells;
+               int _slabSize;
+               float _dx;
+               float _p0[3];
+               float _p1[3];
+               float _totalTime;
+               int _totalSteps;
+               int _totalImgDumps;
+               int _totalVelDumps;
+
+    void artificialDamping(float* field);
+
+               // fields
+               float* _density;
+               float* _densityOld;
+               float* _heat;
+               float* _heatOld;
+               float* _pressure;
+               float* _xVelocity;
+               float* _yVelocity;
+               float* _zVelocity;
+               float* _xVelocityOld;
+               float* _yVelocityOld;
+               float* _zVelocityOld;
+               float* _xForce;
+               float* _yForce;
+               float* _zForce;
+               float* _divergence;
+               float* _xVorticity;
+               float* _yVorticity;
+               float* _zVorticity;
+               float* _vorticity;
+               unsigned char*  _obstacles;
+
+               // CG fields
+               float* _residual;
+               float* _direction;
+               float* _q;
+               int _iterations;
+
+               // simulation constants
+               float _dt;
+               float _vorticityEps;
+               float _heatDiffusion;
+               float *_alpha; // for the buoyancy density term <-- as pointer to get blender RNA in here
+               float *_beta; // was _buoyancy <-- as pointer to get blender RNA in here
+               float _tempAmb; /* ambient temperature */
+
+               // WTURBULENCE object, if active
+               WTURBULENCE* _wTurbulence;
+
+               // boundary setting functions
+               void copyBorderAll(float* field);
+
+               // timestepping functions
+               void wipeBoundaries();
+               void addForce();
+               void addVorticity();
+               void addBuoyancy(float *heat, float *density);
+
+               // solver stuff
+               void project();
+               void diffuseHeat();
+               void solvePressure(float* field, float* b, unsigned char* skip);
+               void solveHeat(float* field, float* b, unsigned char* skip);
+
+               // handle obstacle boundaries
+               void setObstacleBoundaries();
+
+       public:
+               // advection, accessed e.g. by WTURBULENCE class
+               void advectMacCormack();
+
+               // boundary setting functions
+               static void copyBorderX(float* field, Vec3Int res);
+               static void copyBorderY(float* field, Vec3Int res);
+               static void copyBorderZ(float* field, Vec3Int res);
+               static void setNeumannX(float* field, Vec3Int res);
+               static void setNeumannY(float* field, Vec3Int res);
+               static void setNeumannZ(float* field, Vec3Int res);
+               static void setZeroX(float* field, Vec3Int res);
+               static void setZeroY(float* field, Vec3Int res);
+               static void setZeroZ(float* field, Vec3Int res);
+               static void setZeroBorder(float* field, Vec3Int res) {
+                       setZeroX(field, res);
+                       setZeroY(field, res);
+                       setZeroZ(field, res);
+               };
+
+               // static advection functions, also used by WTURBULENCE
+               static void advectFieldSemiLagrange(const float dt, const float* velx, const float* vely,  const float* velz,
+                               float* oldField, float* newField, Vec3Int res);
+               static void advectFieldMacCormack(const float dt, const float* xVelocity, const float* yVelocity, const float* zVelocity, 
+                               float* oldField, float* newField, float* temp1, float* temp2, Vec3Int res, const float* obstacles);
+
+               // maccormack helper functions
+               static void clampExtrema(const float dt, const float* xVelocity, const float* yVelocity,  const float* zVelocity,
+                               float* oldField, float* newField, Vec3Int res);
+               static void clampOutsideRays(const float dt, const float* xVelocity, const float* yVelocity,  const float* zVelocity,
+                               float* oldField, float* newField, Vec3Int res, const float* obstacles, const float *oldAdvection);
+
+               // output helper functions
+               // static void writeImageSliceXY(const float *field, Vec3Int res, int slice, string prefix, int picCnt, float scale=1.);
+               // static void writeImageSliceYZ(const float *field, Vec3Int res, int slice, string prefix, int picCnt, float scale=1.);
+               // static void writeImageSliceXZ(const float *field, Vec3Int res, int slice, string prefix, int picCnt, float scale=1.);
+               // static void writeProjectedIntern(const float *field, Vec3Int res, int dir1, int dir2, string prefix, int picCnt, float scale=1.); 
+};
+
+#endif
diff --git a/intern/smoke/intern/FLUID_3D_SOLVERS.cpp b/intern/smoke/intern/FLUID_3D_SOLVERS.cpp
new file mode 100644 (file)
index 0000000..5fd8f72
--- /dev/null
@@ -0,0 +1,319 @@
+//////////////////////////////////////////////////////////////////////
+// This file is part of Wavelet Turbulence.
+// 
+// Wavelet Turbulence 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 3 of the License, or
+// (at your option) any later version.
+// 
+// Wavelet Turbulence 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 Wavelet Turbulence.  If not, see <http://www.gnu.org/licenses/>.
+// 
+// Copyright 2008 Theodore Kim and Nils Thuerey
+// 
+// FLUID_3D.cpp: implementation of the FLUID_3D class.
+//
+//////////////////////////////////////////////////////////////////////
+
+#include "FLUID_3D.h"
+#define SOLVER_ACCURACY 1e-06
+
+//////////////////////////////////////////////////////////////////////
+// solve the poisson equation with CG
+//////////////////////////////////////////////////////////////////////
+void FLUID_3D::solvePressure(float* field, float* b, unsigned char* skip)
+{
+  int x, y, z, index;
+
+  // i = 0
+  int i = 0;
+
+  // r = b - Ax
+  index = _slabSize + _xRes + 1;
+  for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes)
+    for (y = 1; y < _yRes - 1; y++, index += 2)
+      for (x = 1; x < _xRes - 1; x++, index++)
+      {
+        // if the cell is a variable
+        float Acenter = 0.0f;
+        if (!skip[index])
+        {
+          // set the matrix to the Poisson stencil in order
+          if (!skip[index + 1]) Acenter += 1.;
+          if (!skip[index - 1]) Acenter += 1.;
+          if (!skip[index + _xRes]) Acenter += 1.;
+          if (!skip[index - _xRes]) Acenter += 1.;
+          if (!skip[index + _slabSize]) Acenter += 1.;
+          if (!skip[index - _slabSize]) Acenter += 1.;
+        }
+        
+        _residual[index] = b[index] - (Acenter * field[index] +  
+          field[index - 1] * (skip[index - 1] ? 0.0 : -1.0f)+ 
+          field[index + 1] * (skip[index + 1] ? 0.0 : -1.0f)+
+          field[index - _xRes] * (skip[index - _xRes] ? 0.0 : -1.0f)+ 
+          field[index + _xRes] * (skip[index + _xRes] ? 0.0 : -1.0f)+
+          field[index - _slabSize] * (skip[index - _slabSize] ? 0.0 : -1.0f)+ 
+          field[index + _slabSize] * (skip[index + _slabSize] ? 0.0 : -1.0f) );
+        _residual[index] = (skip[index]) ? 0.0f : _residual[index];
+      }
+
+  // d = r
+  index = _slabSize + _xRes + 1;
+  for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes)
+    for (y = 1; y < _yRes - 1; y++, index += 2)
+      for (x = 1; x < _xRes - 1; x++, index++)
+        _direction[index] = _residual[index];
+
+  // deltaNew = transpose(r) * r
+  float deltaNew = 0.0f;
+  index = _slabSize + _xRes + 1;
+  for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes)
+    for (y = 1; y < _yRes - 1; y++, index += 2)
+      for (x = 1; x < _xRes - 1; x++, index++)
+        deltaNew += _residual[index] * _residual[index];
+
+  // delta0 = deltaNew
+  // float delta0 = deltaNew;
+
+  // While deltaNew > (eps^2) * delta0
+  const float eps  = SOLVER_ACCURACY;
+  float maxR = 2.0f * eps;
+  while ((i < _iterations) && (maxR > eps))
+  {
+    // q = Ad
+    index = _slabSize + _xRes + 1;
+    for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes)
+      for (y = 1; y < _yRes - 1; y++, index += 2)
+        for (x = 1; x < _xRes - 1; x++, index++)
+        {
+          // if the cell is a variable
+          float Acenter = 0.0f;
+          if (!skip[index])
+          {
+            // set the matrix to the Poisson stencil in order
+            if (!skip[index + 1]) Acenter += 1.;
+            if (!skip[index - 1]) Acenter += 1.;
+            if (!skip[index + _xRes]) Acenter += 1.;
+            if (!skip[index - _xRes]) Acenter += 1.;
+            if (!skip[index + _slabSize]) Acenter += 1.;
+            if (!skip[index - _slabSize]) Acenter += 1.;
+          }
+          
+          _q[index] = Acenter * _direction[index] +  
+            _direction[index - 1] * (skip[index - 1] ? 0.0 : -1.0f) + 
+            _direction[index + 1] * (skip[index + 1] ? 0.0 : -1.0f) +
+            _direction[index - _xRes] * (skip[index - _xRes] ? 0.0 : -1.0f) + 
+            _direction[index + _xRes] * (skip[index + _xRes] ? 0.0 : -1.0f)+
+            _direction[index - _slabSize] * (skip[index - _slabSize] ? 0.0 : -1.0f) + 
+            _direction[index + _slabSize] * (skip[index + _slabSize] ? 0.0 : -1.0f);
+          _q[index] = (skip[index]) ? 0.0f : _q[index];
+        }
+
+    // alpha = deltaNew / (transpose(d) * q)
+    float alpha = 0.0f;
+    index = _slabSize + _xRes + 1;
+    for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes)
+      for (y = 1; y < _yRes - 1; y++, index += 2)
+        for (x = 1; x < _xRes - 1; x++, index++)
+          alpha += _direction[index] * _q[index];
+    if (fabs(alpha) > 0.0f)
+      alpha = deltaNew / alpha;
+
+    // x = x + alpha * d
+    index = _slabSize + _xRes + 1;
+    for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes)
+      for (y = 1; y < _yRes - 1; y++, index += 2)
+        for (x = 1; x < _xRes - 1; x++, index++)
+          field[index] += alpha * _direction[index];
+
+    // r = r - alpha * q
+    maxR = 0.0f;
+    index = _slabSize + _xRes + 1;
+    for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes)
+      for (y = 1; y < _yRes - 1; y++, index += 2)
+        for (x = 1; x < _xRes - 1; x++, index++)
+        {
+          _residual[index] -= alpha * _q[index];
+          maxR = (_residual[index] > maxR) ? _residual[index] : maxR;
+        }
+
+    // deltaOld = deltaNew
+    float deltaOld = deltaNew;
+
+    // deltaNew = transpose(r) * r
+    deltaNew = 0.0f;
+    index = _slabSize + _xRes + 1;
+    for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes)
+      for (y = 1; y < _yRes - 1; y++, index += 2)
+        for (x = 1; x < _xRes - 1; x++, index++)
+          deltaNew += _residual[index] * _residual[index];
+
+    // beta = deltaNew / deltaOld
+    float beta = deltaNew / deltaOld;
+
+    // d = r + beta * d
+    index = _slabSize + _xRes + 1;
+    for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes)
+      for (y = 1; y < _yRes - 1; y++, index += 2)
+        for (x = 1; x < _xRes - 1; x++, index++)
+          _direction[index] = _residual[index] + beta * _direction[index];
+
+    // i = i + 1
+    i++;
+  }
+  cout << i << " iterations converged to " << maxR << endl;
+}
+
+//////////////////////////////////////////////////////////////////////
+// solve the heat equation with CG
+//////////////////////////////////////////////////////////////////////
+void FLUID_3D::solveHeat(float* field, float* b, unsigned char* skip)
+{
+  int x, y, z, index;
+  const float heatConst = _dt * _heatDiffusion / (_dx * _dx);
+
+  // i = 0
+  int i = 0;
+
+  // r = b - Ax
+  index = _slabSize + _xRes + 1;
+  for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes)
+    for (y = 1; y < _yRes - 1; y++, index += 2)
+      for (x = 1; x < _xRes - 1; x++, index++)
+      {
+        // if the cell is a variable
+        float Acenter = 1.0f;
+        if (!skip[index])
+        {
+          // set the matrix to the Poisson stencil in order
+          if (!skip[index + 1]) Acenter += heatConst;
+          if (!skip[index - 1]) Acenter += heatConst;
+          if (!skip[index + _xRes]) Acenter += heatConst;
+          if (!skip[index - _xRes]) Acenter += heatConst;
+          if (!skip[index + _slabSize]) Acenter += heatConst;
+          if (!skip[index - _slabSize]) Acenter += heatConst;
+        }
+        
+        _residual[index] = b[index] - (Acenter * field[index] + 
+          field[index - 1] * (skip[index - 1] ? 0.0 : -heatConst) + 
+          field[index + 1] * (skip[index + 1] ? 0.0 : -heatConst) +
+          field[index - _xRes] * (skip[index - _xRes] ? 0.0 : -heatConst) + 
+          field[index + _xRes] * (skip[index + _xRes] ? 0.0 : -heatConst) +
+          field[index - _slabSize] * (skip[index - _slabSize] ? 0.0 : -heatConst) + 
+          field[index + _slabSize] * (skip[index + _slabSize] ? 0.0 : -heatConst));
+        _residual[index] = (skip[index]) ? 0.0f : _residual[index];
+      }
+
+  // d = r
+  index = _slabSize + _xRes + 1;
+  for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes)
+    for (y = 1; y < _yRes - 1; y++, index += 2)
+      for (x = 1; x < _xRes - 1; x++, index++)
+        _direction[index] = _residual[index];
+
+  // deltaNew = transpose(r) * r
+  float deltaNew = 0.0f;
+  index = _slabSize + _xRes + 1;
+  for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes)
+    for (y = 1; y < _yRes - 1; y++, index += 2)
+      for (x = 1; x < _xRes - 1; x++, index++)
+        deltaNew += _residual[index] * _residual[index];
+
+  // delta0 = deltaNew
+  // float delta0 = deltaNew;
+
+  // While deltaNew > (eps^2) * delta0
+  const float eps  = SOLVER_ACCURACY;
+  float maxR = 2.0f * eps;
+  while ((i < _iterations) && (maxR > eps))
+  {
+    // q = Ad
+    index = _slabSize + _xRes + 1;
+    for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes)
+      for (y = 1; y < _yRes - 1; y++, index += 2)
+        for (x = 1; x < _xRes - 1; x++, index++)
+        {
+          // if the cell is a variable
+          float Acenter = 1.0f;
+          if (!skip[index])
+          {
+            // set the matrix to the Poisson stencil in order
+            if (!skip[index + 1]) Acenter += heatConst;
+            if (!skip[index - 1]) Acenter += heatConst;
+            if (!skip[index + _xRes]) Acenter += heatConst;
+            if (!skip[index - _xRes]) Acenter += heatConst;
+            if (!skip[index + _slabSize]) Acenter += heatConst;
+            if (!skip[index - _slabSize]) Acenter += heatConst;
+          }
+
+          _q[index] = (Acenter * _direction[index] + 
+            _direction[index - 1] * (skip[index - 1] ? 0.0 : -heatConst) + 
+            _direction[index + 1] * (skip[index + 1] ? 0.0 : -heatConst) +
+            _direction[index - _xRes] * (skip[index - _xRes] ? 0.0 : -heatConst) + 
+            _direction[index + _xRes] * (skip[index + _xRes] ? 0.0 : -heatConst) +
+            _direction[index - _slabSize] * (skip[index - _slabSize] ? 0.0 : -heatConst) + 
+            _direction[index + _slabSize] * (skip[index + _slabSize] ? 0.0 : -heatConst));
+         
+          _q[index] = (skip[index]) ? 0.0f : _q[index];
+        }
+
+    // alpha = deltaNew / (transpose(d) * q)
+    float alpha = 0.0f;
+    index = _slabSize + _xRes + 1;
+    for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes)
+      for (y = 1; y < _yRes - 1; y++, index += 2)
+        for (x = 1; x < _xRes - 1; x++, index++)
+          alpha += _direction[index] * _q[index];
+    if (fabs(alpha) > 0.0f)
+      alpha = deltaNew / alpha;
+
+    // x = x + alpha * d
+    index = _slabSize + _xRes + 1;
+    for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes)
+      for (y = 1; y < _yRes - 1; y++, index += 2)
+        for (x = 1; x < _xRes - 1; x++, index++)
+          field[index] += alpha * _direction[index];
+
+    // r = r - alpha * q
+    maxR = 0.0f;
+    index = _slabSize + _xRes + 1;
+    for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes)
+      for (y = 1; y < _yRes - 1; y++, index += 2)
+        for (x = 1; x < _xRes - 1; x++, index++)
+        {
+          _residual[index] -= alpha * _q[index];
+          maxR = (_residual[index] > maxR) ? _residual[index] : maxR;
+        }
+
+    // deltaOld = deltaNew
+    float deltaOld = deltaNew;
+
+    // deltaNew = transpose(r) * r
+    deltaNew = 0.0f;
+    index = _slabSize + _xRes + 1;
+    for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes)
+      for (y = 1; y < _yRes - 1; y++, index += 2)
+        for (x = 1; x < _xRes - 1; x++, index++)
+          deltaNew += _residual[index] * _residual[index];
+
+    // beta = deltaNew / deltaOld
+    float beta = deltaNew / deltaOld;
+
+    // d = r + beta * d
+    index = _slabSize + _xRes + 1;
+    for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes)
+      for (y = 1; y < _yRes - 1; y++, index += 2)
+        for (x = 1; x < _xRes - 1; x++, index++)
+          _direction[index] = _residual[index] + beta * _direction[index];
+
+    // i = i + 1
+    i++;
+  }
+  cout << i << " iterations converged to " << maxR << endl;
+}
+
diff --git a/intern/smoke/intern/FLUID_3D_STATIC.cpp b/intern/smoke/intern/FLUID_3D_STATIC.cpp
new file mode 100644 (file)
index 0000000..a72009b
--- /dev/null
@@ -0,0 +1,657 @@
+//////////////////////////////////////////////////////////////////////
+// This file is part of Wavelet Turbulence.
+//
+// Wavelet Turbulence 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 3 of the License, or
+// (at your option) any later version.
+//
+// Wavelet Turbulence 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 Wavelet Turbulence.  If not, see <http://www.gnu.org/licenses/>.
+//
+// Copyright 2008 Theodore Kim and Nils Thuerey
+//
+// FLUID_3D.cpp: implementation of the static functions of the FLUID_3D class.
+//
+//////////////////////////////////////////////////////////////////////
+
+#include <zlib.h>
+#include "FLUID_3D.h"
+#include "IMAGE.h"
+#include "WTURBULENCE.h"
+#include "INTERPOLATE.h"
+
+//////////////////////////////////////////////////////////////////////
+// add a test cube of density to the center
+//////////////////////////////////////////////////////////////////////
+/*
+void FLUID_3D::addSmokeColumn() {
+       addSmokeTestCase(_density, _res, 1.0);
+       // addSmokeTestCase(_zVelocity, _res, 1.0);
+       addSmokeTestCase(_heat, _res, 1.0);
+       if (_wTurbulence) {
+               addSmokeTestCase(_wTurbulence->getDensityBig(), _wTurbulence->getResBig(), 1.0);
+       }
+}
+*/
+
+//////////////////////////////////////////////////////////////////////
+// generic static version, so that it can be applied to the
+// WTURBULENCE grid as well
+//////////////////////////////////////////////////////////////////////
+/*
+void FLUID_3D::addSmokeTestCase(float* field, Vec3Int res, float value)
+{
+       const int slabSize = res[0]*res[1]; int maxRes = (int)MAX3V(res);
+       float dx = 1.0f / (float)maxRes;
+
+       float xTotal = dx * res[0];
+       float yTotal = dx * res[1];
+       float zTotal = dx * res[2];
+
+  float heighMin = 0.05;
+  float heighMax = 0.10;
+
+  for (int y = 0; y < res[1]; y++)
+    for (int z = (int)(heighMin*res[2]); z <= (int)(heighMax * res[1]); z++)
+      for (int x = 0; x < res[0]; x++)
+      {
+        float xLength = x * dx - xTotal * 0.4f;
+        float yLength = y * dx - zTotal * 0.5f;
+        float radius = sqrtf(xLength * xLength + yLength * yLength);
+
+        if (radius < 0.075f * xTotal)
+        {
+          int index = x + y * res[0] + z * slabSize;
+          field[index] = value;
+        }
+      }
+}
+*/
+
+//////////////////////////////////////////////////////////////////////
+// set x direction to Neumann boundary conditions
+//////////////////////////////////////////////////////////////////////
+void FLUID_3D::setNeumannX(float* field, Vec3Int res)
+{
+       const int slabSize = res[0] * res[1];
+       int index;
+       for (int z = 0; z < res[2]; z++)
+               for (int y = 0; y < res[1]; y++)
+               {
+                       // left slab
+                       index = y * res[0] + z * slabSize;
+                       field[index] = field[index + 2];
+
+                       // right slab
+                       index += res[0] - 1;
+                       field[index] = field[index - 2];
+               }
+ }
+
+//////////////////////////////////////////////////////////////////////
+// set y direction to Neumann boundary conditions
+//////////////////////////////////////////////////////////////////////
+void FLUID_3D::setNeumannY(float* field, Vec3Int res)
+{
+       const int slabSize = res[0] * res[1];
+       int index;
+       for (int z = 0; z < res[2]; z++)
+               for (int x = 0; x < res[0]; x++)
+               {
+                       // bottom slab
+                       index = x + z * slabSize;
+                       field[index] = field[index + 2 * res[0]];
+
+                       // top slab
+                       index += slabSize - res[0];
+                       field[index] = field[index - 2 * res[0]];
+               }
+
+       // fix, force top slab to only allow outwards flux
+       for (int z = 0; z < res[2]; z++)
+               for (int x = 0; x < res[0]; x++)
+               {
+                       // top slab
+                       index = x + z * slabSize;
+                       index += slabSize - res[0];
+                       if(field[index]<0.) field[index] = 0.;
+                       index -= res[0];
+                       if(field[index]<0.) field[index] = 0.;
+               }
+}
+
+//////////////////////////////////////////////////////////////////////
+// set z direction to Neumann boundary conditions
+//////////////////////////////////////////////////////////////////////
+void FLUID_3D::setNeumannZ(float* field, Vec3Int res)
+{
+       const int slabSize = res[0] * res[1];
+       const int totalCells = res[0] * res[1] * res[2];
+       int index;
+       for (int y = 0; y < res[1]; y++)
+               for (int x = 0; x < res[0]; x++)
+               {
+                       // front slab
+                       index = x + y * res[0];
+                       field[index] = field[index + 2 * slabSize];
+
+                       // back slab
+                       index += totalCells - slabSize;
+                       field[index] = field[index - 2 * slabSize];
+               }
+}
+
+//////////////////////////////////////////////////////////////////////
+// set x direction to zero
+//////////////////////////////////////////////////////////////////////
+void FLUID_3D::setZeroX(float* field, Vec3Int res)
+{
+       const int slabSize = res[0] * res[1];
+       int index;
+       for (int z = 0; z < res[2]; z++)
+               for (int y = 0; y < res[1]; y++)
+               {
+                       // left slab
+                       index = y * res[0] + z * slabSize;
+                       field[index] = 0.0f;
+
+                       // right slab
+                       index += res[0] - 1;
+                       field[index] = 0.0f;
+               }
+}
+
+//////////////////////////////////////////////////////////////////////
+// set y direction to zero
+//////////////////////////////////////////////////////////////////////
+void FLUID_3D::setZeroY(float* field, Vec3Int res)
+{
+       const int slabSize = res[0] * res[1];
+       int index;
+       for (int z = 0; z < res[2]; z++)
+               for (int x = 0; x < res[0]; x++)
+               {
+                       // bottom slab
+                       index = x + z * slabSize;
+                       field[index] = 0.0f;
+
+                       // top slab
+                       index += slabSize - res[0];
+                       field[index] = 0.0f;
+               }
+}
+
+//////////////////////////////////////////////////////////////////////
+// set z direction to zero
+//////////////////////////////////////////////////////////////////////
+void FLUID_3D::setZeroZ(float* field, Vec3Int res)
+{
+       const int slabSize = res[0] * res[1];
+       const int totalCells = res[0] * res[1] * res[2];
+       int index;
+       for (int y = 0; y < res[1]; y++)
+               for (int x = 0; x < res[0]; x++)
+               {
+                       // front slab
+                       index = x + y * res[0];
+                       field[index] = 0.0f;
+
+                       // back slab
+                       index += totalCells - slabSize;
+                       field[index] = 0.0f;
+               }
+ }
+
+//////////////////////////////////////////////////////////////////////
+// copy grid boundary
+//////////////////////////////////////////////////////////////////////
+void FLUID_3D::copyBorderX(float* field, Vec3Int res)
+{
+       const int slabSize = res[0] * res[1];
+       int index;
+       for (int z = 0; z < res[2]; z++)
+               for (int y = 0; y < res[1]; y++)
+               {
+                       // left slab
+                       index = y * res[0] + z * slabSize;
+                       field[index] = field[index + 1];
+
+                       // right slab
+                       index += res[0] - 1;
+                       field[index] = field[index - 1];
+               }
+}
+void FLUID_3D::copyBorderY(float* field, Vec3Int res)
+{
+       const int slabSize = res[0] * res[1];
+       int index;
+       for (int z = 0; z < res[2]; z++)
+               for (int x = 0; x < res[0]; x++)
+               {
+                       // bottom slab
+                       index = x + z * slabSize;
+                       field[index] = field[index + res[0]];
+                       // top slab
+                       index += slabSize - res[0];
+                       field[index] = field[index - res[0]];
+               }
+}
+void FLUID_3D::copyBorderZ(float* field, Vec3Int res)
+{
+       const int slabSize = res[0] * res[1];
+       const int totalCells = res[0] * res[1] * res[2];
+       int index;
+       for (int y = 0; y < res[1]; y++)
+               for (int x = 0; x < res[0]; x++)
+               {
+                       // front slab
+                       index = x + y * res[0];
+                       field[index] = field[index + slabSize];
+                       // back slab
+                       index += totalCells - slabSize;
+                       field[index] = field[index - slabSize];
+               }
+}
+
+/////////////////////////////////////////////////////////////////////
+// advect field with the semi lagrangian method
+//////////////////////////////////////////////////////////////////////
+void FLUID_3D::advectFieldSemiLagrange(const float dt, const float* velx, const float* vely,  const float* velz,
+               float* oldField, float* newField, Vec3Int res)
+{
+       const int xres = res[0];
+       const int yres = res[1];
+       const int zres = res[2];
+       const int slabSize = res[0] * res[1];
+
+       // scale dt up to grid resolution
+#if PARALLEL==1
+#pragma omp parallel for schedule(static)
+#endif
+       for (int z = 0; z < zres; z++)
+               for (int y = 0; y < yres; y++)
+                       for (int x = 0; x < xres; x++)
+                       {
+                               const int index = x + y * xres + z * xres*yres;
+
+        // backtrace
+                               float xTrace = x - dt * velx[index];
+                               float yTrace = y - dt * vely[index];
+                               float zTrace = z - dt * velz[index];
+
+                               // clamp backtrace to grid boundaries
+                               if (xTrace < 0.5) xTrace = 0.5;
+                               if (xTrace > xres - 1.5) xTrace = xres - 1.5;
+                               if (yTrace < 0.5) yTrace = 0.5;
+                               if (yTrace > yres - 1.5) yTrace = yres - 1.5;
+                               if (zTrace < 0.5) zTrace = 0.5;
+                               if (zTrace > zres - 1.5) zTrace = zres - 1.5;
+
+                               // locate neighbors to interpolate
+                               const int x0 = (int)xTrace;
+                               const int x1 = x0 + 1;
+                               const int y0 = (int)yTrace;
+                               const int y1 = y0 + 1;
+                               const int z0 = (int)zTrace;
+                               const int z1 = z0 + 1;
+
+                               // get interpolation weights
+                               const float s1 = xTrace - x0;
+                               const float s0 = 1.0f - s1;
+                               const float t1 = yTrace - y0;
+                               const float t0 = 1.0f - t1;
+                               const float u1 = zTrace - z0;
+                               const float u0 = 1.0f - u1;
+
+                               const int i000 = x0 + y0 * xres + z0 * slabSize;
+                               const int i010 = x0 + y1 * xres + z0 * slabSize;
+                               const int i100 = x1 + y0 * xres + z0 * slabSize;
+                               const int i110 = x1 + y1 * xres + z0 * slabSize;
+                               const int i001 = x0 + y0 * xres + z1 * slabSize;
+                               const int i011 = x0 + y1 * xres + z1 * slabSize;
+                               const int i101 = x1 + y0 * xres + z1 * slabSize;
+                               const int i111 = x1 + y1 * xres + z1 * slabSize;
+
+                               // interpolate
+                               // (indices could be computed once)
+                               newField[index] = u0 * (s0 * (t0 * oldField[i000] +
+                                                       t1 * oldField[i010]) +
+                                               s1 * (t0 * oldField[i100] +
+                                                       t1 * oldField[i110])) +
+                                       u1 * (s0 * (t0 * oldField[i001] +
+                                                               t1 * oldField[i011]) +
+                                                       s1 * (t0 * oldField[i101] +
+                                                               t1 * oldField[i111]));
+                       }
+}
+
+/////////////////////////////////////////////////////////////////////
+// advect field with the maccormack method
+//
+// comments are the pseudocode from selle's paper
+//////////////////////////////////////////////////////////////////////
+void FLUID_3D::advectFieldMacCormack(const float dt, const float* xVelocity, const float* yVelocity, const float* zVelocity,
+               float* oldField, float* newField, float* temp1, float* temp2, Vec3Int res, const float* obstacles)
+{
+       float* phiHatN  = temp1;
+       float* phiHatN1 = temp2;
+       const int sx= res[0];
+       const int sy= res[1];
+       const int sz= res[2];
+
+       for (int x = 0; x < sx * sy * sz; x++)
+               phiHatN[x] = phiHatN1[x] = oldField[x];
+
+       float*& phiN    = oldField;
+       float*& phiN1   = newField;
+
+       // phiHatN1 = A(phiN)
+       advectFieldSemiLagrange(  dt, xVelocity, yVelocity, zVelocity, phiN, phiHatN1, res);
+
+       // phiHatN = A^R(phiHatN1)
+       advectFieldSemiLagrange( -1.0*dt, xVelocity, yVelocity, zVelocity, phiHatN1, phiHatN, res);
+
+       // phiN1 = phiHatN1 + (phiN - phiHatN) / 2
+       const int border = 0;
+       for (int z = border; z < sz-border; z++)
+               for (int y = border; y < sy-border; y++)
+                       for (int x = border; x < sx-border; x++) {
+                               int index = x + y * sx + z * sx*sy;
+                               phiN1[index] = phiHatN1[index] + (phiN[index] - phiHatN[index]) * 0.50f;
+                               //phiN1[index] = phiHatN1[index]; // debug, correction off
+                       }
+       copyBorderX(phiN1, res);
+       copyBorderY(phiN1, res);
+       copyBorderZ(phiN1, res);
+
+       // clamp any newly created extrema
+       clampExtrema(dt, xVelocity, yVelocity, zVelocity, oldField, newField, res);
+
+       // if the error estimate was bad, revert to first order
+       clampOutsideRays(dt, xVelocity, yVelocity, zVelocity, oldField, newField, res, obstacles, phiHatN1);
+}
+
+
+//////////////////////////////////////////////////////////////////////
+// Clamp the extrema generated by the BFECC error correction
+//////////////////////////////////////////////////////////////////////
+void FLUID_3D::clampExtrema(const float dt, const float* velx, const float* vely,  const float* velz,
+               float* oldField, float* newField, Vec3Int res)
+{
+       const int xres= res[0];
+       const int yres= res[1];
+       const int zres= res[2];
+       const int slabSize = res[0] * res[1];
+       for (int z = 1; z < zres-1; z++)
+               for (int y = 1; y < yres-1; y++)
+                       for (int x = 1; x < xres-1; x++)
+                       {
+                               const int index = x + y * xres+ z * xres*yres;
+                               // backtrace
+                               float xTrace = x - dt * velx[index];
+                               float yTrace = y - dt * vely[index];
+                               float zTrace = z - dt * velz[index];
+
+                               // clamp backtrace to grid boundaries
+                               if (xTrace < 0.5) xTrace = 0.5;
+                               if (xTrace > xres - 1.5) xTrace = xres - 1.5;
+                               if (yTrace < 0.5) yTrace = 0.5;
+                               if (yTrace > yres - 1.5) yTrace = yres - 1.5;
+                               if (zTrace < 0.5) zTrace = 0.5;
+                               if (zTrace > zres - 1.5) zTrace = zres - 1.5;
+
+                               // locate neighbors to interpolate
+                               const int x0 = (int)xTrace;
+                               const int x1 = x0 + 1;
+                               const int y0 = (int)yTrace;
+                               const int y1 = y0 + 1;
+                               const int z0 = (int)zTrace;
+                               const int z1 = z0 + 1;
+
+                               const int i000 = x0 + y0 * xres + z0 * slabSize;
+                               const int i010 = x0 + y1 * xres + z0 * slabSize;
+                               const int i100 = x1 + y0 * xres + z0 * slabSize;
+                               const int i110 = x1 + y1 * xres + z0 * slabSize;
+                               const int i001 = x0 + y0 * xres + z1 * slabSize;
+                               const int i011 = x0 + y1 * xres + z1 * slabSize;
+                               const int i101 = x1 + y0 * xres + z1 * slabSize;
+                               const int i111 = x1 + y1 * xres + z1 * slabSize;
+
+                               float minField = oldField[i000];
+                               float maxField = oldField[i000];
+
+                               minField = (oldField[i010] < minField) ? oldField[i010] : minField;
+                               maxField = (oldField[i010] > maxField) ? oldField[i010] : maxField;
+
+                               minField = (oldField[i100] < minField) ? oldField[i100] : minField;
+                               maxField = (oldField[i100] > maxField) ? oldField[i100] : maxField;
+
+                               minField = (oldField[i110] < minField) ? oldField[i110] : minField;
+                               maxField = (oldField[i110] > maxField) ? oldField[i110] : maxField;
+
+                               minField = (oldField[i001] < minField) ? oldField[i001] : minField;
+                               maxField = (oldField[i001] > maxField) ? oldField[i001] : maxField;
+
+                               minField = (oldField[i011] < minField) ? oldField[i011] : minField;
+                               maxField = (oldField[i011] > maxField) ? oldField[i011] : maxField;
+
+                               minField = (oldField[i101] < minField) ? oldField[i101] : minField;
+                               maxField = (oldField[i101] > maxField) ? oldField[i101] : maxField;
+
+                               minField = (oldField[i111] < minField) ? oldField[i111] : minField;
+                               maxField = (oldField[i111] > maxField) ? oldField[i111] : maxField;
+
+                               newField[index] = (newField[index] > maxField) ? maxField : newField[index];
+                               newField[index] = (newField[index] < minField) ? minField : newField[index];
+                       }
+}
+
+//////////////////////////////////////////////////////////////////////
+// Reverts any backtraces that go into boundaries back to first
+// order -- in this case the error correction term was totally
+// incorrect
+//////////////////////////////////////////////////////////////////////
+void FLUID_3D::clampOutsideRays(const float dt, const float* velx, const float* vely, const float* velz,
+               float* oldField, float* newField, Vec3Int res, const float* obstacles, const float *oldAdvection)
+{
+       const int sx= res[0];
+       const int sy= res[1];
+       const int sz= res[2];
+       const int slabSize = res[0] * res[1];
+       for (int z = 1; z < sz-1; z++)
+               for (int y = 1; y < sy-1; y++)
+                       for (int x = 1; x < sx-1; x++)
+                       {
+                               const int index = x + y * sx+ z * slabSize;
+                               // backtrace
+                               float xBackward = x + dt * velx[index];
+                               float yBackward = y + dt * vely[index];
+                               float zBackward = z + dt * velz[index];
+                               float xTrace    = x - dt * velx[index];
+                               float yTrace    = y - dt * vely[index];
+                               float zTrace    = z - dt * velz[index];
+
+                               // see if it goes outside the boundaries
+                               bool hasObstacle =
+                                       (zTrace < 1.0f)    || (zTrace > sz - 2.0f) ||
+                                       (yTrace < 1.0f)    || (yTrace > sy - 2.0f) ||
+                                       (xTrace < 1.0f)    || (xTrace > sx - 2.0f) ||
+                                       (zBackward < 1.0f) || (zBackward > sz - 2.0f) ||
+                                       (yBackward < 1.0f) || (yBackward > sy - 2.0f) ||
+                                       (xBackward < 1.0f) || (xBackward > sx - 2.0f);
+                               // reuse old advection instead of doing another one...
+                               if(hasObstacle) { newField[index] = oldAdvection[index]; continue; }
+
+                               // clamp to prevent an out of bounds access when looking into
+                               // the _obstacles array
+                               zTrace = (zTrace < 0.5f) ? 0.5f : zTrace;
+                               zTrace = (zTrace > sz - 1.5f) ? sz - 1.5f : zTrace;
+                               yTrace = (yTrace < 0.5f) ? 0.5f : yTrace;
+                               yTrace = (yTrace > sy - 1.5f) ? sy - 1.5f : yTrace;
+                               xTrace = (xTrace < 0.5f) ? 0.5f : xTrace;
+                               xTrace = (xTrace > sx - 1.5f) ? sx - 1.5f : xTrace;
+
+                               // locate neighbors to interpolate,
+                               // do backward first since we will use the forward indices if a
+                               // reversion is actually necessary
+                               zBackward = (zBackward < 0.5f) ? 0.5f : zBackward;
+                               zBackward = (zBackward > sz - 1.5f) ? sz - 1.5f : zBackward;
+                               yBackward = (yBackward < 0.5f) ? 0.5f : yBackward;
+                               yBackward = (yBackward > sy - 1.5f) ? sy - 1.5f : yBackward;
+                               xBackward = (xBackward < 0.5f) ? 0.5f : xBackward;
+                               xBackward = (xBackward > sx - 1.5f) ? sx - 1.5f : xBackward;
+
+                               int x0 = (int)xBackward;
+                               int x1 = x0 + 1;
+                               int y0 = (int)yBackward;
+                               int y1 = y0 + 1;
+                               int z0 = (int)zBackward;
+                               int z1 = z0 + 1;
+                               if(obstacles && !hasObstacle) {
+                                       hasObstacle = hasObstacle ||
+                                               obstacles[x0 + y0 * sx + z0*slabSize] ||
+                                               obstacles[x0 + y1 * sx + z0*slabSize] ||
+                                               obstacles[x1 + y0 * sx + z0*slabSize] ||
+                                               obstacles[x1 + y1 * sx + z0*slabSize] ||
+                                               obstacles[x0 + y0 * sx + z1*slabSize] ||
+                                               obstacles[x0 + y1 * sx + z1*slabSize] ||
+                                               obstacles[x1 + y0 * sx + z1*slabSize] ||
+                                               obstacles[x1 + y1 * sx + z1*slabSize] ;
+                               }
+                               // reuse old advection instead of doing another one...
+                               if(hasObstacle) { newField[index] = oldAdvection[index]; continue; }
+
+                               x0 = (int)xTrace;
+                               x1 = x0 + 1;
+                               y0 = (int)yTrace;
+                               y1 = y0 + 1;
+                               z0 = (int)zTrace;
+                               z1 = z0 + 1;
+                               if(obstacles && !hasObstacle) {
+                                       hasObstacle = hasObstacle ||
+                                               obstacles[x0 + y0 * sx + z0*slabSize] ||
+                                               obstacles[x0 + y1 * sx + z0*slabSize] ||
+                                               obstacles[x1 + y0 * sx + z0*slabSize] ||
+                                               obstacles[x1 + y1 * sx + z0*slabSize] ||
+                                               obstacles[x0 + y0 * sx + z1*slabSize] ||
+                                               obstacles[x0 + y1 * sx + z1*slabSize] ||
+                                               obstacles[x1 + y0 * sx + z1*slabSize] ||
+                                               obstacles[x1 + y1 * sx + z1*slabSize] ;
+                               } // obstacle array
+                               // reuse old advection instead of doing another one...
+                               if(hasObstacle) { newField[index] = oldAdvection[index]; continue; }
+
+                               // see if either the forward or backward ray went into
+                               // a boundary
+                               if (hasObstacle) {
+                                       // get interpolation weights
+                                       float s1 = xTrace - x0;
+                                       float s0 = 1.0f - s1;
+                                       float t1 = yTrace - y0;
+                                       float t0 = 1.0f - t1;
+                                       float u1 = zTrace - z0;
+                                       float u0 = 1.0f - u1;
+
+                                       const int i000 = x0 + y0 * sx + z0 * slabSize;
+                                       const int i010 = x0 + y1 * sx + z0 * slabSize;
+                                       const int i100 = x1 + y0 * sx + z0 * slabSize;
+                                       const int i110 = x1 + y1 * sx + z0 * slabSize;
+                                       const int i001 = x0 + y0 * sx + z1 * slabSize;
+                                       const int i011 = x0 + y1 * sx + z1 * slabSize;
+                                       const int i101 = x1 + y0 * sx + z1 * slabSize;
+                                       const int i111 = x1 + y1 * sx + z1 * slabSize;
+
+                                       // interpolate, (indices could be computed once)
+                                       newField[index] = u0 * (s0 * (
+                                                               t0 * oldField[i000] +
+                                                               t1 * oldField[i010]) +
+                                                       s1 * (t0 * oldField[i100] +
+                                                               t1 * oldField[i110])) +
+                                               u1 * (s0 * (t0 * oldField[i001] +
+                                                                       t1 * oldField[i011]) +
+                                                               s1 * (t0 * oldField[i101] +
+                                                                       t1 * oldField[i111]));
+                               }
+                       } // xyz
+}
+
+//////////////////////////////////////////////////////////////////////
+// image output
+//////////////////////////////////////////////////////////////////////
+/*
+void FLUID_3D::writeImageSliceXY(const float *field, Vec3Int res, int slice, string prefix, int picCnt, float scale) {
+  writeProjectedIntern(field, res, 0,1, prefix, picCnt, scale);
+}
+void FLUID_3D::writeImageSliceYZ(const float *field, Vec3Int res, int slice, string prefix, int picCnt, float scale) {
+  writeProjectedIntern(field, res, 1,2, prefix, picCnt, scale);
+}
+void FLUID_3D::writeImageSliceXZ(const float *field, Vec3Int res, int slice, string prefix, int picCnt, float scale) {
+  writeProjectedIntern(field, res, 0,2, prefix, picCnt, scale);
+}
+*/
+
+//////////////////////////////////////////////////////////////////////
+// Helper function for projecting densities along a dimension
+//////////////////////////////////////////////////////////////////////
+static int getOtherDir(int dir1, int dir2) {
+       switch(dir1) {
+               case 0:
+                       switch(dir2) {
+                               case 1: return 2;
+                               case 2: return 1; }
+                       break;
+               case 1:
+                       switch(dir2) {
+                               case 0: return 2;
+                               case 2: return 0; }
+                       break;
+               case 2:
+                       switch(dir2) {
+                               case 0: return 1;
+                               case 1: return 0; }
+                       break;
+               default:
+                       return 0;
+       }
+       return 0;
+}
+
+//////////////////////////////////////////////////////////////////////
+// average densities along third spatial direction
+//////////////////////////////////////////////////////////////////////
+/*
+void FLUID_3D::writeProjectedIntern(const float *field, Vec3Int res,
+               int dir1, int dir2, string prefix, int picCnt, float scale) {
+       const int nitems = res[dir1]*res[dir2];
+       const int otherDir = getOtherDir(dir1,dir2);
+       float *buf = new float[nitems];
+       Vec3Int min = Vec3Int(0);
+       Vec3Int max = res;
+
+       min[otherDir] = 0;
+       max[otherDir] = res[otherDir];
+       float div = 1./(float)MIN3V(res); // normalize for shorter sides, old: res[otherDir];
+       div *= 4.; //slightly increase contrast
+       for(int i=0; i<nitems; i++) buf[i] = 0.;
+
+       Vec3Int cnt = 0;
+       for (cnt[2] = min[2]; cnt[2] < max[2]; cnt[2]++) {
+               for (cnt[1] = min[1]; cnt[1] < max[1]; cnt[1]++)
+                       for (cnt[0] = min[0]; cnt[0] < max[0]; cnt[0]++)
+                       {
+                               const int index = cnt[0] + cnt[1] * res[0] + cnt[2] * res[0]*res[1];
+                               const int bufindex = cnt[dir1] + cnt[dir2] * res[dir1];
+                               buf[bufindex] += field[index] * scale *div;
+                       }
+       }
+       // IMAGE::dumpNumberedPNG(picCnt, prefix, buf, res[dir1], res[dir2]);
+       delete[] buf;
+}
+*/
+
diff --git a/intern/smoke/intern/IMAGE.h b/intern/smoke/intern/IMAGE.h
new file mode 100644 (file)
index 0000000..a57f164
--- /dev/null
@@ -0,0 +1,277 @@
+//////////////////////////////////////////////////////////////////////
+// This file is part of Wavelet Turbulence.
+//
+// Wavelet Turbulence 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 3 of the License, or
+// (at your option) any later version.
+//
+// Wavelet Turbulence 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 Wavelet Turbulence.  If not, see <http://www.gnu.org/licenses/>.
+//
+// Copyright 2008 Theodore Kim and Nils Thuerey
+//
+//////////////////////////////////////////////////////////////////////
+//
+#ifndef IMAGE_H
+#define IMAGE_H
+
+#include <stdlib.h>
+#include <string>
+#include <fstream>
+#include <sstream>
+#include <zlib.h>
+
+//////////////////////////////////////////////////////////////////////
+// NT helper functions
+//////////////////////////////////////////////////////////////////////
+template < class T > inline T ABS( T a ) {
+       return (0 < a) ? a : -a ;
+}
+
+template < class T > inline void SWAP_POINTERS( T &a, T &b ) {
+       T temp = a;
+       a = b;
+       b = temp;
+}
+
+template < class T > inline void CLAMP( T &a, T b=0., T c=1.) {
+       if(a<b) { a=b; return; }
+       if(a>c) { a=c; return; }
+}
+
+template < class T > inline T MIN( T a, T b) {
+       return (a < b) ? a : b;
+}
+
+template < class T > inline T MAX( T a, T b) {
+       return (a > b) ? a : b;
+}
+
+template < class T > inline T MAX3( T a, T b, T c) {
+       T max = (a > b) ? a : b;
+       max = (max > c) ? max : c;
+       return max;
+}
+
+template < class T > inline float MAX3V( T vec) {
+       float max = (vec[0] > vec[1]) ? vec[0] : vec[1];
+       max = (max > vec[2]) ? max : vec[2];
+       return max;
+}
+
+template < class T > inline float MIN3V( T vec) {
+       float min = (vec[0] < vec[1]) ? vec[0] : vec[1];
+       min = (min < vec[2]) ? min : vec[2];
+       return min;
+}
+
+//////////////////////////////////////////////////////////////////////
+// PNG, POV-Ray, and PBRT output functions
+//////////////////////////////////////////////////////////////////////
+#include <png.h>
+
+namespace IMAGE {
+       /*
+  static int writePng(const char *fileName, unsigned char **rowsp, int w, int h)
+  {
+    // defaults
+    const int colortype = PNG_COLOR_TYPE_RGBA;
+    const int bitdepth = 8;
+    png_structp png_ptr = NULL;
+    png_infop info_ptr = NULL;
+    png_bytep *rows = rowsp;
+
+    FILE *fp = NULL;
+    std::string doing = "open for writing";
+    if (!(fp = fopen(fileName, "wb"))) goto fail;
+
+    if(!png_ptr) {
+      doing = "create png write struct";
+      if (!(png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL))) goto fail;
+    }
+    if(!info_ptr) {
+      doing = "create png info struct";
+      if (!(info_ptr = png_create_info_struct(png_ptr))) goto fail;
+    }
+
+    if (setjmp(png_jmpbuf(png_ptr))) goto fail;
+    doing = "init IO";
+    png_init_io(png_ptr, fp);
+    doing = "write header";
+    png_set_IHDR(png_ptr, info_ptr, w, h, bitdepth, colortype, PNG_INTERLACE_NONE,
+        PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
+    doing = "write info";
+    png_write_info(png_ptr, info_ptr);
+    doing = "write image";
+    png_write_image(png_ptr, rows);
+    doing = "write end";
+    png_write_end(png_ptr, NULL);
+    doing = "write destroy structs";
+    png_destroy_write_struct(&png_ptr, &info_ptr);
+
+    fclose( fp );
+    return 0;
+
+  fail:
+    std::cerr << "writePng: could not "<<doing<<" !\n";
+    if(fp) fclose( fp );
+    if(png_ptr || info_ptr) png_destroy_write_struct(&png_ptr, &info_ptr);
+    return -1;
+  }
+  */
+
+  /////////////////////////////////////////////////////////////////////////////////
+  // write a numbered PNG file out, padded with zeros up to three zeros
+  /////////////////////////////////////////////////////////////////////////////////
+  /*
+  static void dumpNumberedPNG(int counter, std::string prefix, float* field, int xRes, int yRes)
+  {
+       char buffer[256];
+    sprintf(buffer,"%04i", counter);
+    std::string number = std::string(buffer);
+
+    unsigned char pngbuf[xRes*yRes*4];
+    unsigned char *rows[yRes];
+    float *pfield = field;
+    for (int j=0; j<yRes; j++) {
+      for (int i=0; i<xRes; i++) {
+        float val = *pfield;
+        if(val>1.) val=1.;
+        if(val<0.) val=0.;
+        pngbuf[(j*xRes+i)*4+0] = (unsigned char)(val*255.);
+        pngbuf[(j*xRes+i)*4+1] = (unsigned char)(val*255.);
+        pngbuf[(j*xRes+i)*4+2] = (unsigned char)(val*255.);
+        pfield++;
+        pngbuf[(j*xRes+i)*4+3] = 255;
+      }
+      rows[j] = &pngbuf[(yRes-j-1)*xRes*4];
+    }
+    std::string filenamePNG = prefix + number + std::string(".png");
+    writePng(filenamePNG.c_str(), rows, xRes, yRes, false);
+    printf("Writing %s\n", filenamePNG.c_str());
+   
+  }
+*/
+  /////////////////////////////////////////////////////////////////////////////////
+  // export pbrt volumegrid geometry object
+  /////////////////////////////////////////////////////////////////////////////////
+       /*
+  static void dumpPBRT(int counter, std::string prefix, float* fieldOrg, int xRes, int yRes, int zRes)
+  {
+    char buffer[256];
+    sprintf(buffer,"%04i", counter);
+    std::string number = std::string(buffer);
+
+    std::string filenamePbrt = prefix + number + std::string(".pbrt.gz");
+    printf("Writing PBRT %s\n", filenamePbrt.c_str());
+
+    float *field = new float[xRes*yRes*zRes];
+    // normalize values
+    float maxDensVal = ABS(fieldOrg[0]);
+    float targetNorm = 0.5;
+    for (int i = 0; i < xRes * yRes * zRes; i++) {
+      if(ABS(fieldOrg[i])>maxDensVal) maxDensVal = ABS(fieldOrg[i]);
+      field[i] = 0.;
+    }
+    if(maxDensVal>0.) {
+      for (int i = 0; i < xRes * yRes * zRes; i++) {
+        field[i] = ABS(fieldOrg[i]) / maxDensVal * targetNorm;
+      }
+    }
+
+    std::fstream fout;
+    fout.open(filenamePbrt.c_str(), std::ios::out);
+
+    int maxRes = (xRes > yRes) ? xRes : yRes;
+    maxRes = (maxRes > zRes) ? maxRes : zRes;
+
+    const float xSize = 1.0 / (float)maxRes * (float)xRes;
+    const float ySize = 1.0 / (float)maxRes * (float)yRes;
+    const float zSize = 1.0 / (float)maxRes * (float)zRes;
+
+    gzFile file;
+    file = gzopen(filenamePbrt.c_str(), "wb1");
+    if (file == NULL) {
+      std::cerr << " Couldn't write file " << filenamePbrt << "!!!" << std::endl;
+      return;
+    }
+
+    // dimensions
+    gzprintf(file, "Volume \"volumegrid\" \n");
+    gzprintf(file, " \"integer nx\" %i\n", xRes);
+    gzprintf(file, " \"integer ny\" %i\n", yRes);
+    gzprintf(file, " \"integer nz\" %i\n", zRes);
+    gzprintf(file, " \"point p0\" [ 0.0 0.0 0.0 ] \"point p1\" [%f %f %f ] \n", xSize, ySize, zSize);
+    gzprintf(file, " \"float density\" [ \n");
+    for (int i = 0; i < xRes * yRes * zRes; i++)
+      gzprintf(file, "%f ", field[i]);
+    gzprintf(file, "] \n \n");
+
+    gzclose(file);
+    delete[] field;
+  }
+  */
+
+  /////////////////////////////////////////////////////////////////////////////////
+  // 3D df3 export
+  /////////////////////////////////////////////////////////////////////////////////
+/*
+  static void dumpDF3(int counter, std::string prefix, float* fieldOrg, int xRes, int yRes, int zRes)
+  {
+    char buffer[256];
+
+    // do deferred copying to final directory, better for network directories
+    sprintf(buffer,"%04i", counter);
+    std::string number = std::string(buffer);
+    std::string filenameDf3 = prefix + number + std::string(".df3.gz");
+    printf("Writing DF3 %s\n", filenameDf3.c_str());
+
+    gzFile file;
+    file = gzopen(filenameDf3.c_str(), "wb1");
+    if (file == NULL) {
+      std::cerr << " Couldn't write file " << filenameDf3 << "!!!" << std::endl;
+      return;
+    }
+
+    // dimensions
+    const int byteSize = 2;
+    const unsigned short int onx=xRes,ony=yRes,onz=zRes;
+    unsigned short int nx,ny,nz;
+    nx = onx >> 8;
+    ny = ony >> 8;
+    nz = onz >> 8;
+    nx += (onx << 8);
+    ny += (ony << 8);
+    nz += (onz << 8);
+    gzwrite(file, (void*)&nx, sizeof(short));
+    gzwrite(file, (void*)&ny, sizeof(short));
+    gzwrite(file, (void*)&nz, sizeof(short));
+    const int nitems = onx*ony*onz;
+    const float mul = (float)( (1<<(8*byteSize))-1);
+
+    unsigned short int *buf = new unsigned short int[nitems];
+    for (int k = 0; k < onz; k++)
+      for (int j = 0; j < ony; j++)
+        for (int i = 0; i < onx; i++) {
+          float val = fieldOrg[k*(onx*ony)+j*onx+i] ;
+          CLAMP(val);
+          buf[k*(onx*ony)+j*onx+i] = (short int)(val*mul);
+        }
+    gzwrite(file, (void*)buf, sizeof(unsigned short int)* nitems);
+
+    gzclose(file);
+    delete[] buf;
+  }
+  */
+
+};
+
+
+#endif
+
diff --git a/intern/smoke/intern/INTERPOLATE.h b/intern/smoke/intern/INTERPOLATE.h
new file mode 100644 (file)
index 0000000..6800c3b
--- /dev/null
@@ -0,0 +1,227 @@
+//////////////////////////////////////////////////////////////////////
+// This file is part of Wavelet Turbulence.
+// 
+// Wavelet Turbulence 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 3 of the License, or
+// (at your option) any later version.
+// 
+// Wavelet Turbulence 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 Wavelet Turbulence.  If not, see <http://www.gnu.org/licenses/>.
+// 
+// Copyright 2008 Theodore Kim and Nils Thuerey
+// 
+//////////////////////////////////////////////////////////////////////
+#ifndef INTERPOLATE_H
+#define INTERPOLATE_H
+
+#include <iostream>
+#include <VEC3.h>
+
+namespace INTERPOLATE {
+
+//////////////////////////////////////////////////////////////////////
+// linear interpolators
+//////////////////////////////////////////////////////////////////////
+static inline float lerp(float t, float a, float b) {
+       return ( a + t * (b - a) );
+}
+
+static inline float lerp(float* field, float x, float y, int res) {
+       // clamp backtrace to grid boundaries
+       if (x < 0.5f) x = 0.5f;
+       if (x > res - 1.5f) x = res - 1.5f;
+       if (y < 0.5f) y = 0.5f;
+       if (y > res - 1.5f) y = res - 1.5f;
+
+       const int x0 = (int)x;
+       const int y0 = (int)y;
+       x -= x0;
+       y -= y0;
+       float d00, d10, d01, d11;
+
+       // lerp the velocities
+       d00 = field[x0 + y0 * res];
+       d10 = field[(x0 + 1) + y0 * res];
+       d01 = field[x0 + (y0 + 1) * res];
+       d11 = field[(x0 + 1) + (y0 + 1) * res];
+       return lerp(y, lerp(x, d00, d10),
+                       lerp(x, d01, d11));
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// 3d linear interpolation
+////////////////////////////////////////////////////////////////////////////////////////// 
+static inline float lerp3d(float* field, float x, float y, float z,  int xres, int yres, int zres) {
+       // clamp pos to grid boundaries
+       if (x < 0.5) x = 0.5;
+       if (x > xres - 1.5) x = xres - 1.5;
+       if (y < 0.5) y = 0.5;
+       if (y > yres - 1.5) y = yres - 1.5;
+       if (z < 0.5) z = 0.5;
+       if (z > zres - 1.5) z = zres - 1.5;
+
+       // locate neighbors to interpolate
+       const int x0 = (int)x;
+       const int x1 = x0 + 1;
+       const int y0 = (int)y;
+       const int y1 = y0 + 1;
+       const int z0 = (int)z;
+       const int z1 = z0 + 1;
+
+       // get interpolation weights
+       const float s1 = x - (float)x0;
+       const float s0 = 1.0f - s1;
+       const float t1 = y - (float)y0;
+       const float t0 = 1.0f - t1;
+       const float u1 = z - (float)z0;
+       const float u0 = 1.0f - u1;
+
+       const int slabSize = xres*yres;
+       const int i000 = x0 + y0 * xres + z0 * slabSize;
+       const int i010 = x0 + y1 * xres + z0 * slabSize;
+       const int i100 = x1 + y0 * xres + z0 * slabSize;
+       const int i110 = x1 + y1 * xres + z0 * slabSize;
+       const int i001 = x0 + y0 * xres + z1 * slabSize;
+       const int i011 = x0 + y1 * xres + z1 * slabSize;
+       const int i101 = x1 + y0 * xres + z1 * slabSize;
+       const int i111 = x1 + y1 * xres + z1 * slabSize;
+
+       // interpolate (indices could be computed once)
+       return ( u0 * (s0 * (t0 * field[i000] +
+               t1 * field[i010]) +
+               s1 * (t0 * field[i100] +
+               t1 * field[i110])) +
+               u1 * (s0 * (t0 * field[i001] +
+               t1 * field[i011]) +
+               s1 * (t0 * field[i101] +
+               t1 * field[i111])) );
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// convert field entries of type T to floats, then interpolate
+//////////////////////////////////////////////////////////////////////////////////////////
+template <class T> 
+static inline float lerp3dToFloat(T* field1,
+               float x, float y, float z,  int xres, int yres, int zres) {
+       // clamp pos to grid boundaries
+       if (x < 0.5) x = 0.5;
+       if (x > xres - 1.5) x = xres - 1.5;
+       if (y < 0.5) y = 0.5;
+       if (y > yres - 1.5) y = yres - 1.5;
+       if (z < 0.5) z = 0.5;
+       if (z > zres - 1.5) z = zres - 1.5;
+
+       // locate neighbors to interpolate
+       const int x0 = (int)x;
+       const int x1 = x0 + 1;
+       const int y0 = (int)y;
+       const int y1 = y0 + 1;
+       const int z0 = (int)z;
+       const int z1 = z0 + 1;
+
+       // get interpolation weights
+       const float s1 = x - (float)x0;
+       const float s0 = 1.0f - s1;
+       const float t1 = y - (float)y0;
+       const float t0 = 1.0f - t1;
+       const float u1 = z - (float)z0;
+       const float u0 = 1.0f - u1;
+
+       const int slabSize = xres*yres;
+       const int i000 = x0 + y0 * xres + z0 * slabSize;
+       const int i010 = x0 + y1 * xres + z0 * slabSize;
+       const int i100 = x1 + y0 * xres + z0 * slabSize;
+       const int i110 = x1 + y1 * xres + z0 * slabSize;
+       const int i001 = x0 + y0 * xres + z1 * slabSize;
+       const int i011 = x0 + y1 * xres + z1 * slabSize;
+       const int i101 = x1 + y0 * xres + z1 * slabSize;
+       const int i111 = x1 + y1 * xres + z1 * slabSize;
+
+       // interpolate (indices could be computed once)
+       return (float)(
+                       ( u0 * (s0 * (t0 * (float)field1[i000] +
+                               t1 * (float)field1[i010]) +
+                               s1 * (t0 * (float)field1[i100] +
+                               t1 * (float)field1[i110])) +
+                               u1 * (s0 * (t0 * (float)field1[i001] +
+                               t1 * (float)field1[i011]) +
+                               s1 * (t0 * (float)field1[i101] +
+                               t1 * (float)field1[i111])) ) );
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// interpolate a vector from 3 fields
+//////////////////////////////////////////////////////////////////////////////////////////
+static inline Vec3 lerp3dVec(float* field1, float* field2, float* field3, 
+               float x, float y, float z,  int xres, int yres, int zres) {
+       // clamp pos to grid boundaries
+       if (x < 0.5) x = 0.5;
+       if (x > xres - 1.5) x = xres - 1.5;
+       if (y < 0.5) y = 0.5;
+       if (y > yres - 1.5) y = yres - 1.5;
+       if (z < 0.5) z = 0.5;
+       if (z > zres - 1.5) z = zres - 1.5;
+
+       // locate neighbors to interpolate
+       const int x0 = (int)x;
+       const int x1 = x0 + 1;
+       const int y0 = (int)y;
+       const int y1 = y0 + 1;
+       const int z0 = (int)z;
+       const int z1 = z0 + 1;
+
+       // get interpolation weights
+       const float s1 = x - (float)x0;
+       const float s0 = 1.0f - s1;
+       const float t1 = y - (float)y0;
+       const float t0 = 1.0f - t1;
+       const float u1 = z - (float)z0;
+       const float u0 = 1.0f - u1;
+
+       const int slabSize = xres*yres;
+       const int i000 = x0 + y0 * xres + z0 * slabSize;
+       const int i010 = x0 + y1 * xres + z0 * slabSize;
+       const int i100 = x1 + y0 * xres + z0 * slabSize;
+       const int i110 = x1 + y1 * xres + z0 * slabSize;
+       const int i001 = x0 + y0 * xres + z1 * slabSize;
+       const int i011 = x0 + y1 * xres + z1 * slabSize;
+       const int i101 = x1 + y0 * xres + z1 * slabSize;
+       const int i111 = x1 + y1 * xres + z1 * slabSize;
+
+       // interpolate (indices could be computed once)
+       return Vec3(
+                       ( u0 * (s0 * (t0 * field1[i000] +
+                               t1 * field1[i010]) +
+                               s1 * (t0 * field1[i100] +
+                               t1 * field1[i110])) +
+                               u1 * (s0 * (t0 * field1[i001] +
+                               t1 * field1[i011]) +
+                               s1 * (t0 * field1[i101] +
+                               t1 * field1[i111])) ) , 
+                       ( u0 * (s0 * (t0 * field2[i000] +
+                               t1 * field2[i010]) +
+                               s1 * (t0 * field2[i100] +
+                               t1 * field2[i110])) +
+                               u1 * (s0 * (t0 * field2[i001] +
+                               t1 * field2[i011]) +
+                               s1 * (t0 * field2[i101] +
+                               t1 * field2[i111])) ) , 
+                       ( u0 * (s0 * (t0 * field3[i000] +
+                               t1 * field3[i010]) +
+                               s1 * (t0 * field3[i100] +
+                               t1 * field3[i110])) +
+                               u1 * (s0 * (t0 * field3[i001] +
+                               t1 * field3[i011]) +
+                               s1 * (t0 * field3[i101] +
+                               t1 * field3[i111])) ) 
+                       );
+}
+
+};
+#endif
diff --git a/intern/smoke/intern/LICENSE.txt b/intern/smoke/intern/LICENSE.txt
new file mode 100644 (file)
index 0000000..94a9ed0
--- /dev/null
@@ -0,0 +1,674 @@
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  You must make sure that they, too, receive
+or can get the source code.  And you must show them these terms so they
+know their rights.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                       TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
+
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
+
+  You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
+
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the&nbs