Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt2
-rwxr-xr-xbuild_files/build_environment/prepare_release_env.sh1555
-rw-r--r--build_files/buildbot/config/user-config-glibc27-i686.py4
-rw-r--r--build_files/buildbot/config/user-config-glibc27-x86_64.py4
-rw-r--r--build_files/buildbot/config/user-config-player-glibc211-i686.py8
-rw-r--r--build_files/buildbot/config/user-config-player-glibc211-x86_64.py8
-rw-r--r--build_files/buildbot/config/user-config-player-glibc27-i686.py11
-rw-r--r--build_files/buildbot/config/user-config-player-glibc27-x86_64.py11
-rw-r--r--build_files/cmake/Modules/FindPythonLibsUnix.cmake63
-rw-r--r--build_files/cmake/cmake_static_check_clang_array.py11
-rw-r--r--build_files/cmake/cmake_static_check_cppcheck.py11
-rw-r--r--build_files/cmake/cmake_static_check_smatch.py11
-rw-r--r--build_files/cmake/cmake_static_check_sparse.py12
-rw-r--r--build_files/cmake/cmake_static_check_splint.py12
-rw-r--r--build_files/scons/config/Modules/FindPython.py2
-rw-r--r--doc/python_api/rst/bge.constraints.rst8
-rw-r--r--doc/python_api/rst/bge.types.rst20
-rw-r--r--extern/carve/lib/intersect_face_division.cpp3
-rw-r--r--extern/glew/src/glew.c4
-rw-r--r--extern/libmv/libmv-capi.cpp10
-rw-r--r--extern/libmv/libmv-capi.h9
-rw-r--r--extern/libmv/libmv/multiview/euclidean_resection.cc17
-rw-r--r--extern/libmv/libmv/multiview/euclidean_resection.h9
-rw-r--r--extern/libmv/libmv/simple_pipeline/pipeline.cc25
-rw-r--r--extern/libmv/libmv/simple_pipeline/pipeline.h12
-rw-r--r--extern/libmv/libmv/simple_pipeline/reconstruction.h11
-rw-r--r--extern/libmv/libmv/simple_pipeline/resect.cc20
-rw-r--r--extern/libmv/libmv/simple_pipeline/resect.h6
-rw-r--r--intern/audaspace/CMakeLists.txt6
-rw-r--r--intern/audaspace/FX/AUD_AccumulatorFactory.cpp8
-rw-r--r--intern/audaspace/FX/AUD_AccumulatorFactory.h4
-rw-r--r--intern/audaspace/FX/AUD_BaseIIRFilterReader.cpp2
-rw-r--r--intern/audaspace/FX/AUD_BaseIIRFilterReader.h2
-rw-r--r--intern/audaspace/FX/AUD_ButterworthFactory.cpp2
-rw-r--r--intern/audaspace/FX/AUD_ButterworthFactory.h2
-rw-r--r--intern/audaspace/FX/AUD_CallbackIIRFilterReader.cpp2
-rw-r--r--intern/audaspace/FX/AUD_CallbackIIRFilterReader.h2
-rw-r--r--intern/audaspace/FX/AUD_DelayFactory.cpp6
-rw-r--r--intern/audaspace/FX/AUD_DelayFactory.h4
-rw-r--r--intern/audaspace/FX/AUD_DelayReader.cpp2
-rw-r--r--intern/audaspace/FX/AUD_DelayReader.h2
-rw-r--r--intern/audaspace/FX/AUD_DoubleFactory.cpp10
-rw-r--r--intern/audaspace/FX/AUD_DoubleFactory.h8
-rw-r--r--intern/audaspace/FX/AUD_DoubleReader.cpp4
-rw-r--r--intern/audaspace/FX/AUD_DoubleReader.h9
-rw-r--r--intern/audaspace/FX/AUD_DynamicIIRFilterFactory.cpp8
-rw-r--r--intern/audaspace/FX/AUD_DynamicIIRFilterFactory.h18
-rw-r--r--intern/audaspace/FX/AUD_DynamicIIRFilterReader.cpp8
-rw-r--r--intern/audaspace/FX/AUD_DynamicIIRFilterReader.h8
-rw-r--r--intern/audaspace/FX/AUD_EffectFactory.cpp4
-rw-r--r--intern/audaspace/FX/AUD_EffectFactory.h8
-rw-r--r--intern/audaspace/FX/AUD_EffectReader.cpp2
-rw-r--r--intern/audaspace/FX/AUD_EffectReader.h7
-rw-r--r--intern/audaspace/FX/AUD_EnvelopeFactory.cpp10
-rw-r--r--intern/audaspace/FX/AUD_EnvelopeFactory.h4
-rw-r--r--intern/audaspace/FX/AUD_FaderFactory.cpp6
-rw-r--r--intern/audaspace/FX/AUD_FaderFactory.h4
-rw-r--r--intern/audaspace/FX/AUD_FaderReader.cpp2
-rw-r--r--intern/audaspace/FX/AUD_FaderReader.h2
-rw-r--r--intern/audaspace/FX/AUD_HighpassFactory.cpp2
-rw-r--r--intern/audaspace/FX/AUD_HighpassFactory.h2
-rw-r--r--intern/audaspace/FX/AUD_IDynamicIIRFilterCalculator.h (renamed from intern/audaspace/intern/AUD_ReferenceHandler.cpp)46
-rw-r--r--intern/audaspace/FX/AUD_IIRFilterFactory.cpp6
-rw-r--r--intern/audaspace/FX/AUD_IIRFilterFactory.h5
-rw-r--r--intern/audaspace/FX/AUD_IIRFilterReader.cpp2
-rw-r--r--intern/audaspace/FX/AUD_IIRFilterReader.h2
-rw-r--r--intern/audaspace/FX/AUD_LimiterFactory.cpp6
-rw-r--r--intern/audaspace/FX/AUD_LimiterFactory.h4
-rw-r--r--intern/audaspace/FX/AUD_LimiterReader.cpp2
-rw-r--r--intern/audaspace/FX/AUD_LimiterReader.h2
-rw-r--r--intern/audaspace/FX/AUD_LoopFactory.cpp6
-rw-r--r--intern/audaspace/FX/AUD_LoopFactory.h4
-rw-r--r--intern/audaspace/FX/AUD_LoopReader.cpp2
-rw-r--r--intern/audaspace/FX/AUD_LoopReader.h2
-rw-r--r--intern/audaspace/FX/AUD_LowpassFactory.cpp2
-rw-r--r--intern/audaspace/FX/AUD_LowpassFactory.h2
-rw-r--r--intern/audaspace/FX/AUD_PingPongFactory.cpp10
-rw-r--r--intern/audaspace/FX/AUD_PingPongFactory.h4
-rw-r--r--intern/audaspace/FX/AUD_PitchFactory.cpp6
-rw-r--r--intern/audaspace/FX/AUD_PitchFactory.h4
-rw-r--r--intern/audaspace/FX/AUD_PitchReader.cpp2
-rw-r--r--intern/audaspace/FX/AUD_PitchReader.h2
-rw-r--r--intern/audaspace/FX/AUD_RectifyFactory.cpp6
-rw-r--r--intern/audaspace/FX/AUD_RectifyFactory.h4
-rw-r--r--intern/audaspace/FX/AUD_ReverseFactory.cpp6
-rw-r--r--intern/audaspace/FX/AUD_ReverseFactory.h4
-rw-r--r--intern/audaspace/FX/AUD_ReverseReader.cpp2
-rw-r--r--intern/audaspace/FX/AUD_ReverseReader.h2
-rw-r--r--intern/audaspace/FX/AUD_SquareFactory.cpp8
-rw-r--r--intern/audaspace/FX/AUD_SquareFactory.h4
-rw-r--r--intern/audaspace/FX/AUD_SumFactory.cpp6
-rw-r--r--intern/audaspace/FX/AUD_SumFactory.h4
-rw-r--r--intern/audaspace/FX/AUD_SuperposeFactory.cpp10
-rw-r--r--intern/audaspace/FX/AUD_SuperposeFactory.h8
-rw-r--r--intern/audaspace/FX/AUD_SuperposeReader.cpp2
-rw-r--r--intern/audaspace/FX/AUD_SuperposeReader.h9
-rw-r--r--intern/audaspace/FX/AUD_VolumeFactory.cpp6
-rw-r--r--intern/audaspace/FX/AUD_VolumeFactory.h4
-rw-r--r--intern/audaspace/OpenAL/AUD_OpenALDevice.cpp63
-rw-r--r--intern/audaspace/OpenAL/AUD_OpenALDevice.h14
-rw-r--r--intern/audaspace/Python/AUD_PyAPI.cpp170
-rw-r--r--intern/audaspace/SConscript2
-rw-r--r--intern/audaspace/ffmpeg/AUD_FFMPEGFactory.cpp8
-rw-r--r--intern/audaspace/ffmpeg/AUD_FFMPEGFactory.h6
-rw-r--r--intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp2
-rw-r--r--intern/audaspace/ffmpeg/AUD_FFMPEGReader.h6
-rw-r--r--intern/audaspace/intern/AUD_BufferReader.cpp2
-rw-r--r--intern/audaspace/intern/AUD_BufferReader.h7
-rw-r--r--intern/audaspace/intern/AUD_C-API.cpp140
-rw-r--r--intern/audaspace/intern/AUD_C-API.h4
-rw-r--r--intern/audaspace/intern/AUD_ChannelMapperFactory.cpp8
-rw-r--r--intern/audaspace/intern/AUD_ChannelMapperFactory.h4
-rw-r--r--intern/audaspace/intern/AUD_ChannelMapperReader.cpp2
-rw-r--r--intern/audaspace/intern/AUD_ChannelMapperReader.h2
-rw-r--r--intern/audaspace/intern/AUD_ConverterFactory.cpp8
-rw-r--r--intern/audaspace/intern/AUD_ConverterFactory.h4
-rw-r--r--intern/audaspace/intern/AUD_ConverterReader.cpp2
-rw-r--r--intern/audaspace/intern/AUD_ConverterReader.h2
-rw-r--r--intern/audaspace/intern/AUD_FileFactory.cpp14
-rw-r--r--intern/audaspace/intern/AUD_FileFactory.h6
-rw-r--r--intern/audaspace/intern/AUD_FileWriter.cpp10
-rw-r--r--intern/audaspace/intern/AUD_FileWriter.h9
-rw-r--r--intern/audaspace/intern/AUD_IDevice.h7
-rw-r--r--intern/audaspace/intern/AUD_IFactory.h5
-rw-r--r--intern/audaspace/intern/AUD_JOSResampleFactory.cpp6
-rw-r--r--intern/audaspace/intern/AUD_JOSResampleFactory.h4
-rw-r--r--intern/audaspace/intern/AUD_JOSResampleReader.cpp2
-rw-r--r--intern/audaspace/intern/AUD_JOSResampleReader.h2
-rw-r--r--intern/audaspace/intern/AUD_LinearResampleFactory.cpp6
-rw-r--r--intern/audaspace/intern/AUD_LinearResampleFactory.h4
-rw-r--r--intern/audaspace/intern/AUD_LinearResampleReader.cpp2
-rw-r--r--intern/audaspace/intern/AUD_LinearResampleReader.h2
-rw-r--r--intern/audaspace/intern/AUD_Mixer.h3
-rw-r--r--intern/audaspace/intern/AUD_MixerFactory.cpp6
-rw-r--r--intern/audaspace/intern/AUD_MixerFactory.h8
-rw-r--r--intern/audaspace/intern/AUD_NULLDevice.cpp8
-rw-r--r--intern/audaspace/intern/AUD_NULLDevice.h4
-rw-r--r--intern/audaspace/intern/AUD_Reference.h275
-rw-r--r--intern/audaspace/intern/AUD_ResampleReader.cpp2
-rw-r--r--intern/audaspace/intern/AUD_ResampleReader.h2
-rw-r--r--intern/audaspace/intern/AUD_Sequencer.cpp176
-rw-r--r--intern/audaspace/intern/AUD_Sequencer.h206
-rw-r--r--intern/audaspace/intern/AUD_SequencerEntry.cpp4
-rw-r--r--intern/audaspace/intern/AUD_SequencerEntry.h8
-rw-r--r--intern/audaspace/intern/AUD_SequencerFactory.cpp109
-rw-r--r--intern/audaspace/intern/AUD_SequencerFactory.h59
-rw-r--r--intern/audaspace/intern/AUD_SequencerHandle.cpp20
-rw-r--r--intern/audaspace/intern/AUD_SequencerHandle.h10
-rw-r--r--intern/audaspace/intern/AUD_SequencerReader.cpp66
-rw-r--r--intern/audaspace/intern/AUD_SequencerReader.h14
-rw-r--r--intern/audaspace/intern/AUD_SilenceFactory.cpp4
-rw-r--r--intern/audaspace/intern/AUD_SilenceFactory.h2
-rw-r--r--intern/audaspace/intern/AUD_SinusFactory.cpp4
-rw-r--r--intern/audaspace/intern/AUD_SinusFactory.h2
-rw-r--r--intern/audaspace/intern/AUD_SoftwareDevice.cpp83
-rw-r--r--intern/audaspace/intern/AUD_SoftwareDevice.h22
-rw-r--r--intern/audaspace/intern/AUD_StreamBufferFactory.cpp8
-rw-r--r--intern/audaspace/intern/AUD_StreamBufferFactory.h9
-rw-r--r--intern/audaspace/sndfile/AUD_SndFileFactory.cpp8
-rw-r--r--intern/audaspace/sndfile/AUD_SndFileFactory.h6
-rw-r--r--intern/audaspace/sndfile/AUD_SndFileReader.cpp2
-rw-r--r--intern/audaspace/sndfile/AUD_SndFileReader.h6
-rw-r--r--intern/bsp/intern/BOP_CarveInterface.cpp9
-rw-r--r--intern/cycles/blender/addon/enums.py7
-rw-r--r--intern/cycles/blender/addon/ui.py6
-rw-r--r--intern/cycles/blender/blender_mesh.cpp125
-rw-r--r--intern/cycles/blender/blender_python.cpp10
-rw-r--r--intern/cycles/blender/blender_session.cpp7
-rw-r--r--intern/cycles/blender/blender_shader.cpp56
-rw-r--r--intern/cycles/device/device.cpp12
-rw-r--r--intern/cycles/device/device.h8
-rw-r--r--intern/cycles/device/device_cpu.cpp14
-rw-r--r--intern/cycles/device/device_cuda.cpp20
-rw-r--r--intern/cycles/device/device_intern.h10
-rw-r--r--intern/cycles/device/device_multi.cpp10
-rw-r--r--intern/cycles/device/device_network.cpp8
-rw-r--r--intern/cycles/device/device_opencl.cpp11
-rw-r--r--intern/cycles/kernel/CMakeLists.txt1
-rw-r--r--intern/cycles/kernel/closure/bsdf_phong_ramp.h140
-rw-r--r--intern/cycles/kernel/closure/bsdf_ward.h10
-rw-r--r--intern/cycles/kernel/kernel_object.h3
-rw-r--r--intern/cycles/kernel/kernel_path.h9
-rw-r--r--intern/cycles/kernel/kernel_shader.h21
-rw-r--r--intern/cycles/kernel/kernel_types.h15
-rw-r--r--intern/cycles/kernel/osl/CMakeLists.txt1
-rw-r--r--intern/cycles/kernel/osl/background.cpp27
-rw-r--r--intern/cycles/kernel/osl/bsdf_phong_ramp.cpp115
-rw-r--r--intern/cycles/kernel/osl/osl_closures.cpp5
-rw-r--r--intern/cycles/kernel/osl/osl_closures.h8
-rw-r--r--intern/cycles/kernel/osl/osl_globals.h1
-rw-r--r--intern/cycles/kernel/osl/osl_services.cpp312
-rw-r--r--intern/cycles/kernel/osl/osl_services.h19
-rw-r--r--intern/cycles/kernel/osl/osl_shader.cpp31
-rw-r--r--intern/cycles/kernel/shaders/CMakeLists.txt12
-rw-r--r--intern/cycles/kernel/shaders/node_ambient_occlusion.osl27
-rw-r--r--intern/cycles/kernel/shaders/node_geometry.osl15
-rw-r--r--intern/cycles/kernel/shaders/node_normal_map.osl48
-rw-r--r--intern/cycles/kernel/shaders/node_refraction_bsdf.osl39
-rw-r--r--intern/cycles/kernel/shaders/node_tangent.osl50
-rw-r--r--intern/cycles/kernel/shaders/node_ward_bsdf.osl27
-rw-r--r--intern/cycles/kernel/shaders/stdosl.h2
-rw-r--r--intern/cycles/kernel/svm/svm.h9
-rw-r--r--intern/cycles/kernel/svm/svm_bsdf.h11
-rw-r--r--intern/cycles/kernel/svm/svm_closure.h85
-rw-r--r--intern/cycles/kernel/svm/svm_geometry.h46
-rw-r--r--intern/cycles/kernel/svm/svm_image.h6
-rw-r--r--intern/cycles/kernel/svm/svm_tex_coord.h86
-rw-r--r--intern/cycles/kernel/svm/svm_types.h31
-rw-r--r--intern/cycles/render/attribute.cpp4
-rw-r--r--intern/cycles/render/buffers.cpp2
-rw-r--r--intern/cycles/render/graph.cpp1
-rw-r--r--intern/cycles/render/graph.h5
-rw-r--r--intern/cycles/render/image.h3
-rw-r--r--intern/cycles/render/mesh.cpp5
-rw-r--r--intern/cycles/render/nodes.cpp290
-rw-r--r--intern/cycles/render/nodes.h40
-rw-r--r--intern/cycles/render/osl.cpp3
-rw-r--r--intern/cycles/render/session.cpp12
-rw-r--r--intern/cycles/render/session.h2
-rw-r--r--intern/cycles/render/tile.cpp20
-rw-r--r--intern/cycles/util/util_attribute.cpp4
-rw-r--r--intern/cycles/util/util_math.h23
-rw-r--r--intern/cycles/util/util_opencl.cpp4
-rw-r--r--intern/cycles/util/util_stats.h53
-rw-r--r--intern/cycles/util/util_thread.h3
-rw-r--r--intern/cycles/util/util_types.h3
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.mm8
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.cpp2
-rw-r--r--intern/ghost/intern/GHOST_WindowCocoa.mm12
-rw-r--r--intern/itasc/kdl/chain.hpp2
-rw-r--r--intern/itasc/kdl/tree.hpp4
-rw-r--r--release/datafiles/blender_icons.pngbin228428 -> 228237 bytes
-rw-r--r--release/datafiles/prvicons.pngbin14130 -> 13948 bytes
-rw-r--r--release/scripts/modules/bl_i18n_utils/spell_check_utils.py3
-rw-r--r--release/scripts/startup/bl_ui/properties_data_camera.py10
-rw-r--r--release/scripts/startup/bl_ui/properties_render.py6
-rw-r--r--release/scripts/startup/bl_ui/space_clip.py7
-rw-r--r--release/scripts/startup/bl_ui/space_logic.py5
-rw-r--r--release/scripts/startup/bl_ui/space_sequencer.py4
-rw-r--r--release/scripts/startup/bl_ui/space_text.py12
-rw-r--r--release/scripts/startup/bl_ui/space_time.py5
-rw-r--r--release/scripts/startup/bl_ui/space_view3d.py1
-rw-r--r--release/scripts/startup/bl_ui/space_view3d_toolbar.py2
-rw-r--r--source/blender/blenkernel/BKE_blender.h2
-rw-r--r--source/blender/blenkernel/BKE_global.h3
-rw-r--r--source/blender/blenkernel/BKE_node.h4
-rw-r--r--source/blender/blenkernel/BKE_sequencer.h1
-rw-r--r--source/blender/blenkernel/BKE_utildefines.h6
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c9
-rw-r--r--source/blender/blenkernel/intern/depsgraph.c3
-rw-r--r--source/blender/blenkernel/intern/library.c1
-rw-r--r--source/blender/blenkernel/intern/movieclip.c39
-rw-r--r--source/blender/blenkernel/intern/node.c4
-rw-r--r--source/blender/blenkernel/intern/particle_system.c13
-rw-r--r--source/blender/blenkernel/intern/scene.c10
-rw-r--r--source/blender/blenkernel/intern/sequencer.c38
-rw-r--r--source/blender/blenkernel/intern/shrinkwrap.c83
-rw-r--r--source/blender/blenkernel/intern/smoke.c3
-rw-r--r--source/blender/blenkernel/intern/text.c28
-rw-r--r--source/blender/blenkernel/intern/tracking.c39
-rw-r--r--source/blender/blenlib/BLI_bpath.h5
-rw-r--r--source/blender/blenlib/BLI_math_matrix.h3
-rw-r--r--source/blender/blenlib/BLI_quadric.h2
-rw-r--r--source/blender/blenlib/intern/BLI_kdopbvh.c2
-rw-r--r--source/blender/blenlib/intern/bpath.c70
-rw-r--r--source/blender/blenlib/intern/math_matrix.c62
-rw-r--r--source/blender/blenlib/intern/quadric.c9
-rw-r--r--source/blender/blenlib/intern/smallhash.c18
-rw-r--r--source/blender/blenloader/intern/readfile.c119
-rw-r--r--source/blender/blenloader/intern/writefile.c22
-rw-r--r--source/blender/bmesh/intern/bmesh_decimate_collapse.c17
-rw-r--r--source/blender/bmesh/intern/bmesh_operator_api.h2
-rw-r--r--source/blender/bmesh/intern/bmesh_operators.c14
-rw-r--r--source/blender/bmesh/operators/bmo_mirror.c2
-rw-r--r--source/blender/bmesh/operators/bmo_removedoubles.c61
-rw-r--r--source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_KeyingScreenOperation.cpp27
-rw-r--r--source/blender/editors/animation/keyingsets.c20
-rw-r--r--source/blender/editors/curve/editfont.c26
-rw-r--r--source/blender/editors/interface/interface.c10
-rw-r--r--source/blender/editors/interface/interface_draw.c18
-rw-r--r--source/blender/editors/interface/interface_handlers.c8
-rw-r--r--source/blender/editors/interface/interface_intern.h20
-rw-r--r--source/blender/editors/interface/interface_layout.c6
-rw-r--r--source/blender/editors/object/object_transform.c7
-rw-r--r--source/blender/editors/physics/physics_fluid.c3
-rw-r--r--source/blender/editors/render/render_internal.c6
-rw-r--r--source/blender/editors/render/render_preview.c51
-rw-r--r--source/blender/editors/render/render_update.c6
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c168
-rw-r--r--source/blender/editors/space_clip/clip_draw.c2
-rw-r--r--source/blender/editors/space_clip/tracking_ops.c21
-rw-r--r--source/blender/editors/space_file/filelist.c1
-rw-r--r--source/blender/editors/space_file/filesel.c2
-rw-r--r--source/blender/editors/space_image/image_ops.c4
-rw-r--r--source/blender/editors/space_info/space_info.c8
-rw-r--r--source/blender/editors/space_node/drawnode.c108
-rw-r--r--source/blender/editors/space_node/node_draw.c2
-rw-r--r--source/blender/editors/space_node/node_edit.c2
-rw-r--r--source/blender/editors/space_node/node_group.c38
-rw-r--r--source/blender/editors/space_sequencer/sequencer_add.c4
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c4
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c10
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c47
-rw-r--r--source/blender/editors/space_view3d/view3d_snap.c79
-rw-r--r--source/blender/editors/transform/transform.c48
-rw-r--r--source/blender/editors/transform/transform.h1
-rw-r--r--source/blender/editors/transform/transform_conversions.c6
-rw-r--r--source/blender/editors/uvedit/uvedit_unwrap_ops.c111
-rw-r--r--source/blender/gpu/GPU_material.h1
-rw-r--r--source/blender/gpu/intern/gpu_codegen.c9
-rw-r--r--source/blender/gpu/shaders/gpu_shader_material.glsl32
-rw-r--r--source/blender/imbuf/IMB_imbuf.h2
-rw-r--r--source/blender/imbuf/intern/colormanagement.c2
-rw-r--r--source/blender/imbuf/intern/png.c3
-rw-r--r--source/blender/imbuf/intern/readimage.c6
-rw-r--r--source/blender/imbuf/intern/thumbs.c2
-rw-r--r--source/blender/makesdna/DNA_movieclip_types.h56
-rw-r--r--source/blender/makesdna/DNA_node_types.h33
-rw-r--r--source/blender/makesdna/DNA_scene_types.h11
-rw-r--r--source/blender/makesdna/DNA_sequence_types.h3
-rw-r--r--source/blender/makesdna/DNA_tracking_types.h155
-rw-r--r--source/blender/makesrna/intern/rna_action.c9
-rw-r--r--source/blender/makesrna/intern/rna_animation.c51
-rw-r--r--source/blender/makesrna/intern/rna_boid.c8
-rw-r--r--source/blender/makesrna/intern/rna_color.c37
-rw-r--r--source/blender/makesrna/intern/rna_curve.c6
-rw-r--r--source/blender/makesrna/intern/rna_mask.c3
-rw-r--r--source/blender/makesrna/intern/rna_mesh.c3
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c3
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c103
-rw-r--r--source/blender/makesrna/intern/rna_nodetree_types.h6
-rw-r--r--source/blender/makesrna/intern/rna_object.c8
-rw-r--r--source/blender/makesrna/intern/rna_object_force.c6
-rw-r--r--source/blender/makesrna/intern/rna_particle.c6
-rw-r--r--source/blender/makesrna/intern/rna_pose.c11
-rw-r--r--source/blender/makesrna/intern/rna_render.c5
-rw-r--r--source/blender/makesrna/intern/rna_scene.c19
-rw-r--r--source/blender/makesrna/intern/rna_sequencer.c12
-rw-r--r--source/blender/makesrna/intern/rna_sequencer_api.c2
-rw-r--r--source/blender/makesrna/intern/rna_tracking.c38
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c2
-rw-r--r--source/blender/makesrna/intern/rna_wm_api.c4
-rw-r--r--source/blender/nodes/CMakeLists.txt28
-rw-r--r--source/blender/nodes/NOD_shader.h4
-rw-r--r--source/blender/nodes/NOD_socket.h1
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_keyingscreen.c27
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_math.c3
-rw-r--r--source/blender/nodes/intern/node_socket.c34
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c63
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c5
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c68
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_math.c40
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_normal_map.c69
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_script.c15
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tangent.c60
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_vectMath.c21
-rw-r--r--source/blender/python/generic/bgl.c4
-rw-r--r--source/blender/python/generic/bpy_internal_import.c18
-rw-r--r--source/blender/python/generic/idprop_py_api.c4
-rw-r--r--source/blender/python/intern/bpy.c5
-rw-r--r--source/blender/python/intern/bpy_rna.c4
-rw-r--r--source/blender/python/intern/bpy_util.h14
-rw-r--r--source/blender/python/mathutils/mathutils_Color.c4
-rw-r--r--source/blender/python/mathutils/mathutils_Euler.c4
-rw-r--r--source/blender/python/mathutils/mathutils_Matrix.c6
-rw-r--r--source/blender/python/mathutils/mathutils_Quaternion.c4
-rw-r--r--source/blender/python/mathutils/mathutils_Vector.c4
-rw-r--r--source/blender/quicktime/quicktime_export.h4
-rw-r--r--source/blender/render/extern/include/RE_engine.h1
-rw-r--r--source/blender/render/extern/include/RE_pipeline.h1
-rw-r--r--source/blender/render/intern/include/render_types.h2
-rw-r--r--source/blender/render/intern/source/convertblender.c2
-rw-r--r--source/blender/render/intern/source/envmap.c3
-rw-r--r--source/blender/render/intern/source/external_engine.c12
-rw-r--r--source/blender/render/intern/source/initrender.c26
-rw-r--r--source/blender/render/intern/source/pipeline.c7
-rw-r--r--source/blender/render/intern/source/renderdatabase.c3
-rw-r--r--source/blender/render/intern/source/shadbuf.c2
-rw-r--r--source/blender/windowmanager/WM_api.h6
-rw-r--r--source/blender/windowmanager/intern/wm_draw.c4
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c64
-rw-r--r--source/blender/windowmanager/intern/wm_files.c4
-rw-r--r--source/blender/windowmanager/intern/wm_jobs.c29
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c41
-rw-r--r--source/blenderplayer/bad_level_call_stubs/stubs.c1
-rw-r--r--source/gameengine/BlenderRoutines/CMakeLists.txt1
-rw-r--r--source/gameengine/BlenderRoutines/SConscript1
-rw-r--r--source/gameengine/Converter/CMakeLists.txt2
-rw-r--r--source/gameengine/Converter/KX_ConvertActuators.cpp8
-rw-r--r--source/gameengine/Converter/SConscript1
-rw-r--r--source/gameengine/Ketsji/CMakeLists.txt3
-rw-r--r--source/gameengine/Ketsji/KX_CharacterWrapper.cpp94
-rw-r--r--source/gameengine/Ketsji/KX_CharacterWrapper.h35
-rw-r--r--source/gameengine/Ketsji/KX_ObjectActuator.cpp2
-rw-r--r--source/gameengine/Ketsji/KX_PyConstraintBinding.cpp34
-rw-r--r--source/gameengine/Ketsji/KX_PythonInitTypes.cpp2
-rw-r--r--source/gameengine/Ketsji/KX_SoundActuator.cpp72
-rw-r--r--source/gameengine/Ketsji/KX_SoundActuator.h8
-rw-r--r--source/gameengine/Ketsji/SConscript1
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp40
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h2
-rw-r--r--source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h6
-rw-r--r--source/gameengine/Physics/common/CMakeLists.txt1
-rw-r--r--source/gameengine/Physics/common/PHY_ICharacter.h30
-rw-r--r--source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h4
409 files changed, 7089 insertions, 2239 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b53c6f6b71f..c33f4384a76 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -291,7 +291,7 @@ if(APPLE)
message(STATUS "Detected system-version: " ${OSX_SYSTEM})
if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
- set(CMAKE_OSX_DEPLOYMENT_TARGET "10.5" CACHE STRING "" FORCE) # 10.5 is our minimum target, if you have higher sdk, weak linking happens
+ set(CMAKE_OSX_DEPLOYMENT_TARGET "10.6" CACHE STRING "" FORCE) # 10.6 is our min. target, if you use higher sdk, weak linking happens - with 10.5 we have still not solved problems, build those with 10.5.sdk for now !!!
endif()
if(${CMAKE_GENERATOR} MATCHES "Xcode")
diff --git a/build_files/build_environment/prepare_release_env.sh b/build_files/build_environment/prepare_release_env.sh
new file mode 100755
index 00000000000..9889feadcd2
--- /dev/null
+++ b/build_files/build_environment/prepare_release_env.sh
@@ -0,0 +1,1555 @@
+#!/bin/sh
+
+#
+# This script will prepare build environment with the same settings as release environment
+#
+# It will install two chroot environments:
+# - /home/buildbot_squeeze_i686
+# - /home/buildbot_squeeze_x86_64
+# which are used for 32bit and 64bit
+#
+# This sctipt will also create folder /home/sources where all dependent libraries sources are
+# downloading and compiling.
+#
+# Release builder scripts are stored in /home/sources/release-builder
+# See build_all.sh script for usage details
+#
+# This script was tested on debian squeeze and wheezy, should work on ubuntu as well
+# It wouldn't work on other distros
+#
+# TODO:
+# - It's still required manual copying of build configuration files to /home/sources/release-builder/config
+# - OSL is not set up yet
+#
+
+set -e
+
+NO_COLOR='\033[0m'
+EWHITE='\033[1;37m'
+ERED='\033[1;31m'
+
+CONFIRM="--i-really-do-know-what-im-doing"
+
+ERROR() {
+ echo ${ERED}${@}${NO_COLOR}
+}
+
+INFO() {
+ echo ${EWHITE}${@}${NO_COLOR}
+}
+
+if [ $# != 1 ]; then
+ ERROR "Usage: $0 $CONFIRM"
+ exit 1
+fi
+
+if [ "$1" != "$CONFIRM" ]; then
+ ERROR "Usage: $0 $CONFIRM"
+ exit 1
+fi
+
+DEBIAN_BRANCH="squeeze"
+DEBIAN_MIRROR="http://ftp.de.debian.org/debian"
+USER_ID=1000
+
+# For now it's always /home, so we can setup schroot to map /sources to the same
+# path at both host and chroot systems (which is currently needed for release building script)
+ENV_PATH="/home"
+
+AMD64_PATH="$ENV_PATH/buildbot_${DEBIAN_BRANCH}_x86_64"
+I686_PATH="$ENV_PATH/buildbot_${DEBIAN_BRANCH}_i686"
+SOURCES_PATH="$ENV_PATH/sources"
+
+THREADS=`cat /proc/cpuinfo | grep cores | uniq | sed -e "s/.*: *\(.*\)/\\1/"`
+
+# Force vpx be installed from the backports
+VPX_V="1.0.0-2~bpo60+1"
+
+BINUTILS_V="2.22"
+BINUTILS_FV="2.22-7.1"
+
+GCC_V="4.7_4.7.1"
+GCC_FV="4.7_4.7.1-7"
+
+OPENAL_V="1.14"
+
+DPKG_V="1.16.8"
+
+DEBHELPER_V="9"
+DEBHELPER_FV="9.20120909"
+
+JEMALLOC_V="3.1.0"
+SPNAV_V="0.2.2"
+FFMPEG_V="1.0"
+BOOST_V="1_51_0"
+PYTHON_V="3.3.0"
+PYTHIN_V_SHORT="3.3"
+OIIO_V="1.0.9"
+OCIO_V="1.0.7"
+MESA_V="8.0.5"
+
+OPENSSL_V="0.9.8o"
+OPENSSL_FV="0.9.8o-4squeeze13"
+
+CUDA_V="4.2.9"
+CUDA_DISTR="ubuntu10.04"
+CUDA_32="cudatoolkit_${CUDA_V}_linux_32_${CUDA_DISTR}.run"
+CUDA_64="cudatoolkit_${CUDA_V}_linux_64_${CUDA_DISTR}.run"
+
+INSTALL_RELEASE_BUILDER() {
+ SOURCES_PATH=$1
+
+ RB=$SOURCES_PATH/release-builder
+ if [ ! -d $RB ]; then
+ INFO "Installing release building scripts"
+
+ mkdir -p $RB
+
+ cat << EOF > $RB/Readme.txt
+This directory contains scrips needed for automated release archive preparation
+
+config/: storage of scons configs for different platforms
+
+build_all.sh: script asks version to add to archive name and revision to compile,
+ when script finished, there'll be 32 and 64 bit archives in current directory
+ better to run this script from this directory
+
+do_build_all.sh: uses environment variables set by build_all.sh script (or other scripts)
+ and launches compilation inside chroot environments
+
+chroot_compile.py: runs compilation process with giver parameters in chroots
+compile.py: script runs inside chroot environment and prepares archive
+
+blender-buildenv.tar.bz2: archive, received from Ken Hughes when i've been preparing
+ new environment to make it as close to old one as it's possible
+
+Hope all this would help you.
+
+-Sergey-
+EOF
+
+ cat << EOF > $RB/build_all.sh
+#!/bin/sh
+
+echo -n "version: "
+read version
+echo -n "svn revision (blank to latest, 0 to keep unchanged): "
+read revision
+
+export version
+export revision
+
+d=\`dirname \${0}\`
+\${d}/do_build_all.sh
+EOF
+ chmod +x $RB/build_all.sh
+
+ cat << EOF > $RB/build_all-test.sh
+#!/bin/sh
+
+d=\`dirname \${0}\`
+\${d}/do_build_all.sh
+EOF
+ chmod +x $RB/build_all-test.sh
+
+ cat << EOF > $RB/chroot-compile.py
+#!/usr/bin/env python
+
+import sys
+import os
+import platform
+
+from optparse import OptionParser
+
+# This could be passed through options, but does we actually need this?
+bl_source = '/home/sources/blender'
+build_dir = '/home/sources/blender-build/'
+install_dir = '/home/sources/blender-install/'
+with_player = True
+
+# Default config
+curr_arch = platform.architecture()[0]
+def_arch = 'x86_64' if curr_arch == '64bit' else 'i686'
+builder_dir = os.path.dirname(os.path.realpath(__file__))
+
+# XXX: bad thing!
+# builder_dir = builder_dir.replace("sources-new", "sources")
+
+def_cores = 1
+if hasattr(os, 'sysconf'):
+ if 'SC_NPROCESSORS_ONLN' in os.sysconf_names:
+ def_cores = os.sysconf('SC_NPROCESSORS_ONLN')
+
+# Per-architecture chroot name
+chroots = { 'i686': 'buildbot_squeeze_i686',
+ 'x86_64': 'buildbot_squeeze_x86_64'}
+
+# Parse command line
+op = OptionParser()
+op.add_option('--tag', default = None)
+op.add_option('--branch', default = None)
+op.add_option('--arch', default = def_arch)
+op.add_option('--cores', default = def_cores)
+op.add_option('--bl-version', default = 'UNDEFINED')
+op.add_option('--no-clean', default = False)
+(opts, args) = op.parse_args()
+
+if opts.arch not in chroots:
+ print('Error: No configured machine gound to build ' +
+ '{0} version' . format(opts.arch))
+ sys.exit(1)
+
+chroot = chroots[opts.arch]
+
+if opts.tag:
+ bl_source = '/home/sources/blender-tags/' + opts.tag
+elif opts.branch:
+ bl_source = '/home/sources/blender-branches/' + opts.branch
+
+if not os.path.isdir(bl_source):
+ print('Uname to find directory with sources: ' + bl_source)
+ sys.exit(1)
+
+print('Building {0} version, machine is {1}' . format(opts.bl_version, opts.arch))
+
+# Assume builder directory is binded to the same location in
+# chroot environments
+compiler = os.path.join(builder_dir, 'compile.py')
+
+cmd = 'schroot -c %s -d /home/sources/release-builder --' % (chroot)
+cmd += ' python %s' % (compiler)
+cmd += ' --bl-version=%s' % (opts.bl_version)
+cmd += ' --bl-source=%s' % (bl_source)
+cmd += ' --arch=%s' % (opts.arch)
+cmd += ' --build-dir=%s' % (build_dir)
+cmd += ' --install-dir=%s' % (install_dir)
+
+if opts.no_clean:
+ cmd += ' --no-clean=1'
+
+if with_player:
+ cmd += ' --with-player=1'
+
+#if opts.branch:
+# cmd += ' --use-new-ffmpeg=1'
+
+result = os.system(cmd)
+if result != 0:
+ print('compiler script exited with errcode: %s' % (result))
+ sys.exit(1)
+EOF
+ chmod +x $RB/chroot-compile.py
+
+ cat << EOF > $RB/compile.py
+#!/usr/bin/env python
+
+import platform
+import sys
+import os
+import shutil
+
+from optparse import OptionParser
+
+# Default config
+curr_arch = platform.architecture()[0]
+def_arch = 'x86_64' if curr_arch == '64bit' else 'i686'
+builder_dir = os.path.dirname(os.path.realpath(__file__))
+
+def_cores = 1
+if hasattr(os, 'sysconf'):
+ if 'SC_NPROCESSORS_ONLN' in os.sysconf_names:
+ def_cores = os.sysconf('SC_NPROCESSORS_ONLN')
+
+# Parse command line
+op = OptionParser()
+op.add_option('--arch', default = def_arch)
+op.add_option('--cores', default = def_cores)
+op.add_option('--no-clean', default = False)
+op.add_option('--bl-version', default = 'UNKNOWN')
+op.add_option('--bl-source', default = '')
+op.add_option('--config-dir', default = '')
+op.add_option('--build-dir', default = '')
+op.add_option('--install-dir', default = '')
+op.add_option('--with-player', default = False)
+#op.add_option('--use-new-ffmpeg', default = False)
+(opts, args) = op.parse_args()
+
+if opts.config_dir == '':
+ opts.config_dir = os.path.join(builder_dir, 'config')
+
+# Initial directory checking (could be problems with permissions)
+if not os.path.isdir(opts.bl_source):
+ print('Blender\'s source tree not found: %s' % (opts.bl_source))
+ sys.exit(1)
+
+if not os.path.isdir(opts.config_dir):
+ print('Directory with configuration files not found: %s' % (opts.config_dir))
+ sys.exit(1)
+
+if not os.path.isdir(os.path.dirname(opts.build_dir)):
+ print('Build directory can\'t be reached: %s' % (opts.build_dir))
+ sys.exit(1)
+
+if not os.path.isdir(os.path.dirname(opts.install_dir)):
+ print('Install directory can\'t be reached: %s' % (opts.install_dir))
+ sys.exit(1)
+
+# Detect glibc version
+libc = [name for name in os.listdir('/lib') if 'libc.so.' in name]
+if len(libc) == 0:
+ print('Could not find "/lib/libc.so.*": cannot determine glibc version')
+ sys.exit(-1)
+
+if len(libc) > 1:
+ print('warning: found more than one "/lib/libc.so.*": '+
+ 'using %s' % (libc[0]))
+
+glibc = 'glibc' + os.readlink('/lib/' + libc[0])[5:][:-3].replace('.', '')
+glibc = glibc[:8]
+
+# Full name for archive
+full_name = 'blender-%s-linux-%s-%s' % (opts.bl_version, glibc, opts.arch)
+build_dir = os.path.join(opts.build_dir, full_name)
+install_dir = os.path.join(opts.install_dir, full_name)
+scons = os.path.join(opts.bl_source, 'scons', 'scons.py')
+scons_cmd = 'python %s -C %s' % (scons, opts.bl_source)
+config = os.path.join(opts.config_dir, 'user-config-' + glibc + '-' + opts.arch + '.py')
+
+if not os.path.isfile(config):
+ print('Configuration file not found: %s' % (config))
+ sys.exit(1)
+
+# Clean build directory
+if not opts.no_clean:
+ print('Cleaning up build directory...')
+ os.system('%s BF_BUILDDIR=%s clean ' % (scons_cmd, build_dir))
+
+# Clean install directory
+if os.path.isdir(install_dir):
+ shutil.rmtree(install_dir)
+
+flags = ""
+
+# Switch to newer libraries if needed
+#if opts.use_new_ffmpeg:
+# print("Using new ffmpeg-0.8.1")
+# flags += " BF_FFMPEG='/home/sources/staticlibs/ffmpeg-0.8'"
+
+# Build blenderplayer first
+# (to be sure all stuff needed for blender would copied automatically)
+if opts.with_player:
+ player_config = os.path.join(opts.config_dir,
+ 'user-config-player-' + glibc + '-' + opts.arch + '.py')
+
+ if not os.path.isfile(player_config):
+ print('Player configuration file not found: %s' % (player_config))
+ sys.exit(1)
+
+ cmd = '%s -j %d blenderplayer ' % (scons_cmd, opts.cores + 1)
+ cmd += ' BF_BUILDDIR=%s' % (build_dir + '-player')
+ cmd += ' BF_INSTALLDIR=%s' % (install_dir)
+ cmd += ' BF_CONFIG=%s' % (player_config)
+ cmd += flags
+
+ result = os.system(cmd)
+ if result != 0:
+ print('Compilation failed, exit code is %d' % (result))
+ sys.exit(-1)
+
+# Build blender itself
+cmd = '%s -j %d blender ' % (scons_cmd, opts.cores + 1)
+cmd += ' BF_BUILDDIR=%s' % (build_dir)
+cmd += ' BF_INSTALLDIR=%s' % (install_dir)
+cmd += ' BF_CONFIG=%s' % (config)
+cmd += flags
+
+result = os.system(cmd)
+if result != 0:
+ print('Compilation failed, exit code is %d' % (result))
+ sys.exit(-1)
+
+blender = os.path.join(install_dir, 'blender')
+blenderplayer = blender + 'player'
+
+if not os.path.exists(blender):
+ print('scons completed successfully but blender executable missing')
+ sys.exit(1)
+
+if opts.with_player and not os.path.exists(blenderplayer):
+ print('scons completed successfully but blenderplayer executable missing')
+ sys.exit(1)
+
+# compile python modules
+#result = os.system('%s --background --python %s/source/tools/compile_scripts.py' % (blender, opts.bl_source))
+#if result != 0:
+# print('Python modules compilation failed, exit code is %d' % (result))
+# sys.exit(-1)
+
+print('build successful')
+
+os.system('strip -s %s %s' % (blender, blenderplayer))
+
+# Copy all texts needed for release
+release_texts = os.path.join(opts.bl_source, 'release', 'text', '*')
+release_txt = os.path.join(install_dir, 'release_%s.txt' % (opts.bl_version))
+
+os.system('cp -r %s %s' % (release_texts, install_dir))
+
+if os.path.exists(release_txt):
+ print 'RELEASE TEXT FOUND'
+else:
+ print 'WARNING! RELEASE TEXT NOT FOUND!'
+
+# TODO: copy plugins data when ready
+
+# Add software gl libraries and scripts
+mesa_arch = None
+
+if opts.arch == 'x86_64':
+ mesa_arch = 'mesalibs64.tar.bz2'
+elif opts.arch == 'i686':
+ mesa_arch = 'mesalibs32.tar.bz2'
+
+if mesa_arch is not None:
+ mesalibs = os.path.join(builder_dir, 'extra', mesa_arch)
+ software_gl = os.path.join(builder_dir, 'extra', 'blender-softwaregl')
+
+ os.system('tar -xpf %s -C %s' % (mesalibs, install_dir))
+ os.system('cp %s %s' % (software_gl, install_dir))
+ os.system('chmod 755 %s' % (os.path.join(install_dir, 'blender-softwaregl')))
+
+# Pack release archive
+print("Building Dynamic Tarball")
+os.system('tar -C %s -cjf %s.tar.bz2 %s ' % (opts.install_dir,
+ full_name, full_name))
+
+print('Done.')
+EOF
+ chmod +x $RB/compile.py
+
+ cat << EOF > $RB/do_build_al.sh
+#!/bin/sh
+
+SOURCES="/home/sources"
+
+#opts="--cores=1 "
+opts=""
+
+if [ "x\${tag}" != "x" ]; then
+ echo "Getting tagged source tree..."
+ d="\${SOURCES}/blender-tags/\${tag}"
+ opts="\${opts} --tag=\${tag}"
+ if [ ! -d \${d} ]; then
+ svn co https://svn.blender.org/svnroot/bf-blender/tags/\${tag}/blender/@\${revision} \${d}
+ else
+ svn up -r \${revision} \${d}
+ fi
+elif [ "x\${branch}" != "x" ]; then
+ echo "Getting branched source tree..."
+ d="\${SOURCES}/blender-branches/\${branch}"
+ opts="\${opts} --branch=\${branch}"
+ if [ ! -d \${d} ]; then
+ if [ "x\${revision}" != "x" ]; then
+ svn co https://svn.blender.org/svnroot/bf-blender/branches/\${branch}/@\${revision} \${d}
+ else
+ svn co https://svn.blender.org/svnroot/bf-blender/branches/\${branch}/ \${d}
+ fi
+ else
+ if [ "x\${revision}" != "x" ]; then
+ svn up -r \${revision} \${d}
+ else
+ svn up \${d}
+ fi
+ fi
+else
+ if [ "x\${revision}" != "x" ]; then
+ if [ "x\${revision}" != "x0" ]; then
+ svn up -r \${revision} \${SOURCES}/blender
+ else
+ svn up \${SOURCES}/blender
+ fi
+ fi
+fi
+
+if [ "x\${tag}" != "x" ]; then
+ b="\${SOURCES}/blender-tags/\${tag}"
+elif [ "x\${branch}" != "x" ]; then
+ b="\${SOURCES}/blender-branches/\${branch}"
+else
+ b="\${SOURCES}/blender"
+fi
+
+if [ "x\${addons_revision}" != "x" ]; then
+ d="\${b}/release/scripts/addons"
+
+ if [ "x\${addons_revision}" != "x0" ]; then
+ svn up -r \${addons_revision} \${d}
+ else
+ svn up \${d}
+ fi
+fi
+
+if [ "x\${locale_revision}" != "x" ]; then
+ d="\${b}/release/datafiles/locale"
+
+ if [ "x\${locale_revision}" != "x0" ]; then
+ svn up -r \${locale_revision} \${d}
+ else
+ svn up \${d}
+ fi
+fi
+
+if [ -z "\$version" ]; then
+ version=r\`/usr/bin/svnversion \$SOURCES/blender\`
+fi
+
+cd extra
+./update-libs.sh
+cd ..
+
+python chroot-compile.py \${opts} --arch=x86_64 --bl-version \${version} # --no-clean=1
+python chroot-compile.py \${opts} --arch=i686 --bl-version \${version} # --no-clean=1
+EOF
+ chmod +x $RB/do_build_al.sh
+
+ mkdir -p $RB/extra
+
+ cat << EOF > $RB/extra/blender-softwaregl
+#!/bin/sh
+
+BF_DIST_BIN=\`dirname "\$0"\`
+BF_PROGRAM="blender" # BF_PROGRAM=\`basename "\$0"\`-bin
+exitcode=0
+
+LD_LIBRARY_PATH=\${BF_DIST_BIN}/lib:\${LD_LIBRARY_PATH}
+
+if [ -n "\$LD_LIBRARYN32_PATH" ]; then
+ LD_LIBRARYN32_PATH=\${BF_DIST_BIN}/lib:\${LD_LIBRARYN32_PATH}
+fi
+if [ -n "\$LD_LIBRARYN64_PATH" ]; then
+ LD_LIBRARYN64_PATH=\${BF_DIST_BIN}/lib:\${LD_LIBRARYN64_PATH}
+fi
+if [ -n "\$LD_LIBRARY_PATH_64" ]; then
+ LD_LIBRARY_PATH_64=\${BF_DIST_BIN}/lib:\${LD_LIBRARY_PATH_64}
+fi
+
+# Workaround for half-transparent windows when compiz is enabled
+XLIB_SKIP_ARGB_VISUALS=1
+
+export LD_LIBRARY_PATH LD_LIBRARYN32_PATH LD_LIBRARYN64_PATH LD_LIBRARY_PATH_64 LD_PRELOAD XLIB_SKIP_ARGB_VISUALS
+
+"\$BF_DIST_BIN/\$BF_PROGRAM" \${1+"\$@"}
+exitcode=\$?
+exit \$exitcode
+EOF
+ chmod +x $RB/extra/blender-softwaregl
+
+ cat << EOF > $RB/extra/do_update-libs.sh
+#!/bin/sh
+
+BITS=\$1
+V="\`readlink /opt/lib/mesa | sed -r 's/mesa-//'\`"
+TMP=\`mktemp -d\`
+N="mesalibs\$1-\$V"
+
+if [ ! -f \$N.tar.bz2 ]; then
+ mkdir -p \$TMP/lib
+ cp -P /opt/lib/mesa/lib/libGL* \$TMP/lib
+ strip -s \$TMP/lib/*
+ tar -C \$TMP -cf \$N.tar lib
+ bzip2 \$N.tar
+
+ rm -f mesalibs\$BITS.tar,bz2
+ ln -s \$N.tar.bz2 mesalibs\$BITS.tar.bz2
+fi
+
+rm -rf \$TMP
+EOF
+ chmod +x $RB/extra/do_update-libs.sh
+
+ cat << EOF > $RB/extra/update-libs.sh
+#!/bin/sh
+
+P="/home/sources/release-builder/extra"
+CHROOT_PREFIX="buildbot_squeeze_"
+CHROOT32="\${CHROOT_PREFIX}i686"
+CHROOT64="\${CHROOT_PREFIX}x86_64"
+RUN32="schroot -c \$CHROOT32 -d \$P"
+RUN64="schroot -c \$CHROOT64 -d \$P"
+
+\$RUN64 ./do_update-libs.sh 64
+\$RUN32 ./do_update-libs.sh 32
+EOF
+ chmod +x $RB/extra/update-libs.sh
+
+ mkdir -p $RB/config
+ cp $SOURCES_PATH/blender/build_files/buildbot/config/* $RB/config
+
+ fi
+}
+
+INSTALL_SOURCES() {
+ SOURCES_PATH=$1
+
+ if [ ! -d "$SOURCES_PATH" ]; then
+ INFO "Creating sources directory"
+ mkdir -p "$SOURCES_PATH"
+ fi
+
+ if [ ! -d "$SOURCES_PATH/backport/binutils" ]; then
+ INFO "Downloading binutils"
+ mkdir -p "$SOURCES_PATH/backport/binutils"
+ wget -c $DEBIAN_MIRROR/pool/main/b/binutils/binutils_$BINUTILS_FV.diff.gz \
+ $DEBIAN_MIRROR/pool/main/b/binutils/binutils_$BINUTILS_FV.dsc \
+ $DEBIAN_MIRROR/pool/main/b/binutils/binutils_$BINUTILS_V.orig.tar.gz \
+ -P "$SOURCES_PATH/backport/binutils"
+ fi
+
+ if [ ! -d "$SOURCES_PATH/backport/gcc-4.7" ]; then
+ INFO "Downloading gcc-4.7"
+ mkdir -p "$SOURCES_PATH/backport/gcc-4.7"
+ wget -c $DEBIAN_MIRROR/pool/main/g/gcc-4.7/gcc-$GCC_FV.diff.gz \
+ $DEBIAN_MIRROR/pool/main/g/gcc-4.7/gcc-$GCC_FV.dsc \
+ $DEBIAN_MIRROR/pool/main/g/gcc-4.7/gcc-$GCC_V.orig.tar.gz \
+ -P "$SOURCES_PATH/backport/gcc-4.7"
+ fi
+
+ if [ ! -d "$SOURCES_PATH/backport/openssl" ]; then
+ INFO "Downloading openssl"
+ mkdir -p "$SOURCES_PATH/backport/openssl"
+ wget -c $DEBIAN_MIRROR/pool/main/o/openssl/openssl_$OPENSSL_FV.debian.tar.gz \
+ $DEBIAN_MIRROR/pool/main/o/openssl/openssl_$OPENSSL_FV.dsc \
+ $DEBIAN_MIRROR/pool/main/o/openssl/openssl_$OPENSSL_V.orig.tar.gz \
+ -P "$SOURCES_PATH/backport/openssl"
+ fi
+
+ # JeMalloc
+ J="$SOURCES_PATH/packages/jemalloc-$JEMALLOC_V"
+ if [ ! -d "$J" ]; then
+ INFO "Downloading jemalloc-$JEMALLOC_V"
+ wget -c http://www.canonware.com/download/jemalloc/jemalloc-$JEMALLOC_V.tar.bz2 -P "$SOURCES_PATH/packages"
+ tar -C "$SOURCES_PATH/packages" -xf "$J.tar.bz2"
+ cat << EOF > "$J/0config.sh"
+#!/bin/sh
+
+./configure CC="gcc-4.7 -Wl,--as-needed" CXX="g++-4.7 -Wl,--as-needed" LDFLAGS="-pthread -static-libgcc" --prefix=/opt/lib/jemalloc-$JEMALLOC_V
+EOF
+ chmod +x "$J/0config.sh"
+ fi
+
+ # Spnav
+ S="$SOURCES_PATH/packages/libspnav-$SPNAV_V"
+ if [ ! -d "$S" ]; then
+ wget -c http://downloads.sourceforge.net/project/spacenav/spacenav%20library%20%28SDK%29/libspnav%200.2.2/libspnav-$SPNAV_V.tar.gz \
+ -P "$SOURCES_PATH/packages"
+ tar -C "$SOURCES_PATH/packages" -xf "$S.tar.gz"
+ cat << EOF > "$S/0config.sh"
+#!/bin/sh
+
+./configure --prefix=/opt/lib/libspnav-$SPNAV_V
+EOF
+ chmod +x "$S/0config.sh"
+ fi
+
+ # FFmpeg
+ F="$SOURCES_PATH/packages/ffmpeg-$FFMPEG_V"
+ if [ ! -d "$F" ]; then
+ INFO "Downloading FFmpeg-$FFMPEG_V"
+ wget -c http://ffmpeg.org/releases/ffmpeg-$FFMPEG_V.tar.bz2 -P "$SOURCES_PATH/packages"
+ tar -C "$SOURCES_PATH/packages" -xf "$F.tar.bz2"
+ cat << EOF > "$F/0config.sh"
+#!/bin/sh
+
+./configure \\
+ --cc="/usr/bin/gcc-4.7 -Wl,--as-needed" \\
+ --extra-ldflags="-pthread -static-libgcc" \\
+ --prefix=/opt/lib/ffmpeg-$FFMPEG_V \\
+ --enable-static \\
+ --enable-avfilter \\
+ --disable-vdpau \\
+ --disable-bzlib \\
+ --disable-libgsm \\
+ --enable-libschroedinger \\
+ --disable-libspeex \\
+ --enable-libtheora \\
+ --enable-libvorbis \\
+ --enable-pthreads \\
+ --enable-zlib \\
+ --enable-libvpx \\
+ --enable-stripping \\
+ --enable-runtime-cpudetect \\
+ --disable-vaapi \\
+ --enable-libopenjpeg \\
+ --disable-libfaac \\
+ --disable-nonfree \\
+ --enable-gpl \\
+ --disable-postproc \\
+ --disable-x11grab \\
+ --enable-libmp3lame \\
+ --disable-librtmp \\
+ --enable-libx264 \\
+ --enable-libxvid \\
+ --disable-libopencore-amrnb \\
+ --disable-libopencore-amrwb \\
+ --disable-libdc1394 \\
+ --disable-version3 \\
+ --disable-outdev=sdl \\
+ --disable-outdev=alsa \\
+ --disable-indev=sdl \\
+ --disable-indev=alsa \\
+ --disable-indev=jack \\
+ --disable-indev=lavfi
+
+# --enable-debug
+# --disable-optimizations
+# --disable-ffplay
+EOF
+ chmod +x "$F/0config.sh"
+ fi
+
+ # Boost
+ B="$SOURCES_PATH/packages/boost_$BOOST_V"
+ if [ ! -d "$B" ]; then
+ INFO "Downloading Boost-$BOOST_V"
+ b_d=`echo "$BOOST_V" | sed -r 's/_/./g'`
+ wget -c http://sourceforge.net/projects/boost/files/boost/$b_d/boost_$BOOST_V.tar.bz2/download -O "$B.tar.bz2"
+ tar -C "$SOURCES_PATH/packages" -xf "$B.tar.bz2"
+ fi
+
+ # Python
+ P="$SOURCES_PATH/packages/Python-$PYTHON_V"
+ if [ ! -d "$P" ]; then
+ INFO "Downloading Python-$PYTHON_V"
+ wget -c http://python.org/ftp/python/$PYTHON_V/Python-$PYTHON_V.tar.bz2 -P "$SOURCES_PATH/packages"
+ tar -C "$SOURCES_PATH/packages" -xf "$P.tar.bz2"
+ cat << EOF > "$P/0config.sh"
+#!/bin/sh
+
+# NOTE: this sounds strange, but make sure /dev/shm/ is writable by your user,
+# otherwise syncronization primitives wouldn't be included into python
+if [[ "\`stat -c '%a' /dev/shm/\`" != "777" ]]; then
+ echo "Error checking syncronization primitives"
+ exit 1
+fi
+
+./configure --prefix=/opt/lib/python-$PYTHON_V \\
+ --enable-ipv6 \\
+ --enable-loadable-sqlite-extensions \\
+ --with-dbmliborder=bdb \\
+ --with-wide-unicode \\
+ --with-computed-gotos \\
+ --with-pymalloc
+EOF
+ chmod +x "$P/0config.sh"
+ fi
+
+ # OpenImageIO
+ O="$SOURCES_PATH/packages/OpenImageIO-$OIIO_V"
+ if [ ! -d "$O" ]; then
+ INFO "Downloading OpenImageIO-$OIIO_V"
+ wget -c https://github.com/OpenImageIO/oiio/tarball/Release-$OIIO_V -O "$O.tar.gz"
+ tar -C "$SOURCES_PATH/packages" -xf "$O.tar.gz"
+ mv $SOURCES_PATH/packages/OpenImageIO-oiio* $O
+ mkdir $O/build
+ cat << EOF > "$O/build/prepare.sh"
+#!/bin/sh
+
+if file /bin/cp | grep -q '32-bit'; then
+ cflags="-fPIC -m32 -march=i686"
+else
+ cflags="-fPIC"
+fi
+
+cmake \\
+ -D CMAKE_BUILD_TYPE=Release \\
+ -D CMAKE_PREFIX_PATH=/opt/lib/oiio-$OIIO_V \\
+ -D CMAKE_INSTALL_PREFIX=/opt/lib/oiio-$OIIO_V \\
+ -D BUILDSTATIC=ON \\
+ -D USE_JASPER=OFF \\
+ -D CMAKE_CXX_FLAGS:STRING="\${cflags}" \\
+ -D CMAKE_C_FLAGS:STRING="\${cflags}" \\
+ -D CMAKE_EXE_LINKER_FLAGS='-lgcc_s -lgcc' \\
+ -D BOOST_ROOT=/opt/lib/boost \\
+ ../src
+EOF
+ chmod +x "$O/build/prepare.sh"
+ fi
+
+ # OpenColorIO
+ O="$SOURCES_PATH/packages/OpenColorIO-$OCIO_V"
+ if [ ! -d "$O" ]; then
+ INFO "Downloading OpenColorIO-$OCIO_V"
+ wget -c http://github.com/imageworks/OpenColorIO/tarball/v$OCIO_V -O "$O.tar.gz"
+ tar -C "$SOURCES_PATH/packages" -xf "$O.tar.gz"
+ mv $SOURCES_PATH/packages/imageworks-OpenColorIO* $O
+ mkdir $O/build
+ cat << EOF > "$O/build/prepare.sh"
+#!/bin/sh
+
+if file /bin/cp | grep -q '32-bit'; then
+ cflags="-fPIC -m32 -march=i686"
+else
+ cflags="-fPIC"
+fi
+
+cmake \\
+ -D CMAKE_BUILD_TYPE=Release \\
+ -D CMAKE_PREFIX_PATH=/opt/lib/ocio-1.0.7 \\
+ -D CMAKE_INSTALL_PREFIX=/opt/lib/ocio-1.0.7 \\
+ -D BUILDSTATIC=ON \\
+ -D CMAKE_CXX_FLAGS:STRING="\${cflags}" \\
+ -D CMAKE_C_FLAGS:STRING="\${cflags}" \\
+ -D CMAKE_EXE_LINKER_FLAGS='-lgcc_s -lgcc' \\
+ ..
+EOF
+
+ chmod +x "$O/build/prepare.sh"
+ fi
+
+ # Mesa
+ M="$SOURCES_PATH/packages/Mesa-$MESA_V"
+ if [ ! -d "$M" ]; then
+ INFO "Downloading Mesa-$MESA_V"
+ wget -c ftp://ftp.freedesktop.org/pub/mesa/$MESA_V/MesaLib-$MESA_V.tar.bz2 -P "$SOURCES_PATH/packages"
+ tar -C "$SOURCES_PATH/packages" -xf "$SOURCES_PATH/packages/MesaLib-$MESA_V.tar.bz2"
+ cat << EOF > "$M/0config.sh"
+#!/bin/sh
+
+OPTS="--with-driver=xlib \\
+ --disable-driglx-direct \\
+ --disable-egl \\
+ --enable-gallium-gbm=no \\
+ --enable-gallium-egl=no \\
+ --enable-gallium-llvm=no \\
+ --with-gallium-drivers=swrast \\
+ --with-dri-drivers=swrast \\
+ --prefix=/opt/lib/mesa-$MESA_V"
+
+if file /bin/cp | grep -q '32-bit'; then
+ ./configure CC="gcc-4.7 -Wl,--as-needed" CXX="g++-4.7 -Wl,--as-needed" LDFLAGS="-pthread -static-libgcc" \${OPTS} --enable-32-bit #--build=i486-linux-gnu
+else
+ ./configure CC="gcc-4.7 -Wl,--as-needed" CXX="g++-4.7 -Wl,--as-needed" LDFLAGS="-pthread -static-libgcc" \${OPTS}
+fi
+
+EOF
+ chmod +x "$M/0config.sh"
+ fi
+
+ # OpenAL
+ O="$SOURCES_PATH/packages/openal-soft-$OPENAL_V"
+ if [ ! -d "$O" ]; then
+ INFO "Downloading OpenAL-$OPENAL_V"
+ wget -c http://kcat.strangesoft.net/openal-releases/openal-soft-$OPENAL_V.tar.bz2 -P "$SOURCES_PATH/packages"
+ tar -C "$SOURCES_PATH/packages" -xf "$SOURCES_PATH/packages/openal-soft-$OPENAL_V.tar.bz2"
+ cat << EOF > "$O/build-openal.sh"
+#!/bin/sh
+
+DEB_CMAKE_OPTIONS="-DCMAKE_VERBOSE_MAKEFILE=ON \\
+ -DCMAKE_INSTALL_PREFIX=/opt/lib/openal-$OPENAL_V \\
+ -DCMAKE_BUILD_TYPE:String=Release \\
+ -DALSOFT_CONFIG=ON \\
+ -DLIBTYPE=STATIC .. "
+
+BUILD_TREE=./build-tree
+
+rm -rf "\${BUILD_TREE}"
+mkdir -p "\${BUILD_TREE}"
+cd "\${BUILD_TREE}"
+
+sh -c "cmake \`echo \$DEB_CMAKE_OPTIONS\`"
+make -j$THREADS
+make install
+EOF
+ chmod +x "$O/build-openal.sh"
+ fi
+
+ # OpenCollada
+ O="$SOURCES_PATH/packages/opencollada"
+ if [ ! -d "$O" ]; then
+ INFO "Checking out OpenCollada sources"
+ svn co http://opencollada.googlecode.com/svn/trunk $O
+
+ cat << EOF > "$O/build_all.sh"
+#!/bin/sh
+
+scons RELEASE=0 NOVALIDATION=1 XMLPARSER=libxmlnative PCRENATIVE=1 SHAREDLIB=0 -j ${THREADS} --clean
+scons RELEASE=1 NOVALIDATION=1 XMLPARSER=libxmlnative PCRENATIVE=1 SHAREDLIB=0 -j ${THREADS} --clean
+
+scons RELEASE=0 NOVALIDATION=1 XMLPARSER=libxmlnative PCRENATIVE=1 SHAREDLIB=0 -j ${THREADS}
+scons RELEASE=1 NOVALIDATION=1 XMLPARSER=libxmlnative PCRENATIVE=1 SHAREDLIB=0 -j ${THREADS}
+EOF
+
+ cat << EOF > "$O/prepare_lib-libxml.sh"
+#!/bin/bash
+
+src="./COLLADAStreamWriter/include
+./COLLADABaseUtils/include
+./COLLADABaseUtils/include/Math
+./COLLADAFramework/include
+./GeneratedSaxParser/include
+./COLLADASaxFrameworkLoader/include
+./COLLADASaxFrameworkLoader/include/generated14
+./COLLADASaxFrameworkLoader/include/generated15"
+
+if [ -z \$1 ]; then
+ arch="x86_64"
+else
+ arch=\$1
+fi
+
+libs="./GeneratedSaxParser/lib/posix/\${arch}/releaselibxml/libGeneratedSaxParser.a
+./Externals/MathMLSolver/lib/posix/\${arch}/release/libMathMLSolver.a
+./COLLADABaseUtils/lib/posix/\${arch}/release/libOpenCOLLADABaseUtils.a
+./COLLADAFramework/lib/posix/\${arch}/release/libOpenCOLLADAFramework.a
+./COLLADASaxFrameworkLoader/lib/posix/\${arch}/releaselibxmlNovalidation/libOpenCOLLADASaxFrameworkLoader.a
+./COLLADAStreamWriter/lib/posix/\${arch}/release/libOpenCOLLADAStreamWriter.a
+./Externals/UTF/lib/posix/\${arch}/release/libUTF.a
+./common/libBuffer/lib/posix/\${arch}/release/libbuffer.a
+./common/libftoa/lib/posix/\${arch}/release/libftoa.a"
+
+#./Externals/pcre/lib/posix/\${arch}/release/libpcre.a
+#./Externals/LibXML/lib/posix/\${arch}/release/libxml.a
+
+debug_libs="./GeneratedSaxParser/lib/posix/\${arch}/debuglibxml/libGeneratedSaxParser.a
+./Externals/MathMLSolver/lib/posix/\${arch}/debug/libMathMLSolver.a
+./COLLADABaseUtils/lib/posix/\${arch}/debug/libOpenCOLLADABaseUtils.a
+./COLLADAFramework/lib/posix/\${arch}/debug/libOpenCOLLADAFramework.a
+./COLLADASaxFrameworkLoader/lib/posix/\${arch}/debuglibxmlNovalidation/libOpenCOLLADASaxFrameworkLoader.a
+./COLLADAStreamWriter/lib/posix/\${arch}/debug/libOpenCOLLADAStreamWriter.a
+./Externals/UTF/lib/posix/\${arch}/debug/libUTF.a
+./common/libBuffer/lib/posix/\${arch}/debug/libbuffer.a
+./common/libftoa/lib/posix/\${arch}/debug/libftoa.a"
+
+#./Externals/pcre/lib/posix/\${arch}/debug/libpcre.a
+#./Externals/LibXML/lib/posix/\${arch}/debug/libxml.a
+
+d="opencollada-libxml"
+rm -rf \${d}
+mkdir -p \${d}/include
+
+for i in \${src}; do
+ mkdir -p \${d}/include/\${i}
+ cp \${i}/*.h \${d}/include/\${i}
+done
+
+mkdir \${d}/lib
+for i in \${libs}; do
+ echo "" > /dev/null
+ cp \${i} \${d}/lib
+done
+
+for i in \${debug_libs}; do
+ f=\`basename \${i}\`
+ o=\${f/\\.a/_d.a}
+ cp \${i} \${d}/lib/\${o}
+done
+
+rm -rf /opt/lib/opencollada
+mv \${d} /opt/lib/opencollada
+chown -R root:staff /opt/lib/opencollada
+EOF
+
+ chmod +x "$O/build_all.sh"
+ chmod +x "$O/prepare_lib-libxml.sh"
+ fi
+
+ # Blender
+ B="$SOURCES_PATH/blender"
+ if [ ! -d "$B" ]; then
+ INFO "Checking out Blender sources"
+ svn co https://svn.blender.org/svnroot/bf-blender/trunk/blender $B
+ fi
+
+ # CUDA Toolkit
+ C=$SOURCES_PATH/cudatoolkit
+ if [ ! -f "$C/$CUDA_32" ]; then
+ INFO "Downloading CUDA 32bit toolkit"
+ mkdir -p $C
+ wget -c http://developer.download.nvidia.com/compute/cuda/4_2/rel/toolkit/$CUDA_32 -P $C
+ fi
+
+ if [ ! -f "$C/$CUDA_64" ]; then
+ INFO "Downloading CUDA 64bit toolkit"
+ mkdir -p $C
+ wget -c http://developer.download.nvidia.com/compute/cuda/4_2/rel/toolkit/$CUDA_64 -P $C
+ fi
+
+ if [ ! -f $SOURCES_PATH/Readme.txt ]; then
+
+ cat << EOF > $SOURCES_PATH/Readme.txt
+This directory contains different things needed for Blender builds
+
+blender/: directory with blender's svnsnapshot
+
+blender-build/, blender-install/: build and install directories for
+ automated release creation
+
+buildbot-i686-slave/,
+buildbot-x86_64-slave/: buildbot slave environments for automated builds
+ (maybe it'll be better to move them to /home?)
+
+staticlibs/: set of static libs. Mostly needed to make static linking prioretized
+ under dynamic linking
+
+release-builder/: all stuff needed for release archives preparation
+
+Hope all this would help you.
+
+-Sergey-
+EOF
+ fi
+
+ INSTALL_RELEASE_BUILDER $SOURCES_PATH
+}
+
+DO_BACKPORT() {
+ CHROOT_ARCH=$1
+ CHROOT_PATH=$2
+
+ RUN="chroot $CHROOT_PATH"
+ P="/home/sources/backport"
+
+ # Backport fresh binutils
+ if [ `$RUN dpkg-query -W -f='${Version}\n' binutils | grep -c $BINUTILS_V` -eq "0" ]; then
+ INFO "Backporting binutils"
+ B="$P/binutils/binutils-$BINUTILS_V"
+ pkg="$P/binutils/binutils_${BINUTILS_FV}_amd64.deb"
+
+ if [ ! -d "$CHROOT_PATH/$B" ]; then
+ INFO "Unpacking binutils"
+ $RUN dpkg-source -x "$P/binutils/binutils_$BINUTILS_FV.dsc" "$B"
+ fi
+
+ if [ "$CHROOT_ARCH" = "i386" ]; then
+ pkg=`echo "$pkg" | sed -r 's/amd64/i386/g'`
+ fi
+
+ if [ ! -f "$CHROOT_PATH/$pkg" ]; then
+ INFO "Compiling binutils"
+ sed -ie 's/with_check := yes/with_check := no/' "$CHROOT_PATH/$B/debian/rules"
+ $RUN sh -c "cd '$B' && dpkg-buildpackage -rfakeroot -j$THREADS"
+ fi
+
+ INFO "Installing binutils"
+ $RUN dpkg -i "$pkg"
+
+ INFO "Cleaning binutils"
+ $RUN sh -c "cd '$B' && fakeroot debian/rules clean"
+ fi
+
+ # Install fresh gcc
+ if [ `$RUN dpkg-query -W -f='${Status}\n' gcc-4.7 2> /dev/null | grep -c installed` -eq "0" ]; then
+ INFO "Backporting gcc-4.7"
+ G="$P/gcc-4.7/gcc-$GCC_V"
+
+ pkg="cpp-4.7_4.7.1-7_amd64.deb gcc-4.7-base_4.7.1-7_amd64.deb \
+ libstdc++6-4.7-dev_4.7.1-7_amd64.deb libstdc++6_4.7.1-7_amd64.deb libgcc1_4.7.1-7_amd64.deb \
+ libgomp1_4.7.1-7_amd64.deb libitm1_4.7.1-7_amd64.deb libquadmath0_4.7.1-7_amd64.deb \
+ gcc-4.7_4.7.1-7_amd64.deb g++-4.7_4.7.1-7_amd64.deb"
+
+ if [ ! -d "$CHROOT_PATH/$G" ]; then
+ INFO "Unpacking gcc-4.7"
+ $RUN dpkg-source -x "$P/gcc-4.7/gcc-$GCC_FV.dsc" "$G"
+ fi
+
+ if [ "$CHROOT_ARCH" = "i386" ]; then
+ pkg=`echo "$pkg" | sed -r 's/amd64/i386/g'`
+ fi
+
+ ok=true
+ for x in `echo "$pkg"`; do
+ if [ ! -f "$CHROOT_PATH/$P/gcc-4.7/$x" ]; then
+ ok=false
+ break;
+ fi
+ done
+
+ if ! $ok; then
+ INFO "Compiling gcc-4.7"
+ sed -ie 's/#with_check := disabled by hand/with_check := disabled by hand/' "$CHROOT_PATH/$G/debian/rules.defs"
+ sed -ie 's/dpkg-dev (>= 1.16.0~ubuntu4)/dpkg-dev (>= 1.15.8)/' "$CHROOT_PATH/$G/debian/control"
+ sed -ie 's/doxygen (>= 1.7.2)/doxygen (>= 1.7.1)/' "$CHROOT_PATH/$G/debian/control"
+ sed -ie 's/libmpfr-dev (>= 3.0.0-9~)/libmpfr-dev (>= 3.0.0)/' "$CHROOT_PATH/$G/debian/control"
+ sed -ie 's/libc6-dev (>= 2.13-5)/libc6-dev (>= 2.11.3)/' "$CHROOT_PATH/$G/debian/control"
+ sed -ie 's/libgmp-dev (>= 2:5.0.1~)/libgmp3-dev (>= 2:4.3.2)/' "$CHROOT_PATH/$G/debian/control"
+ $RUN sh -c "cd '$G' && dpkg-buildpackage -rfakeroot"
+ fi
+
+ inst=""
+ for x in `echo "$pkg"`; do
+ inst="$inst $P/gcc-4.7/$x"
+ done
+
+ INFO "Installing gcc-4.7"
+ $RUN dpkg -i $inst
+
+ INFO "Cleaning gcc-4.7"
+ $RUN sh -c "cd '$G' && fakeroot debian/rules clean"
+ fi
+
+ # Backport OpenSSL
+ if [ ! -f $CHROOT_PATH/usr/lib/libssl_pic.a ]; then
+ INFO "Backporting OpenSSL"
+ O="$P/openssl/openssl-$OPENSSL_V"
+
+ pkg="libssl-dev_0.9.8o-4squeeze13_amd64.deb libssl0.9.8_0.9.8o-4squeeze13_amd64.deb openssl_0.9.8o-4squeeze13_amd64.deb"
+
+ if [ ! -d "$CHROOT_PATH/$O" ]; then
+ INFO "Unpacking OpenSSL"
+ $RUN dpkg-source -x "$P/openssl/openssl_$OPENSSL_FV.dsc" "$O"
+ fi
+
+ if [ "$CHROOT_ARCH" = "i386" ]; then
+ pkg=`echo "$pkg" | sed -r 's/amd64/i386/g'`
+ fi
+
+ ok=true
+ for x in `echo "$pkg"`; do
+ if [ ! -f "$CHROOT_PATH/$P/openssl/$x" ]; then
+ ok=false
+ break;
+ fi
+ done
+
+ if ! $ok; then
+ INFO "Compiling OpenSSL"
+ sed -ie 's/#\s*mv debian\/tmp\/usr\/lib\/libcrypto.a debian\/tmp\/usr\/lib\/libcrypto_pic.a/ mv debian\/tmp\/usr\/lib\/libcrypto.a debian\/tmp\/usr\/lib\/libcrypto_pic.a/' "$CHROOT_PATH/$O/debian/rules"
+ sed -ie 's/#\s*mv debian\/tmp\/usr\/lib\/libssl.a debian\/tmp\/usr\/lib\/libssl_pic.a/ mv debian\/tmp\/usr\/lib\/libssl.a debian\/tmp\/usr\/lib\/libssl_pic.a/' "$CHROOT_PATH/$O/debian/rules"
+ cat << EOF > $CHROOT_PATH/$O/debian/libssl-dev.files
+usr/lib/libssl.so
+usr/lib/libcrypto.so
+usr/lib/libssl.a
+usr/lib/libcrypto.a
+usr/lib/libssl_pic.a
+usr/lib/libcrypto_pic.a
+usr/lib/pkgconfig
+usr/include
+usr/share/man/man3
+EOF
+ $RUN sh -c "cd '$O' && dpkg-buildpackage -rfakeroot -j$THREADS"
+ fi
+
+ inst=""
+ for x in `echo "$pkg"`; do
+ inst="$inst $P/openssl/$x"
+ done
+
+ INFO "Installing OpenSSL"
+ $RUN dpkg -i $inst
+
+ echo "openssl hold" | $RUN dpkg --set-selections
+ echo "libssl-dev hold" | $RUN dpkg --set-selections
+ echo "libssl0.9.8 hold" | $RUN dpkg --set-selections
+
+ INFO "Cleaning OpenSSL"
+ $RUN sh -c "cd '$O' && fakeroot debian/rules clean"
+ fi
+}
+
+DO_COMPILE() {
+ CHROOT_ARCH=$1
+ CHROOT_PATH=$2
+
+ RUN="chroot $CHROOT_PATH"
+ P="/home/sources/packages"
+ L="$CHROOT_PATH/opt/lib"
+
+ # JeMalloc
+ if [ ! -d "$L/jemalloc-$JEMALLOC_V" ]; then
+ INFO "Copmiling jemalloc-$JEMALLOC_V"
+ $RUN sh -c "cd '$P/jemalloc-$JEMALLOC_V' && ./0config.sh && make clean && make -j$THREADS && make install && make clean"
+
+ rm -f "$L/jemalloc"
+ ln -s "jemalloc-$JEMALLOC_V" "$L/jemalloc"
+ fi
+
+ # libspnav
+ if [ ! -d "$L/libspnav-$SPNAV_V" ]; then
+ INFO "Copmiling libspnav-$SPNAV_V"
+ mkdir -p "$L/libspnav-$SPNAV_V/lib"
+ mkdir -p "$L/libspnav-$SPNAV_V/include"
+ $RUN sh -c "cd '$P/libspnav-$SPNAV_V' && ./0config.sh && make clean && make -j$THREADS && make install && make clean"
+
+ rm -f "$L/libspnav"
+ ln -s "libspnav-$SPNAV_V" "$L/libspnav"
+ fi
+
+ # FFmpeg
+ if [ ! -d "$L/ffmpeg-$FFMPEG_V" ]; then
+ INFO "Copmiling ffmpeg-$FFMPEG_V"
+ $RUN sh -c "cd '$P/ffmpeg-$FFMPEG_V' && ./0config.sh && make clean && make -j$THREADS && make install && make clean"
+
+ rm -f "$L/ffmpeg"
+ ln -s "ffmpeg-$FFMPEG_V" "$L/ffmpeg"
+ fi
+
+ # Boost
+ V=`echo $BOOST_V | sed -r 's/_/./g'`
+ if [ ! -d "$L/boost-$V" ]; then
+ INFO "Copmiling boost-$V"
+ $RUN sh -c "cd '$P/boost_$BOOST_V' && ./bootstrap.sh && ./b2 --clean && ./b2 install --prefix='/opt/lib/boost-$V' && ./b2 --clean"
+
+ rm -f "$L/boost"
+ ln -s "boost-$V" "$L/boost"
+ fi
+
+ # OCIO
+ if [ ! -d "$L/ocio-$OCIO_V" ]; then
+ INFO "Copmiling ocio-$OCIO_V"
+ $RUN sh -c "cd '$P/OpenColorIO-$OCIO_V/build' && ./prepare.sh && make clean && make -j$THREADS && make install && make clean"
+
+ # Force linking against sttaic libs
+ rm -f $L/ocio-$OCIO_V/lib/*.so*
+
+ # Additional depencencies
+ cp $CHROOT_PATH/$P/OpenColorIO-$OCIO_V/build/ext/dist/lib/libtinyxml.a $L/ocio-$OCIO_V/lib
+ cp $CHROOT_PATH/$P/OpenColorIO-$OCIO_V/build/ext/dist/lib/libyaml-cpp.a $L/ocio-$OCIO_V/lib
+
+ rm -f "$L/ocio"
+ ln -s "ocio-$OCIO_V" "$L/ocio"
+ fi
+
+ # OIIO
+ if [ ! -d "$L/oiio-$OIIO_V" ]; then
+ INFO "Copmiling oiio-$OIIO_V"
+ $RUN sh -c "cd '$P/OpenImageIO-$OIIO_V/build' && ./prepare.sh && make clean && make -j$THREADS && make install && make clean"
+
+ rm -f "$L/oiio"
+ ln -s "oiio-$OIIO_V" "$L/oiio"
+ fi
+
+ # Python
+ if [ ! -d "$L/python-$PYTHON_V" ]; then
+ INFO "Copmiling Python-$PYTHON_V"
+
+ cat << EOF > $CHROOT_PATH/$P/Python-$PYTHON_V/Modules/Setup.local
+_md5 md5module.c
+
+_sha1 sha1module.c
+_sha256 sha256module.c
+_sha512 sha512module.c
+EOF
+
+ sed -ie "s/libraries = \['ssl', 'crypto'\]/libraries = ['ssl_pic', 'crypto_pic', 'z']/" "$P/Python-$PYTHON_V/setup.py"
+
+ $RUN sh -c "cd '$P/Python-$PYTHON_V' && ./0config.sh && make clean && make -j$THREADS && make install && make clean"
+
+ rm -f "$L/python-$PYTHIN_V_SHORT"
+ ln -s "python-$PYTHON_V" "$L/python-$PYTHIN_V_SHORT"
+ fi
+
+ # Mesa
+ if [ ! -d "$L/mesa-$MESA_V" ]; then
+ INFO "Copmiling Mesa-$MESA_V"
+
+ $RUN sh -c "cd '$P/Mesa-$MESA_V' && ./0config.sh && make clean && make -j$THREADS && make install && make clean"
+
+ rm -f "$L/mesa"
+ ln -s "mesa-$MESA_V" "$L/mesa"
+ fi
+
+ # OpenAL
+ if [ ! -d "$L/openal-$OPENAL_V" ]; then
+ INFO "Copmiling openal-$OPENAL_V"
+
+ $RUN sh -c "cd '$P/openal-soft-$OPENAL_V' && ./build-openal.sh"
+
+ rm -f "$L/openal"
+ ln -s "openal-$OPENAL_V" "$L/openal"
+ fi
+
+ # OpenCollada
+ if [ ! -d "$L/opencollada" ]; then
+ INFO "Copmiling opencollada"
+
+ cat << EOF > "$CHROOT_PATH/$P/opencollada/collada.patch"
+Index: common/libBuffer/include/CommonBuffer.h
+===================================================================
+--- common/libBuffer/include/CommonBuffer.h (revision 876)
++++ common/libBuffer/include/CommonBuffer.h (working copy)
+@@ -12,6 +12,7 @@
+ #define __COMMON_BUFFER_H__
+
+ #include "CommonIBufferFlusher.h"
++#include "COLLADABUPlatform.h"
+
+ namespace Common
+ {
+Index: common/libBuffer/src/CommonLogFileBufferFlusher.cpp
+===================================================================
+--- common/libBuffer/src/CommonLogFileBufferFlusher.cpp (revision 876)
++++ common/libBuffer/src/CommonLogFileBufferFlusher.cpp (working copy)
+@@ -10,6 +10,34 @@
+
+ #include "CommonLogFileBufferFlusher.h"
+
++#include <stdio.h>
++#include <errno.h>
++
++#ifndef _WIN32
++FILE *_wfopen(const wchar_t *path, const char *mode)
++{
++ const wchar_t *src = path;
++ char *path_mbs;
++ int n;
++ FILE *file;
++
++ n = (int)wcsrtombs(NULL, &src, 0, NULL);
++
++ if (n < 0)
++ return NULL;
++
++ path_mbs = (char *)malloc(n + 1);
++ wcsrtombs(path_mbs, &path, n, NULL);
++ path_mbs[n] = 0;
++
++ file = fopen(path_mbs, mode);
++
++ free(path_mbs);
++
++ return file;
++}
++#endif
++
+ namespace Common
+ {
+ //--------------------------------------------------------------------
+@@ -35,7 +63,7 @@
+ #ifdef _WIN32
+ mError = (int)_wfopen_s( &stream, fileName, L"wb" );
+ #else
+- stream = _wfopen( fileName, L"wb" );
++ stream = _wfopen( fileName, "wb" );
+ mError = stream ? 0 : errno;
+ #endif
+ if ( !mError )
+@@ -65,7 +93,7 @@
+ #else
+ if ( mUseWideFileName )
+ {
+- stream = _wfopen( mWideFileName.c_str(), L"a" );
++ stream = _wfopen( mWideFileName.c_str(), "a" );
+ }
+ else
+ {
+Index: common/libBuffer/SConscript
+===================================================================
+--- common/libBuffer/SConscript (revision 876)
++++ common/libBuffer/SConscript (working copy)
+@@ -11,7 +11,7 @@
+ targetPath = outputDir + libName
+
+
+-incDirs = ['include/', '../libftoa/include']
++incDirs = ['include/', '../libftoa/include', '../../COLLADABaseUtils/include/', '../../Externals/UTF/include']
+
+
+ src = []
+EOF
+
+ # We're building in a chroot, architecture of host system would be used by scons
+ collada_arch="x86_64"
+
+ $RUN sh -c "cd '$P/opencollada' && svn revert . -R && cat collada.patch | patch -p0 && ./build_all.sh && ./prepare_lib-libxml.sh $collada_arch"
+ fi
+}
+
+ADD_REPO() {
+ CHROOT_PATH=$1
+ DESC=$2
+ REPO=$3
+ C="$CHROOT_PATH/etc/apt/sources.list"
+ RUN="chroot $CHROOT_PATH"
+
+ if [ `cat "$C" | grep -c "$REPO"` -eq "0" ]; then
+ INFO "Adding repo $DESC"
+ echo "" >> $C
+ echo "deb $REPO" >> $C
+ echo "deb-src $REPO" >> $C
+
+ INFO "Updating packages list"
+ $RUN apt-get update
+ fi
+}
+
+INSTALL_CHROOT() {
+ CHROOT_ARCH=$1
+ CHROOT_PATH=$2
+
+ RUN="chroot $CHROOT_PATH"
+
+ # Install fresh debian to a chroot
+ if [ ! -d "$CHROOT_PATH" ]; then
+
+ INFO "Installing Debian ${DEBIAN_BRANCH} to ${CHROOT_PATH}"
+ debootstrap --arch "${CHROOT_ARCH}" "${DEBIAN_BRANCH}" "${CHROOT_PATH}" "${DEBIAN_MIRROR}"
+ fi
+
+ # Configure users and groups
+
+ if [ `cat ${CHROOT_PATH}/etc/group | grep -c developers` -eq "0" ]; then
+ INFO "Creating gorup 'developers'"
+ $RUN groupadd -g 7001 developers
+ fi
+
+ if [ `mount | grep -c "$CHROOT_PATH/dev"` -eq "0" ]; then
+ INFO "Mounting devices from host system to chroot"
+
+ mount -t proc none $CHROOT_PATH/proc
+ mount -t auto -o bind /dev $CHROOT_PATH/dev
+ mount -t devpts -o mode=0620 none $CHROOT_PATH/dev/pts
+ fi
+
+ # Configure apt and install packages
+
+ if [ ! -f ${CHROOT_PATH}/etc/apt/apt.conf ]; then
+ INFO "Setting up apt to not use recommended packages (saves disk space)"
+
+ cat << EOF > "${CHROOT_PATH}/etc/apt/apt.conf"
+APT {
+ Default-Release "${DEBIAN_BRANCH}";
+ Install-Recommends "0";
+};
+EOF
+ fi
+
+ ADD_REPO $CHROOT_PATH "mirror.yandex.ru" "http://mirror.yandex.ru/debian-multimedia/ squeeze main non-free"
+ ADD_REPO $CHROOT_PATH "backports.debian.org" "http://backports.debian.org/debian-backports squeeze-backports main non-free"
+
+ $RUN apt-get upgrade
+
+ $RUN apt-get install -y --force-yes deb-multimedia-keyring libx264-dev libxvidcore4-dev libmp3lame-dev
+
+ if [ `$RUN dpkg-query -W -f='${Status}\n' locales | grep -c not-installed` -eq "1" ]; then
+ INFO "Configuring locales"
+ $RUN apt-get install -y locales
+ $RUN localedef -i en_US -f UTF-8 en_US.UTF-8
+ fi
+
+ INFO "Installing packages from repository"
+
+ $RUN apt-get install -y mc gcc g++ cmake python dpkg-dev build-essential autoconf bison \
+ flex gettext texinfo dejagnu quilt file lsb-release zlib1g-dev fakeroot debhelper \
+ g++-multilib libtool autoconf2.64 automake gawk lzma patchutils gperf sharutils \
+ libcloog-ppl-dev libmpc-dev libmpfr-dev libgmp3-dev autogen realpath chrpath doxygen \
+ graphviz gsfonts-x11 texlive-latex-base libelfg0-dev libx11-dev yasm libopenjpeg-dev \
+ libschroedinger-dev libtheora-dev libvorbis-dev libvpx-dev=$VPX_V \
+ libopenexr-dev libpng-dev libjpeg-dev libtiff-dev python-dev libbz2-dev libreadline-dev \
+ libsqlite3-dev liblzma-dev libncurses5-dev xutils-dev libxext-dev python-libxml2 \
+ libglu1-mesa-dev libfftw3-dev libfreetype6-dev libsdl1.2-dev libopenal-dev libjack-dev \
+ libxi-dev portaudio19-dev po4a subversion scons libpcre3-dev libexpat1-dev sudo \
+ expect bc
+
+ if [ $CHROOT_ARCH = "amd64" ]; then
+ $RUN apt-get install -y libc6-dev-i386 lib32gcc1
+ fi
+
+ # Configure sources directory
+ if [ ! -d "$CHROOT_PATH/home/sources" ]; then
+ INFO "Creating sources directory"
+ $RUN mkdir "/home/sources"
+ $RUN chmod 775 /home/sources
+ $RUN chown root:developers /home/sources
+ fi
+
+ # Bind directory from host system
+ if [ ! -d "$CHROOT_PATH/home/sources/backport" ]; then
+ INFO "Binding sources directory from host system to chroot"
+ mount -o bind "$SOURCES_PATH" "$CHROOT_PATH/home/sources"
+ fi
+
+ if [ "`$RUN getent passwd $USER_ID`" = "" ]; then
+ INFO "Adding default user to chroot"
+ login=`getent passwd $USER_ID | cut -d : -f 1`
+ $RUN useradd -d "/home/$login" -G developers,sudo -m -u $USER_ID "$login"
+ fi
+
+ # Backport packages
+ DO_BACKPORT "$CHROOT_ARCH" "$CHROOT_PATH"
+
+ # Set default compiler to gcc-4.7
+ if [ `readlink "$CHROOT_PATH/usr/bin/gcc"` != "gcc-4.7" ]; then
+ INFO "Setting gcc-4.7 as default compiler"
+ rm -f $CHROOT_PATH/usr/bin/gcc
+ rm -f $CHROOT_PATH/usr/bin/g++
+ ln -s gcc-4.7 $CHROOT_PATH/usr/bin/gcc
+ ln -s g++-4.7 $CHROOT_PATH/usr/bin/g++
+ fi
+
+ # Compile packages
+ DO_COMPILE "$CHROOT_ARCH" "$CHROOT_PATH"
+
+ # Install CUDA toolkit
+ if [ ! -d "$CHROOT_PATH/usr/local/cuda-$CUDA_V" ]; then
+ INFO "Installing CUDA toolkit"
+
+ if [ "$CHROOT_ARCH" = "amd64" ]; then
+ C="cudatoolkit_${CUDA_V}_linux_64_${CUDA_DISTR}.run"
+ else
+ C="cudatoolkit_${CUDA_V}_linux_32_${CUDA_DISTR}.run"
+ fi
+
+ rm -f $CHROOT_PATH/usr/local/cuda
+
+ chmod +x $CHROOT_PATH//home/sources/cudatoolkit/$C
+
+ $RUN /usr/bin/expect <<EOF
+ spawn /home/sources/cudatoolkit/$C
+ expect "Enter install path"
+ send "\n"
+ expect "Installation Complete"
+EOF
+
+ mv $CHROOT_PATH/usr/local/cuda $CHROOT_PATH/usr/local/cuda-$CUDA_V
+ ln -s cuda-$CUDA_V $CHROOT_PATH/usr/local/cuda
+ sudo ln -s /usr/bin/gcc-4.4 $CHROOT_PATH/usr/local/cuda/bin/gcc
+ fi
+
+ # Change permissions
+ INFO "Changing permissions on sources"
+ login=`$RUN getent passwd $USER_ID | cut -d : -f 1`
+ for x in /home/sources /opt/lib; do
+ $RUN chmod g+w -R $x
+ $RUN chown "$login:developers" -R $x
+ done
+}
+
+if ! which debootstrap > /dev/null 2>&1; then
+ ERROR "debootstrap command not found, can not create chroot environment"
+ ERROR "Use apt-get install debootstrap to install debootstrap"
+ exit 1
+fi
+
+if [ -z "$ENV_PATH" ]; then
+ ERROR "Incorrect environment directory is set"
+ exit 1
+fi
+
+INSTALL_SOURCES "$SOURCES_PATH"
+INSTALL_CHROOT amd64 "$AMD64_PATH"
+INSTALL_CHROOT i386 "$I686_PATH"
+
+INFO "Configurtion of build environment is completed!"
+echo "Add this lines to your /etc/fstab:"
+echo
+
+for x in $I686_PATH $AMD64_PATH; do
+ echo "none $x/proc proc auto 0 0"
+ echo "/dev $x/dev auto bind,auto 0 0"
+ echo "none $x/dev/pts devpts mode=0620,auto 0 0"
+ echo "/home/sources $x/home/sources auto bind,auto 0 0"
+ echo
+done
+
+echo "Add this lines to your /etc/schroot/schroot.conf:"
+echo
+login=`getent passwd $USER_ID | cut -d : -f 1`
+
+for x in $I686_PATH $AMD64_PATH; do
+ echo [`basename $x`]
+ echo "description=Linux buildbot environment"
+ echo "directory=$x"
+ echo "users=$login"
+ echo "root-groups=root"
+ echo
+done
diff --git a/build_files/buildbot/config/user-config-glibc27-i686.py b/build_files/buildbot/config/user-config-glibc27-i686.py
index 04b83253678..c1e72662f89 100644
--- a/build_files/buildbot/config/user-config-glibc27-i686.py
+++ b/build_files/buildbot/config/user-config-glibc27-i686.py
@@ -3,8 +3,8 @@ BF_INSTALLDIR = '../blender-install/linux-glibc27-i686'
BF_NUMJOBS = 2
# Python configuration
-BF_PYTHON_VERSION = '3.2'
-BF_PYTHON_ABI_FLAGS = 'mu'
+BF_PYTHON_VERSION = '3.3'
+BF_PYTHON_ABI_FLAGS = 'm'
BF_PYTHON = '/opt/python3'
WITH_BF_STATICPYTHON = True
diff --git a/build_files/buildbot/config/user-config-glibc27-x86_64.py b/build_files/buildbot/config/user-config-glibc27-x86_64.py
index 070e62b2f20..4380b404ac3 100644
--- a/build_files/buildbot/config/user-config-glibc27-x86_64.py
+++ b/build_files/buildbot/config/user-config-glibc27-x86_64.py
@@ -3,8 +3,8 @@ BF_INSTALLDIR = '../blender-install/linux-glibc27-x86_64'
BF_NUMJOBS = 2
# Python configuration
-BF_PYTHON_VERSION = '3.2'
-BF_PYTHON_ABI_FLAGS = 'mu'
+BF_PYTHON_VERSION = '3.3'
+BF_PYTHON_ABI_FLAGS = 'm'
BF_PYTHON = '/opt/python3'
WITH_BF_STATICPYTHON = True
diff --git a/build_files/buildbot/config/user-config-player-glibc211-i686.py b/build_files/buildbot/config/user-config-player-glibc211-i686.py
index 3ac061d934f..1b387445390 100644
--- a/build_files/buildbot/config/user-config-player-glibc211-i686.py
+++ b/build_files/buildbot/config/user-config-player-glibc211-i686.py
@@ -93,6 +93,14 @@ BF_OCIO_INC = '${BF_OCIO}/include'
BF_OCIO_LIB_STATIC = '${BF_OCIO_LIBPATH}/libOpenColorIO.a ${BF_OCIO_LIBPATH}/libtinyxml.a ${BF_OCIO_LIBPATH}/libyaml-cpp.a'
BF_OCIO_LIBPATH = '${BF_OCIO}/lib'
+WITH_BF_BOOST = True
+WITH_BF_STATICBOOST = True
+BF_BOOST = '/opt/lib/boost'
+BF_BOOST_INC = '${BF_BOOST}/include'
+BF_BOOST_LIB_STATIC = '${BF_BOOST_LIBPATH}/libboost_filesystem.a ${BF_BOOST_LIBPATH}/libboost_date_time.a ' + \
+ '${BF_BOOST_LIBPATH}/libboost_regex.a ${BF_BOOST_LIBPATH}/libboost_system.a ${BF_BOOST_LIBPATH}/libboost_thread.a'
+BF_BOOST_LIBPATH = '${BF_BOOST}/lib'
+
# JACK
WITH_BF_JACK = True
WITH_BF_STATICJACK = True
diff --git a/build_files/buildbot/config/user-config-player-glibc211-x86_64.py b/build_files/buildbot/config/user-config-player-glibc211-x86_64.py
index 08d277edb7b..83540150c33 100644
--- a/build_files/buildbot/config/user-config-player-glibc211-x86_64.py
+++ b/build_files/buildbot/config/user-config-player-glibc211-x86_64.py
@@ -93,6 +93,14 @@ BF_OCIO_INC = '${BF_OCIO}/include'
BF_OCIO_LIB_STATIC = '${BF_OCIO_LIBPATH}/libOpenColorIO.a ${BF_OCIO_LIBPATH}/libtinyxml.a ${BF_OCIO_LIBPATH}/libyaml-cpp.a'
BF_OCIO_LIBPATH = '${BF_OCIO}/lib'
+WITH_BF_BOOST = True
+WITH_BF_STATICBOOST = True
+BF_BOOST = '/opt/lib/boost'
+BF_BOOST_INC = '${BF_BOOST}/include'
+BF_BOOST_LIB_STATIC = '${BF_BOOST_LIBPATH}/libboost_filesystem.a ${BF_BOOST_LIBPATH}/libboost_date_time.a ' + \
+ '${BF_BOOST_LIBPATH}/libboost_regex.a ${BF_BOOST_LIBPATH}/libboost_system.a ${BF_BOOST_LIBPATH}/libboost_thread.a'
+BF_BOOST_LIBPATH = '${BF_BOOST}/lib'
+
# JACK
WITH_BF_JACK = True
WITH_BF_STATICJACK = True
diff --git a/build_files/buildbot/config/user-config-player-glibc27-i686.py b/build_files/buildbot/config/user-config-player-glibc27-i686.py
index e23fc70262f..e200e0fccf4 100644
--- a/build_files/buildbot/config/user-config-player-glibc27-i686.py
+++ b/build_files/buildbot/config/user-config-player-glibc27-i686.py
@@ -3,8 +3,8 @@ BF_INSTALLDIR = '../blender-install/linux-glibc27-i686'
BF_NUMJOBS = 2
# Python configuration
-BF_PYTHON_VERSION = '3.2'
-BF_PYTHON_ABI_FLAGS = 'mu'
+BF_PYTHON_VERSION = '3.3'
+BF_PYTHON_ABI_FLAGS = 'm'
BF_PYTHON = '/opt/python3'
WITH_BF_STATICPYTHON = True
@@ -90,6 +90,13 @@ BF_OCIO_INC = '${BF_OCIO}/include'
BF_OCIO_LIB_STATIC = '${BF_OCIO_LIBPATH}/libOpenColorIO.a ${BF_OCIO_LIBPATH}/libtinyxml.a ${BF_OCIO_LIBPATH}/libyaml-cpp.a'
BF_OCIO_LIBPATH = '${BF_OCIO}/lib'
+WITH_BF_BOOST = True
+WITH_BF_STATICBOOST = True
+BF_BOOST = '/opt/boost'
+BF_BOOST_INC = '${BF_BOOST}/include'
+BF_BOOST_LIB_STATIC = '${BF_BOOST_LIBPATH}/libboost_filesystem.a ${BF_BOOST_LIBPATH}/libboost_date_time.a ${BF_BOOST_LIBPATH}/libboost_regex.a ${BF_BOOST_LIBPATH}/libboost_system.a ${BF_BOOST_LIBPATH}/libboost_thread.a'
+BF_BOOST_LIBPATH = '${BF_BOOST}/lib'
+
# JACK
WITH_BF_JACK = True
diff --git a/build_files/buildbot/config/user-config-player-glibc27-x86_64.py b/build_files/buildbot/config/user-config-player-glibc27-x86_64.py
index 3c09603473e..2ee177960cd 100644
--- a/build_files/buildbot/config/user-config-player-glibc27-x86_64.py
+++ b/build_files/buildbot/config/user-config-player-glibc27-x86_64.py
@@ -3,8 +3,8 @@ BF_INSTALLDIR = '../blender-install/linux-glibc27-x86_64'
BF_NUMJOBS = 2
# Python configuration
-BF_PYTHON_VERSION = '3.2'
-BF_PYTHON_ABI_FLAGS = 'mu'
+BF_PYTHON_VERSION = '3.3'
+BF_PYTHON_ABI_FLAGS = 'm'
BF_PYTHON = '/opt/python3'
WITH_BF_STATICPYTHON = True
@@ -90,6 +90,13 @@ BF_OCIO_INC = '${BF_OCIO}/include'
BF_OCIO_LIB_STATIC = '${BF_OCIO_LIBPATH}/libOpenColorIO.a ${BF_OCIO_LIBPATH}/libtinyxml.a ${BF_OCIO_LIBPATH}/libyaml-cpp.a'
BF_OCIO_LIBPATH = '${BF_OCIO}/lib'
+WITH_BF_BOOST = True
+WITH_BF_STATICBOOST = True
+BF_BOOST = '/opt/boost'
+BF_BOOST_INC = '${BF_BOOST}/include'
+BF_BOOST_LIB_STATIC = '${BF_BOOST_LIBPATH}/libboost_filesystem.a ${BF_BOOST_LIBPATH}/libboost_date_time.a ${BF_BOOST_LIBPATH}/libboost_regex.a ${BF_BOOST_LIBPATH}/libboost_system.a ${BF_BOOST_LIBPATH}/libboost_thread.a'
+BF_BOOST_LIBPATH = '${BF_BOOST}/lib'
+
# JACK
WITH_BF_JACK = True
diff --git a/build_files/cmake/Modules/FindPythonLibsUnix.cmake b/build_files/cmake/Modules/FindPythonLibsUnix.cmake
index 448e587e224..fdf2c29704d 100644
--- a/build_files/cmake/Modules/FindPythonLibsUnix.cmake
+++ b/build_files/cmake/Modules/FindPythonLibsUnix.cmake
@@ -9,6 +9,7 @@
# This module defines
# PYTHON_VERSION
# PYTHON_INCLUDE_DIRS
+# PYTHON_INCLUDE_CONFIG_DIRS
# PYTHON_LIBRARIES
# PYTHON_LIBPATH, Used for installation
# PYTHON_LINKFLAGS
@@ -34,7 +35,7 @@ IF(NOT PYTHON_ROOT_DIR AND NOT $ENV{PYTHON_ROOT_DIR} STREQUAL "")
SET(PYTHON_ROOT_DIR $ENV{PYTHON_ROOT_DIR})
ENDIF()
-SET(PYTHON_VERSION 3.2 CACHE STRING "Python Version (major and minor only)")
+SET(PYTHON_VERSION 3.3 CACHE STRING "Python Version (major and minor only)")
MARK_AS_ADVANCED(PYTHON_VERSION)
@@ -46,17 +47,25 @@ MARK_AS_ADVANCED(PYTHON_LINKFLAGS)
# if the user passes these defines as args, we dont want to overwrite
SET(_IS_INC_DEF OFF)
+SET(_IS_INC_CONF_DEF OFF)
SET(_IS_LIB_DEF OFF)
+SET(_IS_LIB_PATH_DEF OFF)
IF(DEFINED PYTHON_INCLUDE_DIR)
SET(_IS_INC_DEF ON)
ENDIF()
+IF(DEFINED PYTHON_INCLUDE_CONFIG_DIR)
+ SET(_IS_INC_CONF_DEF ON)
+ENDIF()
IF(DEFINED PYTHON_LIBRARY)
SET(_IS_LIB_DEF ON)
ENDIF()
+IF(DEFINED PYTHON_LIBPATH)
+ SET(_IS_LIB_PATH_DEF ON)
+ENDIF()
# only search for the dirs if we havn't already
-IF((NOT _IS_INC_DEF) OR (NOT _IS_LIB_DEF))
+IF((NOT _IS_INC_DEF) OR (NOT _IS_INC_CONF_DEF) OR (NOT _IS_LIB_DEF) OR (NOT _IS_LIB_PATH_DEF))
SET(_python_ABI_FLAGS
"m;mu;u; " # release
@@ -85,9 +94,26 @@ IF((NOT _IS_INC_DEF) OR (NOT _IS_LIB_DEF))
${_python_SEARCH_DIRS}
PATH_SUFFIXES
include/python${PYTHON_VERSION}${_CURRENT_ABI_FLAGS}
+ include/${CMAKE_LIBRARY_ARCHITECTURE}/python${PYTHON_VERSION}${_CURRENT_ABI_FLAGS}
)
ENDIF()
+ IF(NOT DEFINED PYTHON_INCLUDE_CONFIG_DIR)
+ FIND_PATH(PYTHON_INCLUDE_CONFIG_DIR
+ NAMES
+ pyconfig.h
+ HINTS
+ ${_python_SEARCH_DIRS}
+ PATH_SUFFIXES
+ include/python${PYTHON_VERSION}${_CURRENT_ABI_FLAGS}
+ include/${CMAKE_LIBRARY_ARCHITECTURE}/python${PYTHON_VERSION}${_CURRENT_ABI_FLAGS}
+ )
+ IF(NOT PYTHON_INCLUDE_CONFIG_DIR AND PYTHON_INCLUDE_DIR)
+ # Fallback...
+ SET(PYTHON_INCLUDE_CONFIG_DIR ${PYTHON_INCLUDE_DIR})
+ ENDIF()
+ ENDIF()
+
IF(NOT DEFINED PYTHON_LIBRARY)
FIND_LIBRARY(PYTHON_LIBRARY
NAMES
@@ -99,16 +125,37 @@ IF((NOT _IS_INC_DEF) OR (NOT _IS_LIB_DEF))
)
ENDIF()
- IF(PYTHON_LIBRARY AND PYTHON_INCLUDE_DIR)
+ IF(NOT DEFINED PYTHON_LIBPATH)
+ FIND_PATH(PYTHON_LIBPATH
+ NAMES
+ "python${PYTHON_VERSION}/abc.py" # This is a bit hackish! :/
+ HINTS
+ ${_python_SEARCH_DIRS}
+ PATH_SUFFIXES
+ lib64 lib
+ )
+ IF(NOT PYTHON_LIBPATH AND PYTHON_LIBRARY)
+ # Fallback...
+ GET_FILENAME_COMPONENT(PYTHON_LIBPATH ${PYTHON_LIBRARY} PATH)
+ ENDIF()
+ ENDIF()
+
+ IF(PYTHON_LIBRARY AND PYTHON_LIBPATH AND PYTHON_INCLUDE_DIR AND PYTHON_INCLUDE_CONFIG_DIR)
break()
ELSE()
# ensure we dont find values from 2 different ABI versions
IF(NOT _IS_INC_DEF)
UNSET(PYTHON_INCLUDE_DIR CACHE)
ENDIF()
+ IF(NOT _IS_INC_CONF_DEF)
+ UNSET(PYTHON_INCLUDE_CONFIG_DIR CACHE)
+ ENDIF()
IF(NOT _IS_LIB_DEF)
UNSET(PYTHON_LIBRARY CACHE)
ENDIF()
+ IF(NOT _IS_LIB_PATH_DEF)
+ UNSET(PYTHON_LIBPATH CACHE)
+ ENDIF()
ENDIF()
ENDFOREACH()
@@ -120,22 +167,25 @@ IF((NOT _IS_INC_DEF) OR (NOT _IS_LIB_DEF))
ENDIF()
UNSET(_IS_INC_DEF)
+UNSET(_IS_INC_CONF_DEF)
UNSET(_IS_LIB_DEF)
+UNSET(_IS_LIB_PATH_DEF)
# handle the QUIETLY and REQUIRED arguments and SET PYTHONLIBSUNIX_FOUND to TRUE IF
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonLibsUnix DEFAULT_MSG
- PYTHON_LIBRARY PYTHON_INCLUDE_DIR)
+ PYTHON_LIBRARY PYTHON_LIBPATH PYTHON_INCLUDE_DIR PYTHON_INCLUDE_CONFIG_DIR)
IF(PYTHONLIBSUNIX_FOUND)
# Assign cache items
- SET(PYTHON_INCLUDE_DIRS ${PYTHON_INCLUDE_DIR})
+ SET(PYTHON_INCLUDE_DIRS ${PYTHON_INCLUDE_DIR} ${PYTHON_INCLUDE_CONFIG_DIR})
SET(PYTHON_LIBRARIES ${PYTHON_LIBRARY})
# we need this for installation
- GET_FILENAME_COMPONENT(PYTHON_LIBPATH ${PYTHON_LIBRARY} PATH)
+ # XXX No more valid with debian-like py3.3 packages...
+# GET_FILENAME_COMPONENT(PYTHON_LIBPATH ${PYTHON_LIBRARY} PATH)
# not used
# SET(PYTHON_BINARY ${PYTHON_EXECUTABLE} CACHE STRING "")
@@ -143,5 +193,6 @@ ENDIF()
MARK_AS_ADVANCED(
PYTHON_INCLUDE_DIR
+ PYTHON_INCLUDE_CONFIG_DIR
PYTHON_LIBRARY
)
diff --git a/build_files/cmake/cmake_static_check_clang_array.py b/build_files/cmake/cmake_static_check_clang_array.py
index 941407170ff..db4e762932e 100644
--- a/build_files/cmake/cmake_static_check_clang_array.py
+++ b/build_files/cmake/cmake_static_check_clang_array.py
@@ -27,6 +27,8 @@ import subprocess
import sys
import os
+USE_QUIET = (os.environ.get("QUIET", None) is not None)
+
CHECKER_IGNORE_PREFIX = [
"extern",
"intern/moto",
@@ -59,11 +61,12 @@ def main():
process_functions = []
def my_process(i, c, cmd):
- percent = 100.0 * (i / (len(check_commands) - 1))
- percent_str = "[" + ("%.2f]" % percent).rjust(7) + " %:"
+ if not USE_QUIET:
+ percent = 100.0 * (i / (len(check_commands) - 1))
+ percent_str = "[" + ("%.2f]" % percent).rjust(7) + " %:"
- sys.stdout.flush()
- sys.stdout.write("%s " % percent_str)
+ sys.stdout.flush()
+ sys.stdout.write("%s " % percent_str)
return subprocess.Popen(cmd)
diff --git a/build_files/cmake/cmake_static_check_cppcheck.py b/build_files/cmake/cmake_static_check_cppcheck.py
index c458e8ede11..518b94d74a5 100644
--- a/build_files/cmake/cmake_static_check_cppcheck.py
+++ b/build_files/cmake/cmake_static_check_cppcheck.py
@@ -27,6 +27,8 @@ import subprocess
import sys
import os
+USE_QUIET = (os.environ.get("QUIET", None) is not None)
+
CHECKER_IGNORE_PREFIX = [
"extern",
"intern/moto",
@@ -62,11 +64,12 @@ def main():
process_functions = []
def my_process(i, c, cmd):
- percent = 100.0 * (i / (len(check_commands) - 1))
- percent_str = "[" + ("%.2f]" % percent).rjust(7) + " %:"
+ if not USE_QUIET:
+ percent = 100.0 * (i / (len(check_commands) - 1))
+ percent_str = "[" + ("%.2f]" % percent).rjust(7) + " %:"
- sys.stdout.flush()
- sys.stdout.write("%s " % percent_str)
+ sys.stdout.flush()
+ sys.stdout.write("%s " % percent_str)
return subprocess.Popen(cmd)
diff --git a/build_files/cmake/cmake_static_check_smatch.py b/build_files/cmake/cmake_static_check_smatch.py
index 5681d2ae5ed..8f7bd37d4c3 100644
--- a/build_files/cmake/cmake_static_check_smatch.py
+++ b/build_files/cmake/cmake_static_check_smatch.py
@@ -37,7 +37,9 @@ CHECKER_ARGS = [
import project_source_info
import subprocess
import sys
+import os
+USE_QUIET = (os.environ.get("QUIET", None) is not None)
def main():
source_info = project_source_info.build_info(use_cxx=False, ignore_prefix_list=CHECKER_IGNORE_PREFIX)
@@ -55,11 +57,12 @@ def main():
check_commands.append((c, cmd))
def my_process(i, c, cmd):
- percent = 100.0 * (i / (len(check_commands) - 1))
- percent_str = "[" + ("%.2f]" % percent).rjust(7) + " %:"
+ if not USE_QUIET:
+ percent = 100.0 * (i / (len(check_commands) - 1))
+ percent_str = "[" + ("%.2f]" % percent).rjust(7) + " %:"
- sys.stdout.flush()
- sys.stdout.write("%s %s\n" % (percent_str, c))
+ sys.stdout.flush()
+ sys.stdout.write("%s %s\n" % (percent_str, c))
return subprocess.Popen(cmd)
diff --git a/build_files/cmake/cmake_static_check_sparse.py b/build_files/cmake/cmake_static_check_sparse.py
index 4f4eb838dd5..92d590e52ac 100644
--- a/build_files/cmake/cmake_static_check_sparse.py
+++ b/build_files/cmake/cmake_static_check_sparse.py
@@ -35,6 +35,9 @@ CHECKER_ARGS = [
import project_source_info
import subprocess
import sys
+import os
+
+USE_QUIET = (os.environ.get("QUIET", None) is not None)
def main():
@@ -53,11 +56,12 @@ def main():
check_commands.append((c, cmd))
def my_process(i, c, cmd):
- percent = 100.0 * (i / (len(check_commands) - 1))
- percent_str = "[" + ("%.2f]" % percent).rjust(7) + " %:"
+ if not USE_QUIET:
+ percent = 100.0 * (i / (len(check_commands) - 1))
+ percent_str = "[" + ("%.2f]" % percent).rjust(7) + " %:"
- sys.stdout.flush()
- sys.stdout.write("%s %s\n" % (percent_str, c))
+ sys.stdout.flush()
+ sys.stdout.write("%s %s\n" % (percent_str, c))
return subprocess.Popen(cmd)
diff --git a/build_files/cmake/cmake_static_check_splint.py b/build_files/cmake/cmake_static_check_splint.py
index 7be28c01af8..d3f22191021 100644
--- a/build_files/cmake/cmake_static_check_splint.py
+++ b/build_files/cmake/cmake_static_check_splint.py
@@ -68,6 +68,9 @@ CHECKER_ARGS = [
import project_source_info
import subprocess
import sys
+import os
+
+USE_QUIET = (os.environ.get("QUIET", None) is not None)
def main():
@@ -85,11 +88,12 @@ def main():
check_commands.append((c, cmd))
def my_process(i, c, cmd):
- percent = 100.0 * (i / (len(check_commands) - 1))
- percent_str = "[" + ("%.2f]" % percent).rjust(7) + " %:"
+ if not USE_QUIET:
+ percent = 100.0 * (i / (len(check_commands) - 1))
+ percent_str = "[" + ("%.2f]" % percent).rjust(7) + " %:"
- sys.stdout.write("%s %s\n" % (percent_str, c))
- sys.stdout.flush()
+ sys.stdout.write("%s %s\n" % (percent_str, c))
+ sys.stdout.flush()
return subprocess.Popen(cmd)
diff --git a/build_files/scons/config/Modules/FindPython.py b/build_files/scons/config/Modules/FindPython.py
index 969d9db92a4..c93a10351d5 100644
--- a/build_files/scons/config/Modules/FindPython.py
+++ b/build_files/scons/config/Modules/FindPython.py
@@ -5,7 +5,7 @@ def FindPython():
python = "/usr"
abi_flags = "m" # Most common for linux distros
- version = "3.2"
+ version = "3.3"
# Determine ABI flags used on this system
include = os.path.join(python, "include")
diff --git a/doc/python_api/rst/bge.constraints.rst b/doc/python_api/rst/bge.constraints.rst
index 83f2a6b4950..7757e11d41f 100644
--- a/doc/python_api/rst/bge.constraints.rst
+++ b/doc/python_api/rst/bge.constraints.rst
@@ -78,6 +78,14 @@ Physics Constraints (bge.constraints)
:return: a vehicle constraint object.
:rtype: :class:`bge.types.KX_VehicleWrapper`
+
+.. function:: getCharacter(gameobj)
+
+ :arg gameobj: The game object with the character physics.
+ :type gameobj: :class:`bge.types.KX_GameObject`
+
+ :return: character wrapper
+ :rtype: :class:`bge.types.KX_CharacterWrapper`
.. function:: removeConstraint(constraintId)
diff --git a/doc/python_api/rst/bge.types.rst b/doc/python_api/rst/bge.types.rst
index a173137e50c..fdaeb61173f 100644
--- a/doc/python_api/rst/bge.types.rst
+++ b/doc/python_api/rst/bge.types.rst
@@ -3464,6 +3464,26 @@ Types
:arg wheelIndex: the wheel index
:type wheelIndex: integer
+.. class:: KX_CharacterWrapper(PyObjectPlus)
+
+ A wrapper to expose character physics options.
+
+ .. attribute:: onGround
+
+ Whether or not the character is on the ground. (read-only)
+
+ :type: boolean
+
+ .. attribute:: gravity
+
+ The gravity value used for the character.
+
+ :type: float
+
+ .. method:: jump()
+
+ The character jumps based on it's jump speed.
+
.. class:: KX_VertexProxy(SCA_IObject)
A vertex holds position, UV, color and normal information.
diff --git a/extern/carve/lib/intersect_face_division.cpp b/extern/carve/lib/intersect_face_division.cpp
index 08550c021ad..c74b52dd557 100644
--- a/extern/carve/lib/intersect_face_division.cpp
+++ b/extern/carve/lib/intersect_face_division.cpp
@@ -1106,7 +1106,8 @@ namespace {
}
// copy up to the end of the path.
- std::copy(base_loop.begin() + pos, base_loop.begin() + e1_1, std::back_inserter(out));
+ if (pos < e1_1)
+ std::copy(base_loop.begin() + pos, base_loop.begin() + e1_1, std::back_inserter(out));
CARVE_ASSERT(base_loop[e1_1] == p1.back());
std::copy(p1.rbegin(), p1.rend() - 1, std::back_inserter(out));
diff --git a/extern/glew/src/glew.c b/extern/glew/src/glew.c
index 5d886ce7807..833d3999268 100644
--- a/extern/glew/src/glew.c
+++ b/extern/glew/src/glew.c
@@ -93,7 +93,7 @@ void* dlGetProcAddress (const GLubyte* name)
#include <string.h>
#include <AvailabilityMacros.h>
-#ifdef MAC_OS_X_VERSION_10_3
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3
#include <dlfcn.h>
@@ -142,7 +142,7 @@ void* NSGLGetProcAddress (const GLubyte *name)
return NULL;
#endif
}
-#endif /* MAC_OS_X_VERSION_10_3 */
+#endif /* MAC_OS_X_VERSION_MIN_REQUIRED */
#endif /* __APPLE__ */
/*
diff --git a/extern/libmv/libmv-capi.cpp b/extern/libmv/libmv-capi.cpp
index 0f73234f49c..a15927f881d 100644
--- a/extern/libmv/libmv-capi.cpp
+++ b/extern/libmv/libmv-capi.cpp
@@ -550,7 +550,8 @@ static void libmv_solveRefineIntrinsics(libmv::Tracks *tracks, libmv::CameraIntr
}
libmv_Reconstruction *libmv_solveReconstruction(libmv_Tracks *tracks, int keyframe1, int keyframe2,
- int refine_intrinsics, double focal_length, double principal_x, double principal_y, double k1, double k2, double k3,
+ int refine_intrinsics, double focal_length, double principal_x, double principal_y,
+ double k1, double k2, double k3, struct libmv_reconstructionOptions *options,
reconstruct_progress_update_cb progress_update_callback, void *callback_customdata)
{
/* Invert the camera intrinsics. */
@@ -558,6 +559,7 @@ libmv_Reconstruction *libmv_solveReconstruction(libmv_Tracks *tracks, int keyfra
libmv_Reconstruction *libmv_reconstruction = new libmv_Reconstruction();
libmv::EuclideanReconstruction *reconstruction = &libmv_reconstruction->reconstruction;
libmv::CameraIntrinsics *intrinsics = &libmv_reconstruction->intrinsics;
+ libmv::ReconstructionOptions reconstruction_options;
ReconstructUpdateCallback update_callback =
ReconstructUpdateCallback(progress_update_callback, callback_customdata);
@@ -566,6 +568,9 @@ libmv_Reconstruction *libmv_solveReconstruction(libmv_Tracks *tracks, int keyfra
intrinsics->SetPrincipalPoint(principal_x, principal_y);
intrinsics->SetRadialDistortion(k1, k2, k3);
+ reconstruction_options.success_threshold = options->success_threshold;
+ reconstruction_options.use_fallback_reconstruction = options->use_fallback_reconstruction;
+
for (int i = 0; i < markers.size(); ++i) {
intrinsics->InvertIntrinsics(markers[i].x,
markers[i].y,
@@ -584,7 +589,8 @@ libmv_Reconstruction *libmv_solveReconstruction(libmv_Tracks *tracks, int keyfra
libmv::EuclideanReconstructTwoFrames(keyframe_markers, reconstruction);
libmv::EuclideanBundle(normalized_tracks, reconstruction);
- libmv::EuclideanCompleteReconstruction(normalized_tracks, reconstruction, &update_callback);
+ libmv::EuclideanCompleteReconstruction(reconstruction_options, normalized_tracks,
+ reconstruction, &update_callback);
if (refine_intrinsics) {
libmv_solveRefineIntrinsics((libmv::Tracks *)tracks, intrinsics, reconstruction,
diff --git a/extern/libmv/libmv-capi.h b/extern/libmv/libmv-capi.h
index 5253ba76a21..e5885e7addf 100644
--- a/extern/libmv/libmv-capi.h
+++ b/extern/libmv/libmv-capi.h
@@ -91,13 +91,20 @@ void libmv_tracksDestroy(struct libmv_Tracks *libmv_tracks);
#define LIBMV_REFINE_RADIAL_DISTORTION_K1 (1<<2)
#define LIBMV_REFINE_RADIAL_DISTORTION_K2 (1<<4)
+/* TODO: make keyframes/distortion model a part of options? */
+struct libmv_reconstructionOptions {
+ double success_threshold;
+ int use_fallback_reconstruction;
+};
+
typedef void (*reconstruct_progress_update_cb) (void *customdata, double progress, const char *message);
int libmv_refineParametersAreValid(int parameters);
struct libmv_Reconstruction *libmv_solveReconstruction(struct libmv_Tracks *tracks, int keyframe1, int keyframe2,
int refine_intrinsics, double focal_length, double principal_x, double principal_y, double k1, double k2, double k3,
- reconstruct_progress_update_cb progress_update_callback, void *callback_customdata);
+ struct libmv_reconstructionOptions *options, reconstruct_progress_update_cb progress_update_callback,
+ void *callback_customdata);
struct libmv_Reconstruction *libmv_solveModal(struct libmv_Tracks *tracks, double focal_length,
double principal_x, double principal_y, double k1, double k2, double k3,
reconstruct_progress_update_cb progress_update_callback, void *callback_customdata);
diff --git a/extern/libmv/libmv/multiview/euclidean_resection.cc b/extern/libmv/libmv/multiview/euclidean_resection.cc
index 6cad4cac049..2605bf04622 100644
--- a/extern/libmv/libmv/multiview/euclidean_resection.cc
+++ b/extern/libmv/libmv/multiview/euclidean_resection.cc
@@ -37,13 +37,14 @@ typedef unsigned int uint;
bool EuclideanResection(const Mat2X &x_camera,
const Mat3X &X_world,
Mat3 *R, Vec3 *t,
- ResectionMethod method) {
+ ResectionMethod method,
+ double success_threshold) {
switch (method) {
case RESECTION_ANSAR_DANIILIDIS:
EuclideanResectionAnsarDaniilidis(x_camera, X_world, R, t);
break;
case RESECTION_EPNP:
- return EuclideanResectionEPnP(x_camera, X_world, R, t);
+ return EuclideanResectionEPnP(x_camera, X_world, R, t, success_threshold);
break;
default:
LOG(FATAL) << "Unknown resection method.";
@@ -435,8 +436,9 @@ static void ComputePointsCoordinatesInCameraFrame(
}
bool EuclideanResectionEPnP(const Mat2X &x_camera,
- const Mat3X &X_world,
- Mat3 *R, Vec3 *t) {
+ const Mat3X &X_world,
+ Mat3 *R, Vec3 *t,
+ double success_threshold) {
CHECK(x_camera.cols() == X_world.cols());
CHECK(x_camera.cols() > 3);
size_t num_points = X_world.cols();
@@ -544,7 +546,12 @@ bool EuclideanResectionEPnP(const Mat2X &x_camera,
//
// TODO(keir): Decide if setting this to infinity, effectively disabling the
// check, is the right approach. So far this seems the case.
- double kSuccessThreshold = std::numeric_limits<double>::max();
+ //
+ // TODO(sergey): Made it an option for now, in some cases it makes sense to
+ // still fallback to reprojection solution (see bug [#32765] from Blender bug tracker)
+
+ // double kSuccessThreshold = std::numeric_limits<double>::max();
+ double kSuccessThreshold = success_threshold;
// Find the first possible solution for R, t corresponding to:
// Betas = [b00 b01 b11 b02 b12 b22 b03 b13 b23 b33]
diff --git a/extern/libmv/libmv/multiview/euclidean_resection.h b/extern/libmv/libmv/multiview/euclidean_resection.h
index f20513d3fbe..b0428ec61fd 100644
--- a/extern/libmv/libmv/multiview/euclidean_resection.h
+++ b/extern/libmv/libmv/multiview/euclidean_resection.h
@@ -45,11 +45,14 @@ enum ResectionMethod {
* \param R Solution for the camera rotation matrix
* \param t Solution for the camera translation vector
* \param method The resection method to use.
+ * \param success_threshold Threshold of an error which is still considered a success
+ * (currently used by EPnP algorithm only)
*/
bool EuclideanResection(const Mat2X &x_camera,
const Mat3X &X_world,
Mat3 *R, Vec3 *t,
- ResectionMethod method = RESECTION_EPNP);
+ ResectionMethod method = RESECTION_EPNP,
+ double success_threshold = 1e-3);
/**
* Computes the extrinsic parameters, R and t for a calibrated camera
@@ -110,6 +113,7 @@ void EuclideanResectionAnsarDaniilidis(const Mat2X &x_camera,
* \param X_world 3D points in the world coordinate system
* \param R Solution for the camera rotation matrix
* \param t Solution for the camera translation vector
+ * \param success_threshold Threshold of an error which is still considered a success
*
* This is the algorithm described in:
* "{EP$n$P: An Accurate $O(n)$ Solution to the P$n$P Problem", by V. Lepetit
@@ -118,7 +122,8 @@ void EuclideanResectionAnsarDaniilidis(const Mat2X &x_camera,
*/
bool EuclideanResectionEPnP(const Mat2X &x_camera,
const Mat3X &X_world,
- Mat3 *R, Vec3 *t);
+ Mat3 *R, Vec3 *t,
+ double success_threshold = 1e-3);
} // namespace euclidean_resection
} // namespace libmv
diff --git a/extern/libmv/libmv/simple_pipeline/pipeline.cc b/extern/libmv/libmv/simple_pipeline/pipeline.cc
index 4773a70d69b..efceda5c455 100644
--- a/extern/libmv/libmv/simple_pipeline/pipeline.cc
+++ b/extern/libmv/libmv/simple_pipeline/pipeline.cc
@@ -50,9 +50,10 @@ struct EuclideanPipelineRoutines {
EuclideanBundle(tracks, reconstruction);
}
- static bool Resect(const vector<Marker> &markers,
+ static bool Resect(const ReconstructionOptions &options,
+ const vector<Marker> &markers,
EuclideanReconstruction *reconstruction, bool final_pass) {
- return EuclideanResect(markers, reconstruction, final_pass);
+ return EuclideanResect(options, markers, reconstruction, final_pass);
}
static bool Intersect(const vector<Marker> &markers,
@@ -88,7 +89,8 @@ struct ProjectivePipelineRoutines {
ProjectiveBundle(tracks, reconstruction);
}
- static bool Resect(const vector<Marker> &markers,
+ static bool Resect(const ReconstructionOptions &options,
+ const vector<Marker> &markers,
ProjectiveReconstruction *reconstruction, bool final_pass) {
return ProjectiveResect(markers, reconstruction);
}
@@ -136,6 +138,7 @@ static void CompleteReconstructionLogProress(ProgressUpdateCallback *update_call
template<typename PipelineRoutines>
void InternalCompleteReconstruction(
+ const ReconstructionOptions &options,
const Tracks &tracks,
typename PipelineRoutines::Reconstruction *reconstruction,
ProgressUpdateCallback *update_callback = NULL) {
@@ -204,7 +207,7 @@ void InternalCompleteReconstruction(
if (reconstructed_markers.size() >= 5) {
CompleteReconstructionLogProress(update_callback,
(double)tot_resects/(max_image));
- if (PipelineRoutines::Resect(reconstructed_markers, reconstruction, false)) {
+ if (PipelineRoutines::Resect(options, reconstructed_markers, reconstruction, false)) {
num_resects++;
tot_resects++;
LG << "Ran Resect() for image " << image;
@@ -240,7 +243,7 @@ void InternalCompleteReconstruction(
if (reconstructed_markers.size() >= 5) {
CompleteReconstructionLogProress(update_callback,
(double)tot_resects/(max_image));
- if (PipelineRoutines::Resect(reconstructed_markers, reconstruction, true)) {
+ if (PipelineRoutines::Resect(options, reconstructed_markers, reconstruction, true)) {
num_resects++;
LG << "Ran final Resect() for image " << image;
} else {
@@ -325,17 +328,21 @@ double ProjectiveReprojectionError(
intrinsics);
}
-void EuclideanCompleteReconstruction(const Tracks &tracks,
+void EuclideanCompleteReconstruction(const ReconstructionOptions &options,
+ const Tracks &tracks,
EuclideanReconstruction *reconstruction,
ProgressUpdateCallback *update_callback) {
- InternalCompleteReconstruction<EuclideanPipelineRoutines>(tracks,
+ InternalCompleteReconstruction<EuclideanPipelineRoutines>(options,
+ tracks,
reconstruction,
update_callback);
}
-void ProjectiveCompleteReconstruction(const Tracks &tracks,
+void ProjectiveCompleteReconstruction(const ReconstructionOptions &options,
+ const Tracks &tracks,
ProjectiveReconstruction *reconstruction) {
- InternalCompleteReconstruction<ProjectivePipelineRoutines>(tracks,
+ InternalCompleteReconstruction<ProjectivePipelineRoutines>(options,
+ tracks,
reconstruction);
}
diff --git a/extern/libmv/libmv/simple_pipeline/pipeline.h b/extern/libmv/libmv/simple_pipeline/pipeline.h
index e940b57bc0d..11c11297d78 100644
--- a/extern/libmv/libmv/simple_pipeline/pipeline.h
+++ b/extern/libmv/libmv/simple_pipeline/pipeline.h
@@ -39,6 +39,9 @@ namespace libmv {
repeated until all points and cameras are estimated. Periodically, bundle
adjustment is run to ensure a quality reconstruction.
+ \a options are used to define some specific befaviours based on settings
+ see documentation for ReconstructionOptions
+
\a tracks should contain markers used in the reconstruction.
\a reconstruction should contain at least some 3D points or some estimated
cameras. The minimum number of cameras is two (with no 3D points) and the
@@ -46,7 +49,8 @@ namespace libmv {
\sa EuclideanResect, EuclideanIntersect, EuclideanBundle
*/
-void EuclideanCompleteReconstruction(const Tracks &tracks,
+void EuclideanCompleteReconstruction(const ReconstructionOptions &options,
+ const Tracks &tracks,
EuclideanReconstruction *reconstruction,
ProgressUpdateCallback *update_callback = NULL);
@@ -63,6 +67,9 @@ void EuclideanCompleteReconstruction(const Tracks &tracks,
repeated until all points and cameras are estimated. Periodically, bundle
adjustment is run to ensure a quality reconstruction.
+ \a options are used to define some specific befaviours based on settings
+ see documentation for ReconstructionOptions
+
\a tracks should contain markers used in the reconstruction.
\a reconstruction should contain at least some 3D points or some estimated
cameras. The minimum number of cameras is two (with no 3D points) and the
@@ -70,7 +77,8 @@ void EuclideanCompleteReconstruction(const Tracks &tracks,
\sa ProjectiveResect, ProjectiveIntersect, ProjectiveBundle
*/
-void ProjectiveCompleteReconstruction(const Tracks &tracks,
+void ProjectiveCompleteReconstruction(const ReconstructionOptions &options,
+ const Tracks &tracks,
ProjectiveReconstruction *reconstruction);
diff --git a/extern/libmv/libmv/simple_pipeline/reconstruction.h b/extern/libmv/libmv/simple_pipeline/reconstruction.h
index 947a0636476..71789e3a245 100644
--- a/extern/libmv/libmv/simple_pipeline/reconstruction.h
+++ b/extern/libmv/libmv/simple_pipeline/reconstruction.h
@@ -26,6 +26,17 @@
namespace libmv {
+struct ReconstructionOptions {
+ // threshold value of reconstruction error which is still considered successful
+ // if reconstruction error bigger than this value, fallback reconstruction
+ // algorithm would be used (if enabled)
+ double success_threshold;
+
+ // use fallback reconstruction algorithm in cases main reconstruction algorithm
+ // failed to reconstruct
+ bool use_fallback_reconstruction;
+};
+
/*!
A EuclideanCamera is the location and rotation of the camera viewing \a image.
diff --git a/extern/libmv/libmv/simple_pipeline/resect.cc b/extern/libmv/libmv/simple_pipeline/resect.cc
index 8737182dd43..4c9ca6d8677 100644
--- a/extern/libmv/libmv/simple_pipeline/resect.cc
+++ b/extern/libmv/libmv/simple_pipeline/resect.cc
@@ -90,7 +90,8 @@ struct EuclideanResectCostFunction {
} // namespace
-bool EuclideanResect(const vector<Marker> &markers,
+bool EuclideanResect(const ReconstructionOptions &options,
+ const vector<Marker> &markers,
EuclideanReconstruction *reconstruction, bool final_pass) {
if (markers.size() < 5) {
return false;
@@ -104,13 +105,24 @@ bool EuclideanResect(const vector<Marker> &markers,
Mat3 R;
Vec3 t;
- if (0 || !euclidean_resection::EuclideanResection(points_2d, points_3d, &R, &t)) {
+
+ double success_threshold = std::numeric_limits<double>::max();
+
+ if(options.use_fallback_reconstruction)
+ success_threshold = options.success_threshold;
+
+ if (0 || !euclidean_resection::EuclideanResection(points_2d, points_3d, &R, &t,
+ euclidean_resection::RESECTION_EPNP,
+ success_threshold))
+ {
// printf("Resection for image %d failed\n", markers[0].image);
LG << "Resection for image " << markers[0].image << " failed;"
<< " trying fallback projective resection.";
- LG << "No fallback; failing resection for " << markers[0].image;
- return false;
+ if (!options.use_fallback_reconstruction) {
+ LG << "No fallback; failing resection for " << markers[0].image;
+ return false;
+ }
if (!final_pass) return false;
// Euclidean resection failed. Fall back to projective resection, which is
diff --git a/extern/libmv/libmv/simple_pipeline/resect.h b/extern/libmv/libmv/simple_pipeline/resect.h
index f8b5b9f68ee..1691e7ee245 100644
--- a/extern/libmv/libmv/simple_pipeline/resect.h
+++ b/extern/libmv/libmv/simple_pipeline/resect.h
@@ -35,6 +35,9 @@ namespace libmv {
reconstruction object, and solves for the pose and orientation of the
camera for that frame.
+ \a options are used to define some specific befaviours based on settings
+ see documentation for ReconstructionOptions
+
\a markers should contain \l Marker markers \endlink belonging to tracks
visible in the one frame to be resectioned. Each of the tracks associated
with the markers must have a corresponding reconstructed 3D position in the
@@ -51,7 +54,8 @@ namespace libmv {
\sa EuclideanIntersect, EuclideanReconstructTwoFrames
*/
-bool EuclideanResect(const vector<Marker> &markers,
+bool EuclideanResect(const ReconstructionOptions &options,
+ const vector<Marker> &markers,
EuclideanReconstruction *reconstruction, bool final_pass);
/*!
diff --git a/intern/audaspace/CMakeLists.txt b/intern/audaspace/CMakeLists.txt
index 1671194653a..1617e520ac7 100644
--- a/intern/audaspace/CMakeLists.txt
+++ b/intern/audaspace/CMakeLists.txt
@@ -28,6 +28,7 @@ set(INC
set(INC_SYS
${PTHREADS_INCLUDE_DIRS}
+ ${BOOST_INCLUDE_DIR}
)
set(SRC
@@ -115,11 +116,11 @@ set(SRC
intern/AUD_PyInit.h
intern/AUD_ReadDevice.cpp
intern/AUD_ReadDevice.h
- intern/AUD_Reference.h
- intern/AUD_ReferenceHandler.cpp
intern/AUD_ResampleFactory.h
intern/AUD_ResampleReader.cpp
intern/AUD_ResampleReader.h
+ intern/AUD_Sequencer.cpp
+ intern/AUD_Sequencer.h
intern/AUD_SequencerEntry.cpp
intern/AUD_SequencerEntry.h
intern/AUD_SequencerFactory.cpp
@@ -150,6 +151,7 @@ set(SRC
FX/AUD_DelayReader.h
FX/AUD_DoubleFactory.h
FX/AUD_DoubleReader.h
+ FX/AUD_IDynamicIIRFilterCalculator.h
FX/AUD_DynamicIIRFilterFactory.h
FX/AUD_DynamicIIRFilterReader.h
FX/AUD_EffectFactory.h
diff --git a/intern/audaspace/FX/AUD_AccumulatorFactory.cpp b/intern/audaspace/FX/AUD_AccumulatorFactory.cpp
index 1862b9ab79d..00d3a9f2395 100644
--- a/intern/audaspace/FX/AUD_AccumulatorFactory.cpp
+++ b/intern/audaspace/FX/AUD_AccumulatorFactory.cpp
@@ -50,15 +50,15 @@ sample_t AUD_AccumulatorFactory::accumulatorFilter(AUD_CallbackIIRFilterReader*
return out;
}
-AUD_AccumulatorFactory::AUD_AccumulatorFactory(AUD_Reference<AUD_IFactory> factory,
+AUD_AccumulatorFactory::AUD_AccumulatorFactory(boost::shared_ptr<AUD_IFactory> factory,
bool additive) :
AUD_EffectFactory(factory),
m_additive(additive)
{
}
-AUD_Reference<AUD_IReader> AUD_AccumulatorFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_AccumulatorFactory::createReader()
{
- return new AUD_CallbackIIRFilterReader(getReader(), 2, 2,
- m_additive ? accumulatorFilterAdditive : accumulatorFilter);
+ return boost::shared_ptr<AUD_IReader>(new AUD_CallbackIIRFilterReader(getReader(), 2, 2,
+ m_additive ? accumulatorFilterAdditive : accumulatorFilter));
}
diff --git a/intern/audaspace/FX/AUD_AccumulatorFactory.h b/intern/audaspace/FX/AUD_AccumulatorFactory.h
index ac73c5aa6ae..9087218a5f9 100644
--- a/intern/audaspace/FX/AUD_AccumulatorFactory.h
+++ b/intern/audaspace/FX/AUD_AccumulatorFactory.h
@@ -58,9 +58,9 @@ public:
* \param factory The input factory.
* \param additive Whether the accumulator is additive.
*/
- AUD_AccumulatorFactory(AUD_Reference<AUD_IFactory> factory, bool additive = false);
+ AUD_AccumulatorFactory(boost::shared_ptr<AUD_IFactory> factory, bool additive = false);
- virtual AUD_Reference<AUD_IReader> createReader();
+ virtual boost::shared_ptr<AUD_IReader> createReader();
static sample_t accumulatorFilterAdditive(AUD_CallbackIIRFilterReader* reader, void* useless);
static sample_t accumulatorFilter(AUD_CallbackIIRFilterReader* reader, void* useless);
diff --git a/intern/audaspace/FX/AUD_BaseIIRFilterReader.cpp b/intern/audaspace/FX/AUD_BaseIIRFilterReader.cpp
index fa9e8746b2b..eadfc525f96 100644
--- a/intern/audaspace/FX/AUD_BaseIIRFilterReader.cpp
+++ b/intern/audaspace/FX/AUD_BaseIIRFilterReader.cpp
@@ -33,7 +33,7 @@
#define CC m_specs.channels + m_channel
-AUD_BaseIIRFilterReader::AUD_BaseIIRFilterReader(AUD_Reference<AUD_IReader> reader, int in,
+AUD_BaseIIRFilterReader::AUD_BaseIIRFilterReader(boost::shared_ptr<AUD_IReader> reader, int in,
int out) :
AUD_EffectReader(reader),
m_specs(reader->getSpecs()),
diff --git a/intern/audaspace/FX/AUD_BaseIIRFilterReader.h b/intern/audaspace/FX/AUD_BaseIIRFilterReader.h
index 43970c96a42..fe0a8efce64 100644
--- a/intern/audaspace/FX/AUD_BaseIIRFilterReader.h
+++ b/intern/audaspace/FX/AUD_BaseIIRFilterReader.h
@@ -90,7 +90,7 @@ protected:
* \param in The count of past input samples needed.
* \param out The count of past output samples needed.
*/
- AUD_BaseIIRFilterReader(AUD_Reference<AUD_IReader> reader, int in, int out);
+ AUD_BaseIIRFilterReader(boost::shared_ptr<AUD_IReader> reader, int in, int out);
void setLengths(int in, int out);
diff --git a/intern/audaspace/FX/AUD_ButterworthFactory.cpp b/intern/audaspace/FX/AUD_ButterworthFactory.cpp
index af1a5af97df..97d85c8122f 100644
--- a/intern/audaspace/FX/AUD_ButterworthFactory.cpp
+++ b/intern/audaspace/FX/AUD_ButterworthFactory.cpp
@@ -39,7 +39,7 @@
#define BWPB41 0.76536686473
#define BWPB42 1.84775906502
-AUD_ButterworthFactory::AUD_ButterworthFactory(AUD_Reference<AUD_IFactory> factory,
+AUD_ButterworthFactory::AUD_ButterworthFactory(boost::shared_ptr<AUD_IFactory> factory,
float frequency) :
AUD_DynamicIIRFilterFactory(factory),
m_frequency(frequency)
diff --git a/intern/audaspace/FX/AUD_ButterworthFactory.h b/intern/audaspace/FX/AUD_ButterworthFactory.h
index dc8b4d92775..e796f76aa29 100644
--- a/intern/audaspace/FX/AUD_ButterworthFactory.h
+++ b/intern/audaspace/FX/AUD_ButterworthFactory.h
@@ -53,7 +53,7 @@ public:
* \param factory The input factory.
* \param frequency The cutoff frequency.
*/
- AUD_ButterworthFactory(AUD_Reference<AUD_IFactory> factory, float frequency);
+ AUD_ButterworthFactory(boost::shared_ptr<AUD_IFactory> factory, float frequency);
virtual void recalculateCoefficients(AUD_SampleRate rate,
std::vector<float>& b,
diff --git a/intern/audaspace/FX/AUD_CallbackIIRFilterReader.cpp b/intern/audaspace/FX/AUD_CallbackIIRFilterReader.cpp
index 1a5c99adfb9..b5157d47666 100644
--- a/intern/audaspace/FX/AUD_CallbackIIRFilterReader.cpp
+++ b/intern/audaspace/FX/AUD_CallbackIIRFilterReader.cpp
@@ -29,7 +29,7 @@
#include "AUD_CallbackIIRFilterReader.h"
-AUD_CallbackIIRFilterReader::AUD_CallbackIIRFilterReader(AUD_Reference<AUD_IReader> reader,
+AUD_CallbackIIRFilterReader::AUD_CallbackIIRFilterReader(boost::shared_ptr<AUD_IReader> reader,
int in, int out,
doFilterIIR doFilter,
endFilterIIR endFilter,
diff --git a/intern/audaspace/FX/AUD_CallbackIIRFilterReader.h b/intern/audaspace/FX/AUD_CallbackIIRFilterReader.h
index 7ced73844c9..d9df65f03eb 100644
--- a/intern/audaspace/FX/AUD_CallbackIIRFilterReader.h
+++ b/intern/audaspace/FX/AUD_CallbackIIRFilterReader.h
@@ -74,7 +74,7 @@ public:
* \param endFilter The finishing callback.
* \param data Data pointer for the callbacks.
*/
- AUD_CallbackIIRFilterReader(AUD_Reference<AUD_IReader> reader, int in, int out,
+ AUD_CallbackIIRFilterReader(boost::shared_ptr<AUD_IReader> reader, int in, int out,
doFilterIIR doFilter,
endFilterIIR endFilter = 0,
void* data = 0);
diff --git a/intern/audaspace/FX/AUD_DelayFactory.cpp b/intern/audaspace/FX/AUD_DelayFactory.cpp
index a4606597933..3e5a7cfd2f8 100644
--- a/intern/audaspace/FX/AUD_DelayFactory.cpp
+++ b/intern/audaspace/FX/AUD_DelayFactory.cpp
@@ -31,7 +31,7 @@
#include "AUD_DelayReader.h"
#include "AUD_Space.h"
-AUD_DelayFactory::AUD_DelayFactory(AUD_Reference<AUD_IFactory> factory, float delay) :
+AUD_DelayFactory::AUD_DelayFactory(boost::shared_ptr<AUD_IFactory> factory, float delay) :
AUD_EffectFactory(factory),
m_delay(delay)
{
@@ -42,7 +42,7 @@ float AUD_DelayFactory::getDelay() const
return m_delay;
}
-AUD_Reference<AUD_IReader> AUD_DelayFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_DelayFactory::createReader()
{
- return new AUD_DelayReader(getReader(), m_delay);
+ return boost::shared_ptr<AUD_IReader>(new AUD_DelayReader(getReader(), m_delay));
}
diff --git a/intern/audaspace/FX/AUD_DelayFactory.h b/intern/audaspace/FX/AUD_DelayFactory.h
index 26855a05d70..8cfb2be9ac8 100644
--- a/intern/audaspace/FX/AUD_DelayFactory.h
+++ b/intern/audaspace/FX/AUD_DelayFactory.h
@@ -53,14 +53,14 @@ public:
* \param factory The input factory.
* \param delay The desired delay in seconds.
*/
- AUD_DelayFactory(AUD_Reference<AUD_IFactory> factory, float delay = 0);
+ AUD_DelayFactory(boost::shared_ptr<AUD_IFactory> factory, float delay = 0);
/**
* Returns the delay in seconds.
*/
float getDelay() const;
- virtual AUD_Reference<AUD_IReader> createReader();
+ virtual boost::shared_ptr<AUD_IReader> createReader();
};
#endif //__AUD_DELAYFACTORY_H__
diff --git a/intern/audaspace/FX/AUD_DelayReader.cpp b/intern/audaspace/FX/AUD_DelayReader.cpp
index 0e9833cd07f..050508f28da 100644
--- a/intern/audaspace/FX/AUD_DelayReader.cpp
+++ b/intern/audaspace/FX/AUD_DelayReader.cpp
@@ -31,7 +31,7 @@
#include <cstring>
-AUD_DelayReader::AUD_DelayReader(AUD_Reference<AUD_IReader> reader, float delay) :
+AUD_DelayReader::AUD_DelayReader(boost::shared_ptr<AUD_IReader> reader, float delay) :
AUD_EffectReader(reader),
m_delay(int((AUD_SampleRate)delay * reader->getSpecs().rate)),
m_remdelay(int((AUD_SampleRate)delay * reader->getSpecs().rate))
diff --git a/intern/audaspace/FX/AUD_DelayReader.h b/intern/audaspace/FX/AUD_DelayReader.h
index 9d9b6619470..d4388e3befc 100644
--- a/intern/audaspace/FX/AUD_DelayReader.h
+++ b/intern/audaspace/FX/AUD_DelayReader.h
@@ -59,7 +59,7 @@ public:
* \param reader The reader to read from.
* \param delay The delay in seconds.
*/
- AUD_DelayReader(AUD_Reference<AUD_IReader> reader, float delay);
+ AUD_DelayReader(boost::shared_ptr<AUD_IReader> reader, float delay);
virtual void seek(int position);
virtual int getLength() const;
diff --git a/intern/audaspace/FX/AUD_DoubleFactory.cpp b/intern/audaspace/FX/AUD_DoubleFactory.cpp
index ab0111f8955..21bcbc2f649 100644
--- a/intern/audaspace/FX/AUD_DoubleFactory.cpp
+++ b/intern/audaspace/FX/AUD_DoubleFactory.cpp
@@ -30,15 +30,15 @@
#include "AUD_DoubleFactory.h"
#include "AUD_DoubleReader.h"
-AUD_DoubleFactory::AUD_DoubleFactory(AUD_Reference<AUD_IFactory> factory1, AUD_Reference<AUD_IFactory> factory2) :
+AUD_DoubleFactory::AUD_DoubleFactory(boost::shared_ptr<AUD_IFactory> factory1, boost::shared_ptr<AUD_IFactory> factory2) :
m_factory1(factory1), m_factory2(factory2)
{
}
-AUD_Reference<AUD_IReader> AUD_DoubleFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_DoubleFactory::createReader()
{
- AUD_Reference<AUD_IReader> reader1 = m_factory1->createReader();
- AUD_Reference<AUD_IReader> reader2 = m_factory2->createReader();
+ boost::shared_ptr<AUD_IReader> reader1 = m_factory1->createReader();
+ boost::shared_ptr<AUD_IReader> reader2 = m_factory2->createReader();
- return new AUD_DoubleReader(reader1, reader2);
+ return boost::shared_ptr<AUD_IReader>(new AUD_DoubleReader(reader1, reader2));
}
diff --git a/intern/audaspace/FX/AUD_DoubleFactory.h b/intern/audaspace/FX/AUD_DoubleFactory.h
index e4d8fbfde8f..4a02cc7bcdb 100644
--- a/intern/audaspace/FX/AUD_DoubleFactory.h
+++ b/intern/audaspace/FX/AUD_DoubleFactory.h
@@ -41,12 +41,12 @@ private:
/**
* First played factory.
*/
- AUD_Reference<AUD_IFactory> m_factory1;
+ boost::shared_ptr<AUD_IFactory> m_factory1;
/**
* Second played factory.
*/
- AUD_Reference<AUD_IFactory> m_factory2;
+ boost::shared_ptr<AUD_IFactory> m_factory2;
// hide copy constructor and operator=
AUD_DoubleFactory(const AUD_DoubleFactory&);
@@ -58,9 +58,9 @@ public:
* \param factory1 The first input factory.
* \param factory2 The second input factory.
*/
- AUD_DoubleFactory(AUD_Reference<AUD_IFactory> factory1, AUD_Reference<AUD_IFactory> factory2);
+ AUD_DoubleFactory(boost::shared_ptr<AUD_IFactory> factory1, boost::shared_ptr<AUD_IFactory> factory2);
- virtual AUD_Reference<AUD_IReader> createReader();
+ virtual boost::shared_ptr<AUD_IReader> createReader();
};
#endif //__AUD_DOUBLEFACTORY_H__
diff --git a/intern/audaspace/FX/AUD_DoubleReader.cpp b/intern/audaspace/FX/AUD_DoubleReader.cpp
index 2b28bc7d679..ee18914e93f 100644
--- a/intern/audaspace/FX/AUD_DoubleReader.cpp
+++ b/intern/audaspace/FX/AUD_DoubleReader.cpp
@@ -31,8 +31,8 @@
#include <cstring>
-AUD_DoubleReader::AUD_DoubleReader(AUD_Reference<AUD_IReader> reader1,
- AUD_Reference<AUD_IReader> reader2) :
+AUD_DoubleReader::AUD_DoubleReader(boost::shared_ptr<AUD_IReader> reader1,
+ boost::shared_ptr<AUD_IReader> reader2) :
m_reader1(reader1), m_reader2(reader2), m_finished1(false)
{
AUD_Specs s1, s2;
diff --git a/intern/audaspace/FX/AUD_DoubleReader.h b/intern/audaspace/FX/AUD_DoubleReader.h
index 1489f4eb184..5d2f65f1a90 100644
--- a/intern/audaspace/FX/AUD_DoubleReader.h
+++ b/intern/audaspace/FX/AUD_DoubleReader.h
@@ -32,7 +32,8 @@
#include "AUD_IReader.h"
#include "AUD_Buffer.h"
-#include "AUD_Reference.h"
+
+#include <boost/shared_ptr.hpp>
/**
* This reader plays two readers sequently.
@@ -43,12 +44,12 @@ private:
/**
* The first reader.
*/
- AUD_Reference<AUD_IReader> m_reader1;
+ boost::shared_ptr<AUD_IReader> m_reader1;
/**
* The second reader.
*/
- AUD_Reference<AUD_IReader> m_reader2;
+ boost::shared_ptr<AUD_IReader> m_reader2;
/**
* Whether we've reached the end of the first reader.
@@ -65,7 +66,7 @@ public:
* \param reader1 The first reader to read from.
* \param reader2 The second reader to read from.
*/
- AUD_DoubleReader(AUD_Reference<AUD_IReader> reader1, AUD_Reference<AUD_IReader> reader2);
+ AUD_DoubleReader(boost::shared_ptr<AUD_IReader> reader1, boost::shared_ptr<AUD_IReader> reader2);
/**
* Destroys the reader.
diff --git a/intern/audaspace/FX/AUD_DynamicIIRFilterFactory.cpp b/intern/audaspace/FX/AUD_DynamicIIRFilterFactory.cpp
index 3d6beb6c554..e8ea4323b2e 100644
--- a/intern/audaspace/FX/AUD_DynamicIIRFilterFactory.cpp
+++ b/intern/audaspace/FX/AUD_DynamicIIRFilterFactory.cpp
@@ -29,12 +29,14 @@
#include "AUD_DynamicIIRFilterFactory.h"
#include "AUD_DynamicIIRFilterReader.h"
-AUD_DynamicIIRFilterFactory::AUD_DynamicIIRFilterFactory(AUD_Reference<AUD_IFactory> factory) :
+
+AUD_DynamicIIRFilterFactory::AUD_DynamicIIRFilterFactory(boost::shared_ptr<AUD_IFactory> factory) :
AUD_EffectFactory(factory)
{
}
-AUD_Reference<AUD_IReader> AUD_DynamicIIRFilterFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_DynamicIIRFilterFactory::createReader()
{
- return new AUD_DynamicIIRFilterReader(getReader(), this);
+ return boost::shared_ptr<AUD_IReader>(new AUD_DynamicIIRFilterReader(getReader(), m_calculator));
}
+
diff --git a/intern/audaspace/FX/AUD_DynamicIIRFilterFactory.h b/intern/audaspace/FX/AUD_DynamicIIRFilterFactory.h
index 5b297db2d56..f36a37f44b4 100644
--- a/intern/audaspace/FX/AUD_DynamicIIRFilterFactory.h
+++ b/intern/audaspace/FX/AUD_DynamicIIRFilterFactory.h
@@ -30,6 +30,7 @@
#define __AUD_DYNAMICIIRFILTERFACTORY_H__
#include "AUD_EffectFactory.h"
+#include "AUD_IDynamicIIRFilterCalculator.h"
#include <vector>
/**
@@ -40,24 +41,17 @@
*/
class AUD_DynamicIIRFilterFactory : public AUD_EffectFactory
{
+protected:
+ boost::shared_ptr<AUD_IDynamicIIRFilterCalculator> m_calculator;
+
public:
/**
* Creates a new Dynmic IIR filter factory.
* \param factory The input factory.
*/
- AUD_DynamicIIRFilterFactory(AUD_Reference<AUD_IFactory> factory);
-
- virtual AUD_Reference<AUD_IReader> createReader();
+ AUD_DynamicIIRFilterFactory(boost::shared_ptr<AUD_IFactory> factory);
- /**
- * Recalculates the filter coefficients.
- * \param rate The sample rate of the audio data.
- * \param[out] b The input filter coefficients.
- * \param[out] a The output filter coefficients.
- */
- virtual void recalculateCoefficients(AUD_SampleRate rate,
- std::vector<float>& b,
- std::vector<float>& a)=0;
+ virtual boost::shared_ptr<AUD_IReader> createReader();
};
#endif // __AUD_DYNAMICIIRFILTERFACTORY_H__
diff --git a/intern/audaspace/FX/AUD_DynamicIIRFilterReader.cpp b/intern/audaspace/FX/AUD_DynamicIIRFilterReader.cpp
index 24332ebfc1a..52aaf2311c0 100644
--- a/intern/audaspace/FX/AUD_DynamicIIRFilterReader.cpp
+++ b/intern/audaspace/FX/AUD_DynamicIIRFilterReader.cpp
@@ -28,10 +28,10 @@
#include "AUD_DynamicIIRFilterReader.h"
-AUD_DynamicIIRFilterReader::AUD_DynamicIIRFilterReader(AUD_Reference<AUD_IReader> reader,
- AUD_Reference<AUD_DynamicIIRFilterFactory> factory) :
+AUD_DynamicIIRFilterReader::AUD_DynamicIIRFilterReader(boost::shared_ptr<AUD_IReader> reader,
+ boost::shared_ptr<AUD_IDynamicIIRFilterCalculator> calculator) :
AUD_IIRFilterReader(reader, std::vector<float>(), std::vector<float>()),
- m_factory(factory)
+ m_calculator(calculator)
{
sampleRateChanged(reader->getSpecs().rate);
}
@@ -39,6 +39,6 @@ AUD_DynamicIIRFilterReader::AUD_DynamicIIRFilterReader(AUD_Reference<AUD_IReader
void AUD_DynamicIIRFilterReader::sampleRateChanged(AUD_SampleRate rate)
{
std::vector<float> a, b;
- m_factory->recalculateCoefficients(rate, b, a);
+ m_calculator->recalculateCoefficients(rate, b, a);
setCoefficients(b, a);
}
diff --git a/intern/audaspace/FX/AUD_DynamicIIRFilterReader.h b/intern/audaspace/FX/AUD_DynamicIIRFilterReader.h
index 8a53c15b18f..0b68578bc53 100644
--- a/intern/audaspace/FX/AUD_DynamicIIRFilterReader.h
+++ b/intern/audaspace/FX/AUD_DynamicIIRFilterReader.h
@@ -30,7 +30,7 @@
#define __AUD_DYNAMICIIRFILTERREADER_H__
#include "AUD_IIRFilterReader.h"
-#include "AUD_DynamicIIRFilterFactory.h"
+#include "AUD_IDynamicIIRFilterCalculator.h"
/**
* This class is for dynamic infinite impulse response filters with simple
@@ -42,11 +42,11 @@ private:
/**
* The factory for dynamically recalculating filter coefficients.
*/
- AUD_Reference<AUD_DynamicIIRFilterFactory> m_factory;
+ boost::shared_ptr<AUD_IDynamicIIRFilterCalculator> m_calculator;
public:
- AUD_DynamicIIRFilterReader(AUD_Reference<AUD_IReader> reader,
- AUD_Reference<AUD_DynamicIIRFilterFactory> factory);
+ AUD_DynamicIIRFilterReader(boost::shared_ptr<AUD_IReader> reader,
+ boost::shared_ptr<AUD_IDynamicIIRFilterCalculator> calculator);
virtual void sampleRateChanged(AUD_SampleRate rate);
};
diff --git a/intern/audaspace/FX/AUD_EffectFactory.cpp b/intern/audaspace/FX/AUD_EffectFactory.cpp
index d35f8affec8..6018ed561ca 100644
--- a/intern/audaspace/FX/AUD_EffectFactory.cpp
+++ b/intern/audaspace/FX/AUD_EffectFactory.cpp
@@ -30,7 +30,7 @@
#include "AUD_EffectFactory.h"
#include "AUD_IReader.h"
-AUD_EffectFactory::AUD_EffectFactory(AUD_Reference<AUD_IFactory> factory)
+AUD_EffectFactory::AUD_EffectFactory(boost::shared_ptr<AUD_IFactory> factory)
{
m_factory = factory;
}
@@ -39,7 +39,7 @@ AUD_EffectFactory::~AUD_EffectFactory()
{
}
-AUD_Reference<AUD_IFactory> AUD_EffectFactory::getFactory() const
+boost::shared_ptr<AUD_IFactory> AUD_EffectFactory::getFactory() const
{
return m_factory;
}
diff --git a/intern/audaspace/FX/AUD_EffectFactory.h b/intern/audaspace/FX/AUD_EffectFactory.h
index c8d26a1daa7..d09872638be 100644
--- a/intern/audaspace/FX/AUD_EffectFactory.h
+++ b/intern/audaspace/FX/AUD_EffectFactory.h
@@ -47,7 +47,7 @@ protected:
/**
* If there is no reader it is created out of this factory.
*/
- AUD_Reference<AUD_IFactory> m_factory;
+ boost::shared_ptr<AUD_IFactory> m_factory;
/**
* Returns the reader created out of the factory.
@@ -55,7 +55,7 @@ protected:
* classes.
* \return The reader created out of the factory.
*/
- inline AUD_Reference<AUD_IReader> getReader() const
+ inline boost::shared_ptr<AUD_IReader> getReader() const
{
return m_factory->createReader();
}
@@ -65,7 +65,7 @@ public:
* Creates a new factory.
* \param factory The input factory.
*/
- AUD_EffectFactory(AUD_Reference<AUD_IFactory> factory);
+ AUD_EffectFactory(boost::shared_ptr<AUD_IFactory> factory);
/**
* Destroys the factory.
@@ -76,7 +76,7 @@ public:
* Returns the saved factory.
* \return The factory or NULL if there has no factory been saved.
*/
- AUD_Reference<AUD_IFactory> getFactory() const;
+ boost::shared_ptr<AUD_IFactory> getFactory() const;
};
#endif //__AUD_EFFECTFACTORY_H__
diff --git a/intern/audaspace/FX/AUD_EffectReader.cpp b/intern/audaspace/FX/AUD_EffectReader.cpp
index 6c08549e744..b3e80bef03b 100644
--- a/intern/audaspace/FX/AUD_EffectReader.cpp
+++ b/intern/audaspace/FX/AUD_EffectReader.cpp
@@ -29,7 +29,7 @@
#include "AUD_EffectReader.h"
-AUD_EffectReader::AUD_EffectReader(AUD_Reference<AUD_IReader> reader)
+AUD_EffectReader::AUD_EffectReader(boost::shared_ptr<AUD_IReader> reader)
{
m_reader = reader;
}
diff --git a/intern/audaspace/FX/AUD_EffectReader.h b/intern/audaspace/FX/AUD_EffectReader.h
index b089ec9a318..2745c12afaf 100644
--- a/intern/audaspace/FX/AUD_EffectReader.h
+++ b/intern/audaspace/FX/AUD_EffectReader.h
@@ -31,7 +31,8 @@
#define __AUD_EFFECTREADER_H__
#include "AUD_IReader.h"
-#include "AUD_Reference.h"
+
+#include <boost/shared_ptr.hpp>
/**
* This reader is a base class for all effect readers that take one other reader
@@ -48,14 +49,14 @@ protected:
/**
* The reader to read from.
*/
- AUD_Reference<AUD_IReader> m_reader;
+ boost::shared_ptr<AUD_IReader> m_reader;
public:
/**
* Creates a new effect reader.
* \param reader The reader to read from.
*/
- AUD_EffectReader(AUD_Reference<AUD_IReader> reader);
+ AUD_EffectReader(boost::shared_ptr<AUD_IReader> reader);
/**
* Destroys the reader.
diff --git a/intern/audaspace/FX/AUD_EnvelopeFactory.cpp b/intern/audaspace/FX/AUD_EnvelopeFactory.cpp
index c7176662659..1e5737557c1 100644
--- a/intern/audaspace/FX/AUD_EnvelopeFactory.cpp
+++ b/intern/audaspace/FX/AUD_EnvelopeFactory.cpp
@@ -54,7 +54,7 @@ void AUD_EnvelopeFactory::endEnvelopeFilter(EnvelopeParameters* param)
delete param;
}
-AUD_EnvelopeFactory::AUD_EnvelopeFactory(AUD_Reference<AUD_IFactory> factory, float attack,
+AUD_EnvelopeFactory::AUD_EnvelopeFactory(boost::shared_ptr<AUD_IFactory> factory, float attack,
float release, float threshold,
float arthreshold) :
AUD_EffectFactory(factory),
@@ -65,9 +65,9 @@ AUD_EnvelopeFactory::AUD_EnvelopeFactory(AUD_Reference<AUD_IFactory> factory, fl
{
}
-AUD_Reference<AUD_IReader> AUD_EnvelopeFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_EnvelopeFactory::createReader()
{
- AUD_Reference<AUD_IReader> reader = getReader();
+ boost::shared_ptr<AUD_IReader> reader = getReader();
EnvelopeParameters* param = new EnvelopeParameters();
param->arthreshold = m_arthreshold;
@@ -75,8 +75,8 @@ AUD_Reference<AUD_IReader> AUD_EnvelopeFactory::createReader()
param->release = pow(m_arthreshold, 1.0f/(static_cast<float>(reader->getSpecs().rate) * m_release));
param->threshold = m_threshold;
- return new AUD_CallbackIIRFilterReader(reader, 1, 2,
+ return boost::shared_ptr<AUD_IReader>(new AUD_CallbackIIRFilterReader(reader, 1, 2,
(doFilterIIR) envelopeFilter,
(endFilterIIR) endEnvelopeFilter,
- param);
+ param));
}
diff --git a/intern/audaspace/FX/AUD_EnvelopeFactory.h b/intern/audaspace/FX/AUD_EnvelopeFactory.h
index c8f3dc37cd2..656212c8cac 100644
--- a/intern/audaspace/FX/AUD_EnvelopeFactory.h
+++ b/intern/audaspace/FX/AUD_EnvelopeFactory.h
@@ -73,10 +73,10 @@ public:
* \param threshold The threshold value.
* \param arthreshold The attack/release threshold value.
*/
- AUD_EnvelopeFactory(AUD_Reference<AUD_IFactory> factory, float attack, float release,
+ AUD_EnvelopeFactory(boost::shared_ptr<AUD_IFactory> factory, float attack, float release,
float threshold, float arthreshold);
- virtual AUD_Reference<AUD_IReader> createReader();
+ virtual boost::shared_ptr<AUD_IReader> createReader();
static sample_t envelopeFilter(AUD_CallbackIIRFilterReader* reader, EnvelopeParameters* param);
static void endEnvelopeFilter(EnvelopeParameters* param);
diff --git a/intern/audaspace/FX/AUD_FaderFactory.cpp b/intern/audaspace/FX/AUD_FaderFactory.cpp
index ec119ef9388..b34d2134385 100644
--- a/intern/audaspace/FX/AUD_FaderFactory.cpp
+++ b/intern/audaspace/FX/AUD_FaderFactory.cpp
@@ -30,7 +30,7 @@
#include "AUD_FaderFactory.h"
#include "AUD_FaderReader.h"
-AUD_FaderFactory::AUD_FaderFactory(AUD_Reference<AUD_IFactory> factory, AUD_FadeType type,
+AUD_FaderFactory::AUD_FaderFactory(boost::shared_ptr<AUD_IFactory> factory, AUD_FadeType type,
float start, float length) :
AUD_EffectFactory(factory),
m_type(type),
@@ -54,7 +54,7 @@ float AUD_FaderFactory::getLength() const
return m_length;
}
-AUD_Reference<AUD_IReader> AUD_FaderFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_FaderFactory::createReader()
{
- return new AUD_FaderReader(getReader(), m_type, m_start, m_length);
+ return boost::shared_ptr<AUD_IReader>(new AUD_FaderReader(getReader(), m_type, m_start, m_length));
}
diff --git a/intern/audaspace/FX/AUD_FaderFactory.h b/intern/audaspace/FX/AUD_FaderFactory.h
index 82eaf2fae9f..f9ad88a751d 100644
--- a/intern/audaspace/FX/AUD_FaderFactory.h
+++ b/intern/audaspace/FX/AUD_FaderFactory.h
@@ -67,7 +67,7 @@ public:
* \param start The time where fading should start in seconds.
* \param length How long fading should last in seconds.
*/
- AUD_FaderFactory(AUD_Reference<AUD_IFactory> factory,
+ AUD_FaderFactory(boost::shared_ptr<AUD_IFactory> factory,
AUD_FadeType type = AUD_FADE_IN,
float start = 0.0f, float length = 1.0f);
@@ -86,7 +86,7 @@ public:
*/
float getLength() const;
- virtual AUD_Reference<AUD_IReader> createReader();
+ virtual boost::shared_ptr<AUD_IReader> createReader();
};
#endif //__AUD_FADERFACTORY_H__
diff --git a/intern/audaspace/FX/AUD_FaderReader.cpp b/intern/audaspace/FX/AUD_FaderReader.cpp
index 4ece91ca899..e09072054cb 100644
--- a/intern/audaspace/FX/AUD_FaderReader.cpp
+++ b/intern/audaspace/FX/AUD_FaderReader.cpp
@@ -31,7 +31,7 @@
#include <cstring>
-AUD_FaderReader::AUD_FaderReader(AUD_Reference<AUD_IReader> reader, AUD_FadeType type,
+AUD_FaderReader::AUD_FaderReader(boost::shared_ptr<AUD_IReader> reader, AUD_FadeType type,
float start,float length) :
AUD_EffectReader(reader),
m_type(type),
diff --git a/intern/audaspace/FX/AUD_FaderReader.h b/intern/audaspace/FX/AUD_FaderReader.h
index 788e8539228..a49960b30fb 100644
--- a/intern/audaspace/FX/AUD_FaderReader.h
+++ b/intern/audaspace/FX/AUD_FaderReader.h
@@ -67,7 +67,7 @@ public:
* \param start The time where fading should start in seconds.
* \param length How long fading should last in seconds.
*/
- AUD_FaderReader(AUD_Reference<AUD_IReader> reader, AUD_FadeType type,
+ AUD_FaderReader(boost::shared_ptr<AUD_IReader> reader, AUD_FadeType type,
float start,float length);
virtual void read(int& length, bool& eos, sample_t* buffer);
diff --git a/intern/audaspace/FX/AUD_HighpassFactory.cpp b/intern/audaspace/FX/AUD_HighpassFactory.cpp
index b56be8942ff..ba5297d21ed 100644
--- a/intern/audaspace/FX/AUD_HighpassFactory.cpp
+++ b/intern/audaspace/FX/AUD_HighpassFactory.cpp
@@ -36,7 +36,7 @@
#define M_PI 3.14159265358979323846
#endif
-AUD_HighpassFactory::AUD_HighpassFactory(AUD_Reference<AUD_IFactory> factory, float frequency,
+AUD_HighpassFactory::AUD_HighpassFactory(boost::shared_ptr<AUD_IFactory> factory, float frequency,
float Q) :
AUD_DynamicIIRFilterFactory(factory),
m_frequency(frequency),
diff --git a/intern/audaspace/FX/AUD_HighpassFactory.h b/intern/audaspace/FX/AUD_HighpassFactory.h
index 66aa8091234..ed7e9db44a4 100644
--- a/intern/audaspace/FX/AUD_HighpassFactory.h
+++ b/intern/audaspace/FX/AUD_HighpassFactory.h
@@ -59,7 +59,7 @@ public:
* \param frequency The cutoff frequency.
* \param Q The Q factor.
*/
- AUD_HighpassFactory(AUD_Reference<AUD_IFactory> factory, float frequency, float Q = 1.0f);
+ AUD_HighpassFactory(boost::shared_ptr<AUD_IFactory> factory, float frequency, float Q = 1.0f);
virtual void recalculateCoefficients(AUD_SampleRate rate, std::vector<float> &b, std::vector<float> &a);
};
diff --git a/intern/audaspace/intern/AUD_ReferenceHandler.cpp b/intern/audaspace/FX/AUD_IDynamicIIRFilterCalculator.h
index 6aa4f87ea96..77d83360255 100644
--- a/intern/audaspace/intern/AUD_ReferenceHandler.cpp
+++ b/intern/audaspace/FX/AUD_IDynamicIIRFilterCalculator.h
@@ -22,31 +22,31 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file audaspace/intern/AUD_ReferenceHandler.cpp
- * \ingroup audaspaceintern
+/** \file audaspace/FX/AUD_IDynamicIIRFilterCalculator.h
+ * \ingroup audfx
*/
-#include "AUD_Reference.h"
+#ifndef AUD_IDYNAMICIIRFILTERCALCULATOR_H
+#define AUD_IDYNAMICIIRFILTERCALCULATOR_H
-std::map<void*, unsigned int> AUD_ReferenceHandler::m_references;
-pthread_mutex_t AUD_ReferenceHandler::m_mutex;
-bool AUD_ReferenceHandler::m_mutex_initialised = false;
+#include <vector>
-pthread_mutex_t *AUD_ReferenceHandler::getMutex()
+/**
+ * This interface calculates dynamic filter coefficients which depend on the
+ * sampling rate for AUD_DynamicIIRFilterReaders.
+ */
+class AUD_IDynamicIIRFilterCalculator
{
- if(!m_mutex_initialised)
- {
- pthread_mutexattr_t attr;
- pthread_mutexattr_init(&attr);
- pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
-
- pthread_mutex_init(&m_mutex, &attr);
-
- pthread_mutexattr_destroy(&attr);
-
- m_mutex_initialised = true;
- }
-
- return &m_mutex;
-}
-
+public:
+ /**
+ * Recalculates the filter coefficients.
+ * \param rate The sample rate of the audio data.
+ * \param[out] b The input filter coefficients.
+ * \param[out] a The output filter coefficients.
+ */
+ virtual void recalculateCoefficients(AUD_SampleRate rate,
+ std::vector<float>& b,
+ std::vector<float>& a)=0;
+};
+
+#endif // AUD_IDYNAMICIIRFILTERCALCULATOR_H
diff --git a/intern/audaspace/FX/AUD_IIRFilterFactory.cpp b/intern/audaspace/FX/AUD_IIRFilterFactory.cpp
index 807b0ef4899..c4f94a2dc27 100644
--- a/intern/audaspace/FX/AUD_IIRFilterFactory.cpp
+++ b/intern/audaspace/FX/AUD_IIRFilterFactory.cpp
@@ -30,14 +30,14 @@
#include "AUD_IIRFilterFactory.h"
#include "AUD_IIRFilterReader.h"
-AUD_IIRFilterFactory::AUD_IIRFilterFactory(AUD_Reference<AUD_IFactory> factory,
+AUD_IIRFilterFactory::AUD_IIRFilterFactory(boost::shared_ptr<AUD_IFactory> factory,
std::vector<float> b,
std::vector<float> a) :
AUD_EffectFactory(factory), m_a(a), m_b(b)
{
}
-AUD_Reference<AUD_IReader> AUD_IIRFilterFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_IIRFilterFactory::createReader()
{
- return new AUD_IIRFilterReader(getReader(), m_b, m_a);
+ return boost::shared_ptr<AUD_IReader>(new AUD_IIRFilterReader(getReader(), m_b, m_a));
}
diff --git a/intern/audaspace/FX/AUD_IIRFilterFactory.h b/intern/audaspace/FX/AUD_IIRFilterFactory.h
index 43256a166aa..0b55c120384 100644
--- a/intern/audaspace/FX/AUD_IIRFilterFactory.h
+++ b/intern/audaspace/FX/AUD_IIRFilterFactory.h
@@ -31,6 +31,7 @@
#define __AUD_IIRFILTERFACTORY_H__
#include "AUD_EffectFactory.h"
+#include "AUD_IDynamicIIRFilterCalculator.h"
#include <vector>
@@ -61,10 +62,10 @@ public:
* \param b The input filter coefficients.
* \param a The output filter coefficients.
*/
- AUD_IIRFilterFactory(AUD_Reference<AUD_IFactory> factory, std::vector<float> b,
+ AUD_IIRFilterFactory(boost::shared_ptr<AUD_IFactory> factory, std::vector<float> b,
std::vector<float> a);
- virtual AUD_Reference<AUD_IReader> createReader();
+ virtual boost::shared_ptr<AUD_IReader> createReader();
};
#endif //__AUD_IIRFILTERFACTORY_H__
diff --git a/intern/audaspace/FX/AUD_IIRFilterReader.cpp b/intern/audaspace/FX/AUD_IIRFilterReader.cpp
index 8f78c110d1f..6716e6b9ddc 100644
--- a/intern/audaspace/FX/AUD_IIRFilterReader.cpp
+++ b/intern/audaspace/FX/AUD_IIRFilterReader.cpp
@@ -29,7 +29,7 @@
#include "AUD_IIRFilterReader.h"
-AUD_IIRFilterReader::AUD_IIRFilterReader(AUD_Reference<AUD_IReader> reader,
+AUD_IIRFilterReader::AUD_IIRFilterReader(boost::shared_ptr<AUD_IReader> reader,
const std::vector<float>& b,
const std::vector<float>& a) :
AUD_BaseIIRFilterReader(reader, b.size(), a.size()), m_a(a), m_b(b)
diff --git a/intern/audaspace/FX/AUD_IIRFilterReader.h b/intern/audaspace/FX/AUD_IIRFilterReader.h
index d9be52f2919..d663805b50f 100644
--- a/intern/audaspace/FX/AUD_IIRFilterReader.h
+++ b/intern/audaspace/FX/AUD_IIRFilterReader.h
@@ -61,7 +61,7 @@ public:
* \param b The input filter coefficients.
* \param a The output filter coefficients.
*/
- AUD_IIRFilterReader(AUD_Reference<AUD_IReader> reader, const std::vector<float>& b,
+ AUD_IIRFilterReader(boost::shared_ptr<AUD_IReader> reader, const std::vector<float>& b,
const std::vector<float>& a);
virtual sample_t filter();
diff --git a/intern/audaspace/FX/AUD_LimiterFactory.cpp b/intern/audaspace/FX/AUD_LimiterFactory.cpp
index e58657d8d70..679ed3a6b8b 100644
--- a/intern/audaspace/FX/AUD_LimiterFactory.cpp
+++ b/intern/audaspace/FX/AUD_LimiterFactory.cpp
@@ -31,7 +31,7 @@
#include "AUD_LimiterReader.h"
#include "AUD_Space.h"
-AUD_LimiterFactory::AUD_LimiterFactory(AUD_Reference<AUD_IFactory> factory,
+AUD_LimiterFactory::AUD_LimiterFactory(boost::shared_ptr<AUD_IFactory> factory,
float start, float end) :
AUD_EffectFactory(factory),
m_start(start),
@@ -49,7 +49,7 @@ float AUD_LimiterFactory::getEnd() const
return m_end;
}
-AUD_Reference<AUD_IReader> AUD_LimiterFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_LimiterFactory::createReader()
{
- return new AUD_LimiterReader(getReader(), m_start, m_end);
+ return boost::shared_ptr<AUD_IReader>(new AUD_LimiterReader(getReader(), m_start, m_end));
}
diff --git a/intern/audaspace/FX/AUD_LimiterFactory.h b/intern/audaspace/FX/AUD_LimiterFactory.h
index ddc8183ce7a..0376952b4bd 100644
--- a/intern/audaspace/FX/AUD_LimiterFactory.h
+++ b/intern/audaspace/FX/AUD_LimiterFactory.h
@@ -60,7 +60,7 @@ public:
* \param end The desired end time, a negative value signals that it should
* play to the end.
*/
- AUD_LimiterFactory(AUD_Reference<AUD_IFactory> factory,
+ AUD_LimiterFactory(boost::shared_ptr<AUD_IFactory> factory,
float start = 0, float end = -1);
/**
@@ -73,7 +73,7 @@ public:
*/
float getEnd() const;
- virtual AUD_Reference<AUD_IReader> createReader();
+ virtual boost::shared_ptr<AUD_IReader> createReader();
};
#endif //__AUD_LIMITERFACTORY_H__
diff --git a/intern/audaspace/FX/AUD_LimiterReader.cpp b/intern/audaspace/FX/AUD_LimiterReader.cpp
index 0abf496c7f9..9c1d4443b06 100644
--- a/intern/audaspace/FX/AUD_LimiterReader.cpp
+++ b/intern/audaspace/FX/AUD_LimiterReader.cpp
@@ -30,7 +30,7 @@
#include "AUD_LimiterReader.h"
#include "AUD_Buffer.h"
-AUD_LimiterReader::AUD_LimiterReader(AUD_Reference<AUD_IReader> reader,
+AUD_LimiterReader::AUD_LimiterReader(boost::shared_ptr<AUD_IReader> reader,
float start, float end) :
AUD_EffectReader(reader),
m_start(start),
diff --git a/intern/audaspace/FX/AUD_LimiterReader.h b/intern/audaspace/FX/AUD_LimiterReader.h
index 34c4ea7c20e..607eb9e5bec 100644
--- a/intern/audaspace/FX/AUD_LimiterReader.h
+++ b/intern/audaspace/FX/AUD_LimiterReader.h
@@ -60,7 +60,7 @@ public:
* \param end The desired end time (sample exklusive), a negative value
* signals that it should play to the end.
*/
- AUD_LimiterReader(AUD_Reference<AUD_IReader> reader, float start = 0, float end = -1);
+ AUD_LimiterReader(boost::shared_ptr<AUD_IReader> reader, float start = 0, float end = -1);
virtual void seek(int position);
virtual int getLength() const;
diff --git a/intern/audaspace/FX/AUD_LoopFactory.cpp b/intern/audaspace/FX/AUD_LoopFactory.cpp
index 32c9e6bad7f..a9e83e349a0 100644
--- a/intern/audaspace/FX/AUD_LoopFactory.cpp
+++ b/intern/audaspace/FX/AUD_LoopFactory.cpp
@@ -30,7 +30,7 @@
#include "AUD_LoopFactory.h"
#include "AUD_LoopReader.h"
-AUD_LoopFactory::AUD_LoopFactory(AUD_Reference<AUD_IFactory> factory, int loop) :
+AUD_LoopFactory::AUD_LoopFactory(boost::shared_ptr<AUD_IFactory> factory, int loop) :
AUD_EffectFactory(factory),
m_loop(loop)
{
@@ -41,7 +41,7 @@ int AUD_LoopFactory::getLoop() const
return m_loop;
}
-AUD_Reference<AUD_IReader> AUD_LoopFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_LoopFactory::createReader()
{
- return new AUD_LoopReader(getReader(), m_loop);
+ return boost::shared_ptr<AUD_IReader>(new AUD_LoopReader(getReader(), m_loop));
}
diff --git a/intern/audaspace/FX/AUD_LoopFactory.h b/intern/audaspace/FX/AUD_LoopFactory.h
index 754b780bd99..570536bee9a 100644
--- a/intern/audaspace/FX/AUD_LoopFactory.h
+++ b/intern/audaspace/FX/AUD_LoopFactory.h
@@ -55,14 +55,14 @@ public:
* \param loop The desired loop count, negative values result in endless
* looping.
*/
- AUD_LoopFactory(AUD_Reference<AUD_IFactory> factory, int loop = -1);
+ AUD_LoopFactory(boost::shared_ptr<AUD_IFactory> factory, int loop = -1);
/**
* Returns the loop count.
*/
int getLoop() const;
- virtual AUD_Reference<AUD_IReader> createReader();
+ virtual boost::shared_ptr<AUD_IReader> createReader();
};
#endif //__AUD_LOOPFACTORY_H__
diff --git a/intern/audaspace/FX/AUD_LoopReader.cpp b/intern/audaspace/FX/AUD_LoopReader.cpp
index 863f66f9f46..6fbcaa5af37 100644
--- a/intern/audaspace/FX/AUD_LoopReader.cpp
+++ b/intern/audaspace/FX/AUD_LoopReader.cpp
@@ -32,7 +32,7 @@
#include <cstring>
-AUD_LoopReader::AUD_LoopReader(AUD_Reference<AUD_IReader> reader, int loop) :
+AUD_LoopReader::AUD_LoopReader(boost::shared_ptr<AUD_IReader> reader, int loop) :
AUD_EffectReader(reader), m_count(loop), m_left(loop)
{
}
diff --git a/intern/audaspace/FX/AUD_LoopReader.h b/intern/audaspace/FX/AUD_LoopReader.h
index fd2dd71d78f..12b8078b12d 100644
--- a/intern/audaspace/FX/AUD_LoopReader.h
+++ b/intern/audaspace/FX/AUD_LoopReader.h
@@ -61,7 +61,7 @@ public:
* \param loop The desired loop count, negative values result in endless
* looping.
*/
- AUD_LoopReader(AUD_Reference<AUD_IReader> reader, int loop);
+ AUD_LoopReader(boost::shared_ptr<AUD_IReader> reader, int loop);
virtual void seek(int position);
virtual int getLength() const;
diff --git a/intern/audaspace/FX/AUD_LowpassFactory.cpp b/intern/audaspace/FX/AUD_LowpassFactory.cpp
index 14dbc951c7f..e2faa241ac9 100644
--- a/intern/audaspace/FX/AUD_LowpassFactory.cpp
+++ b/intern/audaspace/FX/AUD_LowpassFactory.cpp
@@ -36,7 +36,7 @@
#define M_PI 3.14159265358979323846
#endif
-AUD_LowpassFactory::AUD_LowpassFactory(AUD_Reference<AUD_IFactory> factory, float frequency,
+AUD_LowpassFactory::AUD_LowpassFactory(boost::shared_ptr<AUD_IFactory> factory, float frequency,
float Q) :
AUD_DynamicIIRFilterFactory(factory),
m_frequency(frequency),
diff --git a/intern/audaspace/FX/AUD_LowpassFactory.h b/intern/audaspace/FX/AUD_LowpassFactory.h
index 7e98720a2db..fdbc6e5d91d 100644
--- a/intern/audaspace/FX/AUD_LowpassFactory.h
+++ b/intern/audaspace/FX/AUD_LowpassFactory.h
@@ -59,7 +59,7 @@ public:
* \param frequency The cutoff frequency.
* \param Q The Q factor.
*/
- AUD_LowpassFactory(AUD_Reference<AUD_IFactory> factory, float frequency, float Q = 1.0f);
+ AUD_LowpassFactory(boost::shared_ptr<AUD_IFactory> factory, float frequency, float Q = 1.0f);
virtual void recalculateCoefficients(AUD_SampleRate rate, std::vector<float> &b, std::vector<float> &a);
};
diff --git a/intern/audaspace/FX/AUD_PingPongFactory.cpp b/intern/audaspace/FX/AUD_PingPongFactory.cpp
index 3d5011cf47b..84e4b29415e 100644
--- a/intern/audaspace/FX/AUD_PingPongFactory.cpp
+++ b/intern/audaspace/FX/AUD_PingPongFactory.cpp
@@ -31,16 +31,16 @@
#include "AUD_DoubleReader.h"
#include "AUD_ReverseFactory.h"
-AUD_PingPongFactory::AUD_PingPongFactory(AUD_Reference<AUD_IFactory> factory) :
+AUD_PingPongFactory::AUD_PingPongFactory(boost::shared_ptr<AUD_IFactory> factory) :
AUD_EffectFactory(factory)
{
}
-AUD_Reference<AUD_IReader> AUD_PingPongFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_PingPongFactory::createReader()
{
- AUD_Reference<AUD_IReader> reader = getReader();
+ boost::shared_ptr<AUD_IReader> reader = getReader();
AUD_ReverseFactory factory(m_factory);
- AUD_Reference<AUD_IReader> reader2 = factory.createReader();
+ boost::shared_ptr<AUD_IReader> reader2 = factory.createReader();
- return new AUD_DoubleReader(reader, reader2);
+ return boost::shared_ptr<AUD_IReader>(new AUD_DoubleReader(reader, reader2));
}
diff --git a/intern/audaspace/FX/AUD_PingPongFactory.h b/intern/audaspace/FX/AUD_PingPongFactory.h
index f25624a7c5e..e8ee5c9e389 100644
--- a/intern/audaspace/FX/AUD_PingPongFactory.h
+++ b/intern/audaspace/FX/AUD_PingPongFactory.h
@@ -48,9 +48,9 @@ public:
* Creates a new ping pong factory.
* \param factory The input factory.
*/
- AUD_PingPongFactory(AUD_Reference<AUD_IFactory> factory);
+ AUD_PingPongFactory(boost::shared_ptr<AUD_IFactory> factory);
- virtual AUD_Reference<AUD_IReader> createReader();
+ virtual boost::shared_ptr<AUD_IReader> createReader();
};
#endif //__AUD_PINGPONGFACTORY_H__
diff --git a/intern/audaspace/FX/AUD_PitchFactory.cpp b/intern/audaspace/FX/AUD_PitchFactory.cpp
index c6e9ae0b457..9dc27a58162 100644
--- a/intern/audaspace/FX/AUD_PitchFactory.cpp
+++ b/intern/audaspace/FX/AUD_PitchFactory.cpp
@@ -31,13 +31,13 @@
#include "AUD_PitchReader.h"
#include "AUD_Space.h"
-AUD_PitchFactory::AUD_PitchFactory(AUD_Reference<AUD_IFactory> factory, float pitch) :
+AUD_PitchFactory::AUD_PitchFactory(boost::shared_ptr<AUD_IFactory> factory, float pitch) :
AUD_EffectFactory(factory),
m_pitch(pitch)
{
}
-AUD_Reference<AUD_IReader> AUD_PitchFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_PitchFactory::createReader()
{
- return new AUD_PitchReader(getReader(), m_pitch);
+ return boost::shared_ptr<AUD_IReader>(new AUD_PitchReader(getReader(), m_pitch));
}
diff --git a/intern/audaspace/FX/AUD_PitchFactory.h b/intern/audaspace/FX/AUD_PitchFactory.h
index 5ad37ad1a6c..159388b28dd 100644
--- a/intern/audaspace/FX/AUD_PitchFactory.h
+++ b/intern/audaspace/FX/AUD_PitchFactory.h
@@ -53,9 +53,9 @@ public:
* \param factory The input factory.
* \param pitch The desired pitch.
*/
- AUD_PitchFactory(AUD_Reference<AUD_IFactory> factory, float pitch);
+ AUD_PitchFactory(boost::shared_ptr<AUD_IFactory> factory, float pitch);
- virtual AUD_Reference<AUD_IReader> createReader();
+ virtual boost::shared_ptr<AUD_IReader> createReader();
};
#endif //__AUD_PITCHFACTORY_H__
diff --git a/intern/audaspace/FX/AUD_PitchReader.cpp b/intern/audaspace/FX/AUD_PitchReader.cpp
index 0d1ff012e73..218af4fc090 100644
--- a/intern/audaspace/FX/AUD_PitchReader.cpp
+++ b/intern/audaspace/FX/AUD_PitchReader.cpp
@@ -29,7 +29,7 @@
#include "AUD_PitchReader.h"
-AUD_PitchReader::AUD_PitchReader(AUD_Reference<AUD_IReader> reader, float pitch) :
+AUD_PitchReader::AUD_PitchReader(boost::shared_ptr<AUD_IReader> reader, float pitch) :
AUD_EffectReader(reader), m_pitch(pitch)
{
}
diff --git a/intern/audaspace/FX/AUD_PitchReader.h b/intern/audaspace/FX/AUD_PitchReader.h
index 3185bfdf30b..d22e589b05d 100644
--- a/intern/audaspace/FX/AUD_PitchReader.h
+++ b/intern/audaspace/FX/AUD_PitchReader.h
@@ -53,7 +53,7 @@ public:
* \param reader The reader to read from.
* \param pitch The pitch value.
*/
- AUD_PitchReader(AUD_Reference<AUD_IReader> reader, float pitch);
+ AUD_PitchReader(boost::shared_ptr<AUD_IReader> reader, float pitch);
virtual AUD_Specs getSpecs() const;
diff --git a/intern/audaspace/FX/AUD_RectifyFactory.cpp b/intern/audaspace/FX/AUD_RectifyFactory.cpp
index ad01f404698..26bb5615dad 100644
--- a/intern/audaspace/FX/AUD_RectifyFactory.cpp
+++ b/intern/audaspace/FX/AUD_RectifyFactory.cpp
@@ -37,12 +37,12 @@ sample_t AUD_RectifyFactory::rectifyFilter(AUD_CallbackIIRFilterReader* reader,
return fabs(reader->x(0));
}
-AUD_RectifyFactory::AUD_RectifyFactory(AUD_Reference<AUD_IFactory> factory) :
+AUD_RectifyFactory::AUD_RectifyFactory(boost::shared_ptr<AUD_IFactory> factory) :
AUD_EffectFactory(factory)
{
}
-AUD_Reference<AUD_IReader> AUD_RectifyFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_RectifyFactory::createReader()
{
- return new AUD_CallbackIIRFilterReader(getReader(), 1, 1, rectifyFilter);
+ return boost::shared_ptr<AUD_IReader>(new AUD_CallbackIIRFilterReader(getReader(), 1, 1, rectifyFilter));
}
diff --git a/intern/audaspace/FX/AUD_RectifyFactory.h b/intern/audaspace/FX/AUD_RectifyFactory.h
index 5ad41d424d9..eb595e43e4f 100644
--- a/intern/audaspace/FX/AUD_RectifyFactory.h
+++ b/intern/audaspace/FX/AUD_RectifyFactory.h
@@ -48,9 +48,9 @@ public:
* Creates a new rectify factory.
* \param factory The input factory.
*/
- AUD_RectifyFactory(AUD_Reference<AUD_IFactory> factory);
+ AUD_RectifyFactory(boost::shared_ptr<AUD_IFactory> factory);
- virtual AUD_Reference<AUD_IReader> createReader();
+ virtual boost::shared_ptr<AUD_IReader> createReader();
static sample_t rectifyFilter(AUD_CallbackIIRFilterReader* reader, void* useless);
};
diff --git a/intern/audaspace/FX/AUD_ReverseFactory.cpp b/intern/audaspace/FX/AUD_ReverseFactory.cpp
index 063cbc88180..afb4ad2bec9 100644
--- a/intern/audaspace/FX/AUD_ReverseFactory.cpp
+++ b/intern/audaspace/FX/AUD_ReverseFactory.cpp
@@ -31,12 +31,12 @@
#include "AUD_ReverseReader.h"
#include "AUD_Space.h"
-AUD_ReverseFactory::AUD_ReverseFactory(AUD_Reference<AUD_IFactory> factory) :
+AUD_ReverseFactory::AUD_ReverseFactory(boost::shared_ptr<AUD_IFactory> factory) :
AUD_EffectFactory(factory)
{
}
-AUD_Reference<AUD_IReader> AUD_ReverseFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_ReverseFactory::createReader()
{
- return new AUD_ReverseReader(getReader());
+ return boost::shared_ptr<AUD_IReader>(new AUD_ReverseReader(getReader()));
}
diff --git a/intern/audaspace/FX/AUD_ReverseFactory.h b/intern/audaspace/FX/AUD_ReverseFactory.h
index e2d75dc560a..5b0c9e3c29a 100644
--- a/intern/audaspace/FX/AUD_ReverseFactory.h
+++ b/intern/audaspace/FX/AUD_ReverseFactory.h
@@ -48,9 +48,9 @@ public:
* Creates a new reverse factory.
* \param factory The input factory.
*/
- AUD_ReverseFactory(AUD_Reference<AUD_IFactory> factory);
+ AUD_ReverseFactory(boost::shared_ptr<AUD_IFactory> factory);
- virtual AUD_Reference<AUD_IReader> createReader();
+ virtual boost::shared_ptr<AUD_IReader> createReader();
};
#endif //__AUD_REVERSEFACTORY_H__
diff --git a/intern/audaspace/FX/AUD_ReverseReader.cpp b/intern/audaspace/FX/AUD_ReverseReader.cpp
index 6b454c66d25..c0a5962a299 100644
--- a/intern/audaspace/FX/AUD_ReverseReader.cpp
+++ b/intern/audaspace/FX/AUD_ReverseReader.cpp
@@ -34,7 +34,7 @@
static const char* props_error = "AUD_ReverseReader: The reader has to be "
"seekable and a finite length.";
-AUD_ReverseReader::AUD_ReverseReader(AUD_Reference<AUD_IReader> reader) :
+AUD_ReverseReader::AUD_ReverseReader(boost::shared_ptr<AUD_IReader> reader) :
AUD_EffectReader(reader),
m_length(reader->getLength()),
m_position(0)
diff --git a/intern/audaspace/FX/AUD_ReverseReader.h b/intern/audaspace/FX/AUD_ReverseReader.h
index d1e5179b8ec..219047915bd 100644
--- a/intern/audaspace/FX/AUD_ReverseReader.h
+++ b/intern/audaspace/FX/AUD_ReverseReader.h
@@ -61,7 +61,7 @@ public:
* \exception AUD_Exception Thrown if the reader specified has an
* undeterminable/infinite length or is not seekable.
*/
- AUD_ReverseReader(AUD_Reference<AUD_IReader> reader);
+ AUD_ReverseReader(boost::shared_ptr<AUD_IReader> reader);
virtual void seek(int position);
virtual int getLength() const;
diff --git a/intern/audaspace/FX/AUD_SquareFactory.cpp b/intern/audaspace/FX/AUD_SquareFactory.cpp
index 7aabdb775f6..4b4dccb6e6b 100644
--- a/intern/audaspace/FX/AUD_SquareFactory.cpp
+++ b/intern/audaspace/FX/AUD_SquareFactory.cpp
@@ -46,7 +46,7 @@ void AUD_SquareFactory::endSquareFilter(float* threshold)
delete threshold;
}
-AUD_SquareFactory::AUD_SquareFactory(AUD_Reference<AUD_IFactory> factory, float threshold) :
+AUD_SquareFactory::AUD_SquareFactory(boost::shared_ptr<AUD_IFactory> factory, float threshold) :
AUD_EffectFactory(factory),
m_threshold(threshold)
{
@@ -57,10 +57,10 @@ float AUD_SquareFactory::getThreshold() const
return m_threshold;
}
-AUD_Reference<AUD_IReader> AUD_SquareFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_SquareFactory::createReader()
{
- return new AUD_CallbackIIRFilterReader(getReader(), 1, 1,
+ return boost::shared_ptr<AUD_IReader>(new AUD_CallbackIIRFilterReader(getReader(), 1, 1,
(doFilterIIR) squareFilter,
(endFilterIIR) endSquareFilter,
- new float(m_threshold));
+ new float(m_threshold)));
}
diff --git a/intern/audaspace/FX/AUD_SquareFactory.h b/intern/audaspace/FX/AUD_SquareFactory.h
index 9c0dea25d2b..27e62b6f4cc 100644
--- a/intern/audaspace/FX/AUD_SquareFactory.h
+++ b/intern/audaspace/FX/AUD_SquareFactory.h
@@ -54,14 +54,14 @@ public:
* \param factory The input factory.
* \param threshold The threshold.
*/
- AUD_SquareFactory(AUD_Reference<AUD_IFactory> factory, float threshold = 0.0f);
+ AUD_SquareFactory(boost::shared_ptr<AUD_IFactory> factory, float threshold = 0.0f);
/**
* Returns the threshold.
*/
float getThreshold() const;
- virtual AUD_Reference<AUD_IReader> createReader();
+ virtual boost::shared_ptr<AUD_IReader> createReader();
static sample_t squareFilter(AUD_CallbackIIRFilterReader* reader, float* threshold);
static void endSquareFilter(float* threshold);
diff --git a/intern/audaspace/FX/AUD_SumFactory.cpp b/intern/audaspace/FX/AUD_SumFactory.cpp
index b58c44b0171..7f82233a0b7 100644
--- a/intern/audaspace/FX/AUD_SumFactory.cpp
+++ b/intern/audaspace/FX/AUD_SumFactory.cpp
@@ -30,16 +30,16 @@
#include "AUD_SumFactory.h"
#include "AUD_IIRFilterReader.h"
-AUD_SumFactory::AUD_SumFactory(AUD_Reference<AUD_IFactory> factory) :
+AUD_SumFactory::AUD_SumFactory(boost::shared_ptr<AUD_IFactory> factory) :
AUD_EffectFactory(factory)
{
}
-AUD_Reference<AUD_IReader> AUD_SumFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_SumFactory::createReader()
{
std::vector<float> a, b;
a.push_back(1);
a.push_back(-1);
b.push_back(1);
- return new AUD_IIRFilterReader(getReader(), b, a);
+ return boost::shared_ptr<AUD_IReader>(new AUD_IIRFilterReader(getReader(), b, a));
}
diff --git a/intern/audaspace/FX/AUD_SumFactory.h b/intern/audaspace/FX/AUD_SumFactory.h
index ec17faf3fb2..a916f3509cb 100644
--- a/intern/audaspace/FX/AUD_SumFactory.h
+++ b/intern/audaspace/FX/AUD_SumFactory.h
@@ -47,9 +47,9 @@ public:
* Creates a new sum factory.
* \param factory The input factory.
*/
- AUD_SumFactory(AUD_Reference<AUD_IFactory> factory);
+ AUD_SumFactory(boost::shared_ptr<AUD_IFactory> factory);
- virtual AUD_Reference<AUD_IReader> createReader();
+ virtual boost::shared_ptr<AUD_IReader> createReader();
};
#endif //__AUD_SUMFACTORY_H__
diff --git a/intern/audaspace/FX/AUD_SuperposeFactory.cpp b/intern/audaspace/FX/AUD_SuperposeFactory.cpp
index 30c57198c73..3efad37a5b3 100644
--- a/intern/audaspace/FX/AUD_SuperposeFactory.cpp
+++ b/intern/audaspace/FX/AUD_SuperposeFactory.cpp
@@ -30,15 +30,15 @@
#include "AUD_SuperposeFactory.h"
#include "AUD_SuperposeReader.h"
-AUD_SuperposeFactory::AUD_SuperposeFactory(AUD_Reference<AUD_IFactory> factory1, AUD_Reference<AUD_IFactory> factory2) :
+AUD_SuperposeFactory::AUD_SuperposeFactory(boost::shared_ptr<AUD_IFactory> factory1, boost::shared_ptr<AUD_IFactory> factory2) :
m_factory1(factory1), m_factory2(factory2)
{
}
-AUD_Reference<AUD_IReader> AUD_SuperposeFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_SuperposeFactory::createReader()
{
- AUD_Reference<AUD_IReader> reader1 = m_factory1->createReader();
- AUD_Reference<AUD_IReader> reader2 = m_factory2->createReader();
+ boost::shared_ptr<AUD_IReader> reader1 = m_factory1->createReader();
+ boost::shared_ptr<AUD_IReader> reader2 = m_factory2->createReader();
- return new AUD_SuperposeReader(reader1, reader2);
+ return boost::shared_ptr<AUD_IReader>(new AUD_SuperposeReader(reader1, reader2));
}
diff --git a/intern/audaspace/FX/AUD_SuperposeFactory.h b/intern/audaspace/FX/AUD_SuperposeFactory.h
index 2da8e34496d..caa0dfb752f 100644
--- a/intern/audaspace/FX/AUD_SuperposeFactory.h
+++ b/intern/audaspace/FX/AUD_SuperposeFactory.h
@@ -43,12 +43,12 @@ private:
/**
* First played factory.
*/
- AUD_Reference<AUD_IFactory> m_factory1;
+ boost::shared_ptr<AUD_IFactory> m_factory1;
/**
* Second played factory.
*/
- AUD_Reference<AUD_IFactory> m_factory2;
+ boost::shared_ptr<AUD_IFactory> m_factory2;
// hide copy constructor and operator=
AUD_SuperposeFactory(const AUD_SuperposeFactory&);
@@ -60,9 +60,9 @@ public:
* \param factory1 The first input factory.
* \param factory2 The second input factory.
*/
- AUD_SuperposeFactory(AUD_Reference<AUD_IFactory> factory1, AUD_Reference<AUD_IFactory> factory2);
+ AUD_SuperposeFactory(boost::shared_ptr<AUD_IFactory> factory1, boost::shared_ptr<AUD_IFactory> factory2);
- virtual AUD_Reference<AUD_IReader> createReader();
+ virtual boost::shared_ptr<AUD_IReader> createReader();
};
#endif //__AUD_SUPERPOSEFACTORY_H__
diff --git a/intern/audaspace/FX/AUD_SuperposeReader.cpp b/intern/audaspace/FX/AUD_SuperposeReader.cpp
index 535d3590a8f..294a48b3e7a 100644
--- a/intern/audaspace/FX/AUD_SuperposeReader.cpp
+++ b/intern/audaspace/FX/AUD_SuperposeReader.cpp
@@ -34,7 +34,7 @@
static const char* specs_error = "AUD_SuperposeReader: Both readers have to "
"have the same specs.";
-AUD_SuperposeReader::AUD_SuperposeReader(AUD_Reference<AUD_IReader> reader1, AUD_Reference<AUD_IReader> reader2) :
+AUD_SuperposeReader::AUD_SuperposeReader(boost::shared_ptr<AUD_IReader> reader1, boost::shared_ptr<AUD_IReader> reader2) :
m_reader1(reader1), m_reader2(reader2)
{
}
diff --git a/intern/audaspace/FX/AUD_SuperposeReader.h b/intern/audaspace/FX/AUD_SuperposeReader.h
index d0fde13a267..a04ab90fe43 100644
--- a/intern/audaspace/FX/AUD_SuperposeReader.h
+++ b/intern/audaspace/FX/AUD_SuperposeReader.h
@@ -32,7 +32,8 @@
#include "AUD_IReader.h"
#include "AUD_Buffer.h"
-#include "AUD_Reference.h"
+
+#include <boost/shared_ptr.hpp>
/**
* This reader plays two readers with the same specs in parallel.
@@ -43,12 +44,12 @@ private:
/**
* The first reader.
*/
- AUD_Reference<AUD_IReader> m_reader1;
+ boost::shared_ptr<AUD_IReader> m_reader1;
/**
* The second reader.
*/
- AUD_Reference<AUD_IReader> m_reader2;
+ boost::shared_ptr<AUD_IReader> m_reader2;
/**
* Buffer used for mixing.
@@ -66,7 +67,7 @@ public:
* \param reader2 The second reader to read from.
* \exception AUD_Exception Thrown if the specs from the readers differ.
*/
- AUD_SuperposeReader(AUD_Reference<AUD_IReader> reader1, AUD_Reference<AUD_IReader> reader2);
+ AUD_SuperposeReader(boost::shared_ptr<AUD_IReader> reader1, boost::shared_ptr<AUD_IReader> reader2);
/**
* Destroys the reader.
diff --git a/intern/audaspace/FX/AUD_VolumeFactory.cpp b/intern/audaspace/FX/AUD_VolumeFactory.cpp
index f5e635eec2d..4f0e1e425e6 100644
--- a/intern/audaspace/FX/AUD_VolumeFactory.cpp
+++ b/intern/audaspace/FX/AUD_VolumeFactory.cpp
@@ -30,7 +30,7 @@
#include "AUD_VolumeFactory.h"
#include "AUD_IIRFilterReader.h"
-AUD_VolumeFactory::AUD_VolumeFactory(AUD_Reference<AUD_IFactory> factory, float volume) :
+AUD_VolumeFactory::AUD_VolumeFactory(boost::shared_ptr<AUD_IFactory> factory, float volume) :
AUD_EffectFactory(factory),
m_volume(volume)
{
@@ -41,10 +41,10 @@ float AUD_VolumeFactory::getVolume() const
return m_volume;
}
-AUD_Reference<AUD_IReader> AUD_VolumeFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_VolumeFactory::createReader()
{
std::vector<float> a, b;
a.push_back(1);
b.push_back(m_volume);
- return new AUD_IIRFilterReader(getReader(), b, a);
+ return boost::shared_ptr<AUD_IReader>(new AUD_IIRFilterReader(getReader(), b, a));
}
diff --git a/intern/audaspace/FX/AUD_VolumeFactory.h b/intern/audaspace/FX/AUD_VolumeFactory.h
index b12838373b3..6fe779ffb88 100644
--- a/intern/audaspace/FX/AUD_VolumeFactory.h
+++ b/intern/audaspace/FX/AUD_VolumeFactory.h
@@ -55,7 +55,7 @@ public:
* \param factory The input factory.
* \param volume The desired volume.
*/
- AUD_VolumeFactory(AUD_Reference<AUD_IFactory> factory, float volume);
+ AUD_VolumeFactory(boost::shared_ptr<AUD_IFactory> factory, float volume);
/**
* Returns the volume.
@@ -63,7 +63,7 @@ public:
*/
float getVolume() const;
- virtual AUD_Reference<AUD_IReader> createReader();
+ virtual boost::shared_ptr<AUD_IReader> createReader();
};
#endif //__AUD_VOLUMEFACTORY_H__
diff --git a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp
index a114d8b8a87..371e0007bd3 100644
--- a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp
+++ b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp
@@ -67,7 +67,7 @@ static const char* queue_error = "AUD_OpenALDevice: Buffer couldn't be "
static const char* bufferdata_error = "AUD_OpenALDevice: Buffer couldn't be "
"filled with data.";
-AUD_OpenALDevice::AUD_OpenALHandle::AUD_OpenALHandle(AUD_OpenALDevice* device, ALenum format, AUD_Reference<AUD_IReader> reader, bool keep) :
+AUD_OpenALDevice::AUD_OpenALHandle::AUD_OpenALHandle(AUD_OpenALDevice* device, ALenum format, boost::shared_ptr<AUD_IReader> reader, bool keep) :
m_isBuffered(false), m_reader(reader), m_keep(keep), m_format(format), m_current(0),
m_eos(false), m_loopcount(0), m_stop(NULL), m_stop_data(NULL), m_status(AUD_STATUS_PLAYING),
m_device(device)
@@ -130,14 +130,22 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::pause()
if(m_status == AUD_STATUS_PLAYING)
{
- m_device->m_playingSounds.remove(this);
- m_device->m_pausedSounds.push_back(this);
+ for(AUD_HandleIterator it = m_device->m_playingSounds.begin(); it != m_device->m_playingSounds.end(); it++)
+ {
+ if(it->get() == this)
+ {
+ boost::shared_ptr<AUD_OpenALHandle> This = *it;
- alSourcePause(m_source);
+ m_device->m_playingSounds.erase(it);
+ m_device->m_pausedSounds.push_back(This);
- m_status = AUD_STATUS_PAUSED;
+ alSourcePause(m_source);
- return true;
+ m_status = AUD_STATUS_PAUSED;
+
+ return true;
+ }
+ }
}
}
@@ -152,12 +160,21 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::resume()
if(m_status == AUD_STATUS_PAUSED)
{
- m_device->m_pausedSounds.remove(this);
- m_device->m_playingSounds.push_back(this);
+ for(AUD_HandleIterator it = m_device->m_pausedSounds.begin(); it != m_device->m_pausedSounds.end(); it++)
+ {
+ if(it->get() == this)
+ {
+ boost::shared_ptr<AUD_OpenALHandle> This = *it;
- m_device->start();
- m_status = AUD_STATUS_PLAYING;
- return true;
+ m_device->m_pausedSounds.erase(it);
+ m_device->m_playingSounds.push_back(This);
+
+ m_device->start();
+ m_status = AUD_STATUS_PLAYING;
+
+ return true;
+ }
+ }
}
}
@@ -184,7 +201,7 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::stop()
{
if(it->get() == this)
{
- AUD_Reference<AUD_OpenALHandle> This = *it;
+ boost::shared_ptr<AUD_OpenALHandle> This = *it;
m_device->m_playingSounds.erase(it);
@@ -838,15 +855,15 @@ void AUD_OpenALDevice::start(bool join)
void AUD_OpenALDevice::updateStreams()
{
- AUD_Reference<AUD_OpenALHandle> sound;
+ boost::shared_ptr<AUD_OpenALHandle> sound;
int length;
ALint info;
AUD_DeviceSpecs specs = m_specs;
ALCenum cerr;
- std::list<AUD_Reference<AUD_OpenALHandle> > stopSounds;
- std::list<AUD_Reference<AUD_OpenALHandle> > pauseSounds;
+ std::list<boost::shared_ptr<AUD_OpenALHandle> > stopSounds;
+ std::list<boost::shared_ptr<AUD_OpenALHandle> > pauseSounds;
AUD_HandleIterator it;
while(1)
@@ -1204,32 +1221,32 @@ bool AUD_OpenALDevice::getFormat(ALenum &format, AUD_Specs specs)
return valid;
}
-AUD_Reference<AUD_IHandle> AUD_OpenALDevice::play(AUD_Reference<AUD_IReader> reader, bool keep)
+boost::shared_ptr<AUD_IHandle> AUD_OpenALDevice::play(boost::shared_ptr<AUD_IReader> reader, bool keep)
{
AUD_Specs specs = reader->getSpecs();
// check format
if(specs.channels == AUD_CHANNELS_INVALID)
- return AUD_Reference<AUD_IHandle>();
+ return boost::shared_ptr<AUD_IHandle>();
if(m_specs.format != AUD_FORMAT_FLOAT32)
- reader = new AUD_ConverterReader(reader, m_specs);
+ reader = boost::shared_ptr<AUD_IReader>(new AUD_ConverterReader(reader, m_specs));
ALenum format;
if(!getFormat(format, specs))
- return AUD_Reference<AUD_IHandle>();
+ return boost::shared_ptr<AUD_IHandle>();
AUD_MutexLock lock(*this);
alcSuspendContext(m_context);
- AUD_Reference<AUD_OpenALDevice::AUD_OpenALHandle> sound;
+ boost::shared_ptr<AUD_OpenALDevice::AUD_OpenALHandle> sound;
try
{
// create the handle
- sound = new AUD_OpenALDevice::AUD_OpenALHandle(this, format, reader, keep);
+ sound = boost::shared_ptr<AUD_OpenALDevice::AUD_OpenALHandle>(new AUD_OpenALDevice::AUD_OpenALHandle(this, format, reader, keep));
}
catch(AUD_Exception&)
{
@@ -1244,10 +1261,10 @@ AUD_Reference<AUD_IHandle> AUD_OpenALDevice::play(AUD_Reference<AUD_IReader> rea
start();
- return AUD_Reference<AUD_IHandle>(sound);
+ return boost::shared_ptr<AUD_IHandle>(sound);
}
-AUD_Reference<AUD_IHandle> AUD_OpenALDevice::play(AUD_Reference<AUD_IFactory> factory, bool keep)
+boost::shared_ptr<AUD_IHandle> AUD_OpenALDevice::play(boost::shared_ptr<AUD_IFactory> factory, bool keep)
{
/* AUD_XXX disabled
AUD_OpenALHandle* sound = NULL;
diff --git a/intern/audaspace/OpenAL/AUD_OpenALDevice.h b/intern/audaspace/OpenAL/AUD_OpenALDevice.h
index 0a409b42462..d2a4be227ba 100644
--- a/intern/audaspace/OpenAL/AUD_OpenALDevice.h
+++ b/intern/audaspace/OpenAL/AUD_OpenALDevice.h
@@ -58,7 +58,7 @@ private:
bool m_isBuffered;
/// The reader source.
- AUD_Reference<AUD_IReader> m_reader;
+ boost::shared_ptr<AUD_IReader> m_reader;
/// Whether to keep the source if end of it is reached.
bool m_keep;
@@ -105,7 +105,7 @@ private:
* \param reader The reader this handle plays.
* \param keep Whether to keep the handle alive when the reader ends.
*/
- AUD_OpenALHandle(AUD_OpenALDevice* device, ALenum format, AUD_Reference<AUD_IReader> reader, bool keep);
+ AUD_OpenALHandle(AUD_OpenALDevice* device, ALenum format, boost::shared_ptr<AUD_IReader> reader, bool keep);
virtual ~AUD_OpenALHandle() {}
virtual bool pause();
@@ -150,7 +150,7 @@ private:
virtual bool setConeVolumeOuter(float volume);
};
- typedef std::list<AUD_Reference<AUD_OpenALHandle> >::iterator AUD_HandleIterator;
+ typedef std::list<boost::shared_ptr<AUD_OpenALHandle> >::iterator AUD_HandleIterator;
/**
* The OpenAL device handle.
@@ -175,12 +175,12 @@ private:
/**
* The list of sounds that are currently playing.
*/
- std::list<AUD_Reference<AUD_OpenALHandle> > m_playingSounds;
+ std::list<boost::shared_ptr<AUD_OpenALHandle> > m_playingSounds;
/**
* The list of sounds that are currently paused.
*/
- std::list<AUD_Reference<AUD_OpenALHandle> > m_pausedSounds;
+ std::list<boost::shared_ptr<AUD_OpenALHandle> > m_pausedSounds;
/**
* The list of buffered factories.
@@ -255,8 +255,8 @@ public:
virtual ~AUD_OpenALDevice();
virtual AUD_DeviceSpecs getSpecs() const;
- virtual AUD_Reference<AUD_IHandle> play(AUD_Reference<AUD_IReader> reader, bool keep = false);
- virtual AUD_Reference<AUD_IHandle> play(AUD_Reference<AUD_IFactory> factory, bool keep = false);
+ virtual boost::shared_ptr<AUD_IHandle> play(boost::shared_ptr<AUD_IReader> reader, bool keep = false);
+ virtual boost::shared_ptr<AUD_IHandle> play(boost::shared_ptr<AUD_IFactory> factory, bool keep = false);
virtual void stopAll();
virtual void lock();
virtual void unlock();
diff --git a/intern/audaspace/Python/AUD_PyAPI.cpp b/intern/audaspace/Python/AUD_PyAPI.cpp
index dd58e5a7398..9beba2eb0a0 100644
--- a/intern/audaspace/Python/AUD_PyAPI.cpp
+++ b/intern/audaspace/Python/AUD_PyAPI.cpp
@@ -90,7 +90,7 @@ static void
Factory_dealloc(Factory* self)
{
if(self->factory)
- delete reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory);
+ delete reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory);
Py_XDECREF(self->child_list);
Py_TYPE(self)->tp_free((PyObject *)self);
}
@@ -114,7 +114,7 @@ Factory_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
try
{
- self->factory = new AUD_Reference<AUD_IFactory>(new AUD_FileFactory(filename));
+ self->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_FileFactory(filename));
}
catch(AUD_Exception& e)
{
@@ -154,7 +154,7 @@ Factory_sine(PyTypeObject* type, PyObject *args)
{
try
{
- self->factory = new AUD_Reference<AUD_IFactory>(new AUD_SinusFactory(frequency, (AUD_SampleRate)rate));
+ self->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_SinusFactory(frequency, (AUD_SampleRate)rate));
}
catch(AUD_Exception& e)
{
@@ -193,7 +193,7 @@ Factory_file(PyTypeObject* type, PyObject *args)
{
try
{
- self->factory = new AUD_Reference<AUD_IFactory>(new AUD_FileFactory(filename));
+ self->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_FileFactory(filename));
}
catch(AUD_Exception& e)
{
@@ -236,7 +236,7 @@ Factory_lowpass(Factory* self, PyObject *args)
try
{
- parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_LowpassFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), frequency, Q));
+ parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_LowpassFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory), frequency, Q));
}
catch(AUD_Exception& e)
{
@@ -277,7 +277,7 @@ Factory_delay(Factory* self, PyObject *args)
try
{
- parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_DelayFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), delay));
+ parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_DelayFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory), delay));
}
catch(AUD_Exception& e)
{
@@ -321,7 +321,7 @@ Factory_join(Factory* self, PyObject *object)
try
{
- parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_DoubleFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), *reinterpret_cast<AUD_Reference<AUD_IFactory>*>(child->factory)));
+ parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_DoubleFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory), *reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(child->factory)));
}
catch(AUD_Exception& e)
{
@@ -364,7 +364,7 @@ Factory_highpass(Factory* self, PyObject *args)
try
{
- parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_HighpassFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), frequency, Q));
+ parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_HighpassFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory), frequency, Q));
}
catch(AUD_Exception& e)
{
@@ -405,7 +405,7 @@ Factory_limit(Factory* self, PyObject *args)
try
{
- parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_LimiterFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), start, end));
+ parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_LimiterFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory), start, end));
}
catch(AUD_Exception& e)
{
@@ -449,7 +449,7 @@ Factory_pitch(Factory* self, PyObject *args)
try
{
- parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_PitchFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), factor));
+ parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_PitchFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory), factor));
}
catch(AUD_Exception& e)
{
@@ -491,7 +491,7 @@ Factory_volume(Factory* self, PyObject *args)
try
{
- parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_VolumeFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), volume));
+ parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_VolumeFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory), volume));
}
catch(AUD_Exception& e)
{
@@ -534,7 +534,7 @@ Factory_fadein(Factory* self, PyObject *args)
try
{
- parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_FaderFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), AUD_FADE_IN, start, length));
+ parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_FaderFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory), AUD_FADE_IN, start, length));
}
catch(AUD_Exception& e)
{
@@ -578,7 +578,7 @@ Factory_fadeout(Factory* self, PyObject *args)
try
{
- parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_FaderFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), AUD_FADE_OUT, start, length));
+ parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_FaderFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory), AUD_FADE_OUT, start, length));
}
catch(AUD_Exception& e)
{
@@ -620,7 +620,7 @@ Factory_loop(Factory* self, PyObject *args)
try
{
- parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_LoopFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), loop));
+ parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_LoopFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory), loop));
}
catch(AUD_Exception& e)
{
@@ -663,7 +663,7 @@ Factory_mix(Factory* self, PyObject *object)
try
{
- parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_SuperposeFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), *reinterpret_cast<AUD_Reference<AUD_IFactory>*>(child->factory)));
+ parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_SuperposeFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory), *reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(child->factory)));
}
catch(AUD_Exception& e)
{
@@ -696,7 +696,7 @@ Factory_pingpong(Factory* self)
try
{
- parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_PingPongFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory)));
+ parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_PingPongFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory)));
}
catch(AUD_Exception& e)
{
@@ -735,7 +735,7 @@ Factory_reverse(Factory* self)
try
{
- parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_ReverseFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory)));
+ parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_ReverseFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory)));
}
catch(AUD_Exception& e)
{
@@ -770,7 +770,7 @@ Factory_buffer(Factory* self)
{
try
{
- parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_StreamBufferFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory)));
+ parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_StreamBufferFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory)));
}
catch(AUD_Exception& e)
{
@@ -812,7 +812,7 @@ Factory_square(Factory* self, PyObject *args)
try
{
- parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_SquareFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), threshold));
+ parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_SquareFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory), threshold));
}
catch(AUD_Exception& e)
{
@@ -915,7 +915,7 @@ Factory_filter(Factory* self, PyObject *args)
try
{
- parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_IIRFilterFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), b, a));
+ parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_IIRFilterFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory), b, a));
}
catch(AUD_Exception& e)
{
@@ -1039,7 +1039,7 @@ static void
Handle_dealloc(Handle* self)
{
if(self->handle)
- delete reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle);
+ delete reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle);
Py_TYPE(self)->tp_free((PyObject *)self);
}
@@ -1054,7 +1054,7 @@ Handle_pause(Handle *self)
{
try
{
- return PyBool_FromLong((long)(*reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle))->pause());
+ return PyBool_FromLong((long)(*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->pause());
}
catch(AUD_Exception& e)
{
@@ -1074,7 +1074,7 @@ Handle_resume(Handle *self)
{
try
{
- return PyBool_FromLong((long)(*reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle))->resume());
+ return PyBool_FromLong((long)(*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->resume());
}
catch(AUD_Exception& e)
{
@@ -1095,7 +1095,7 @@ Handle_stop(Handle *self)
{
try
{
- return PyBool_FromLong((long)(*reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle))->stop());
+ return PyBool_FromLong((long)(*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->stop());
}
catch(AUD_Exception& e)
{
@@ -1125,7 +1125,7 @@ Handle_get_position(Handle *self, void* nothing)
{
try
{
- return Py_BuildValue("f", (*reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle))->getPosition());
+ return Py_BuildValue("f", (*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->getPosition());
}
catch(AUD_Exception& e)
{
@@ -1144,7 +1144,7 @@ Handle_set_position(Handle *self, PyObject *args, void* nothing)
try
{
- if((*reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle))->seek(position))
+ if((*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->seek(position))
return 0;
PyErr_SetString(AUDError, "Couldn't seek the sound!");
}
@@ -1170,7 +1170,7 @@ Handle_get_keep(Handle *self, void* nothing)
{
try
{
- return PyBool_FromLong((long)(*reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle))->getKeep());
+ return PyBool_FromLong((long)(*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->getKeep());
}
catch(AUD_Exception& e)
{
@@ -1192,7 +1192,7 @@ Handle_set_keep(Handle *self, PyObject *args, void* nothing)
try
{
- if((*reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle))->setKeep(keep))
+ if((*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->setKeep(keep))
return 0;
PyErr_SetString(AUDError, "Couldn't set keep of the sound!");
}
@@ -1212,7 +1212,7 @@ Handle_get_status(Handle *self, void* nothing)
{
try
{
- return PyBool_FromLong((long)(*reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle))->getStatus());
+ return PyBool_FromLong((long)(*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->getStatus());
}
catch(AUD_Exception& e)
{
@@ -1229,7 +1229,7 @@ Handle_get_volume(Handle *self, void* nothing)
{
try
{
- return Py_BuildValue("f", (*reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle))->getVolume());
+ return Py_BuildValue("f", (*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->getVolume());
}
catch(AUD_Exception& e)
{
@@ -1248,7 +1248,7 @@ Handle_set_volume(Handle *self, PyObject *args, void* nothing)
try
{
- if((*reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle))->setVolume(volume))
+ if((*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->setVolume(volume))
return 0;
PyErr_SetString(AUDError, "Couldn't set the sound volume!");
}
@@ -1268,7 +1268,7 @@ Handle_get_pitch(Handle *self, void* nothing)
{
try
{
- return Py_BuildValue("f", (*reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle))->getPitch());
+ return Py_BuildValue("f", (*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->getPitch());
}
catch(AUD_Exception& e)
{
@@ -1287,7 +1287,7 @@ Handle_set_pitch(Handle *self, PyObject *args, void* nothing)
try
{
- if((*reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle))->setPitch(pitch))
+ if((*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->setPitch(pitch))
return 0;
PyErr_SetString(AUDError, "Couldn't set the sound pitch!");
}
@@ -1307,7 +1307,7 @@ Handle_get_loop_count(Handle *self, void* nothing)
{
try
{
- return Py_BuildValue("i", (*reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle))->getLoopCount());
+ return Py_BuildValue("i", (*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->getLoopCount());
}
catch(AUD_Exception& e)
{
@@ -1326,7 +1326,7 @@ Handle_set_loop_count(Handle *self, PyObject *args, void* nothing)
try
{
- if((*reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle))->setLoopCount(loops))
+ if((*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->setLoopCount(loops))
return 0;
PyErr_SetString(AUDError, "Couldn't set the loop count!");
}
@@ -1346,7 +1346,7 @@ Handle_get_location(Handle *self, void* nothing)
{
try
{
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+ AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
if(handle)
{
AUD_Vector3 v = handle->getSourceLocation();
@@ -1375,7 +1375,7 @@ Handle_set_location(Handle *self, PyObject *args, void* nothing)
try
{
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+ AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
if(handle)
{
AUD_Vector3 location(x, y, z);
@@ -1402,7 +1402,7 @@ Handle_get_velocity(Handle *self, void* nothing)
{
try
{
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+ AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
if(handle)
{
AUD_Vector3 v = handle->getSourceVelocity();
@@ -1431,7 +1431,7 @@ Handle_set_velocity(Handle *self, PyObject *args, void* nothing)
try
{
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+ AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
if(handle)
{
AUD_Vector3 velocity(x, y, z);
@@ -1458,7 +1458,7 @@ Handle_get_orientation(Handle *self, void* nothing)
{
try
{
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+ AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
if(handle)
{
AUD_Quaternion o = handle->getSourceOrientation();
@@ -1487,7 +1487,7 @@ Handle_set_orientation(Handle *self, PyObject *args, void* nothing)
try
{
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+ AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
if(handle)
{
AUD_Quaternion orientation(w, x, y, z);
@@ -1514,7 +1514,7 @@ Handle_get_relative(Handle *self, void* nothing)
{
try
{
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+ AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
if(handle)
{
return PyBool_FromLong((long)handle->isRelative());
@@ -1545,7 +1545,7 @@ Handle_set_relative(Handle *self, PyObject *args, void* nothing)
try
{
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+ AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
if(handle)
{
if(handle->setRelative(relative))
@@ -1572,7 +1572,7 @@ Handle_get_volume_minimum(Handle *self, void* nothing)
{
try
{
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+ AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
if(handle)
{
return Py_BuildValue("f", handle->getVolumeMinimum());
@@ -1600,7 +1600,7 @@ Handle_set_volume_minimum(Handle *self, PyObject *args, void* nothing)
try
{
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+ AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
if(handle)
{
if(handle->setVolumeMinimum(volume))
@@ -1627,7 +1627,7 @@ Handle_get_volume_maximum(Handle *self, void* nothing)
{
try
{
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+ AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
if(handle)
{
return Py_BuildValue("f", handle->getVolumeMaximum());
@@ -1655,7 +1655,7 @@ Handle_set_volume_maximum(Handle *self, PyObject *args, void* nothing)
try
{
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+ AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
if(handle)
{
if(handle->setVolumeMaximum(volume))
@@ -1683,7 +1683,7 @@ Handle_get_distance_reference(Handle *self, void* nothing)
{
try
{
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+ AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
if(handle)
{
return Py_BuildValue("f", handle->getDistanceReference());
@@ -1711,7 +1711,7 @@ Handle_set_distance_reference(Handle *self, PyObject *args, void* nothing)
try
{
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+ AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
if(handle)
{
if(handle->setDistanceReference(distance))
@@ -1739,7 +1739,7 @@ Handle_get_distance_maximum(Handle *self, void* nothing)
{
try
{
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+ AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
if(handle)
{
return Py_BuildValue("f", handle->getDistanceMaximum());
@@ -1767,7 +1767,7 @@ Handle_set_distance_maximum(Handle *self, PyObject *args, void* nothing)
try
{
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+ AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
if(handle)
{
if(handle->setDistanceMaximum(distance))
@@ -1795,7 +1795,7 @@ Handle_get_attenuation(Handle *self, void* nothing)
{
try
{
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+ AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
if(handle)
{
return Py_BuildValue("f", handle->getAttenuation());
@@ -1823,7 +1823,7 @@ Handle_set_attenuation(Handle *self, PyObject *args, void* nothing)
try
{
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+ AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
if(handle)
{
if(handle->setAttenuation(factor))
@@ -1856,7 +1856,7 @@ Handle_get_cone_angle_inner(Handle *self, void* nothing)
{
try
{
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+ AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
if(handle)
{
return Py_BuildValue("f", handle->getConeAngleInner());
@@ -1884,7 +1884,7 @@ Handle_set_cone_angle_inner(Handle *self, PyObject *args, void* nothing)
try
{
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+ AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
if(handle)
{
if(handle->setConeAngleInner(angle))
@@ -1911,7 +1911,7 @@ Handle_get_cone_angle_outer(Handle *self, void* nothing)
{
try
{
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+ AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
if(handle)
{
return Py_BuildValue("f", handle->getConeAngleOuter());
@@ -1939,7 +1939,7 @@ Handle_set_cone_angle_outer(Handle *self, PyObject *args, void* nothing)
try
{
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+ AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
if(handle)
{
if(handle->setConeAngleOuter(angle))
@@ -1966,7 +1966,7 @@ Handle_get_cone_volume_outer(Handle *self, void* nothing)
{
try
{
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+ AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
if(handle)
{
return Py_BuildValue("f", handle->getConeVolumeOuter());
@@ -1994,7 +1994,7 @@ Handle_set_cone_volume_outer(Handle *self, PyObject *args, void* nothing)
try
{
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+ AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
if(handle)
{
if(handle->setConeVolumeOuter(volume))
@@ -2104,7 +2104,7 @@ static void
Device_dealloc(Device* self)
{
if(self->device)
- delete reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device);
+ delete reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device);
Py_TYPE(self)->tp_free((PyObject *)self);
}
@@ -2147,21 +2147,21 @@ Device_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
case AUD_DEVICE_NULL:
(void)specs; /* quiet warning when others disabled */
- self->device = new AUD_Reference<AUD_IDevice>(new AUD_NULLDevice());
+ self->device = new boost::shared_ptr<AUD_IDevice>(new AUD_NULLDevice());
break;
case AUD_DEVICE_OPENAL:
#ifdef WITH_OPENAL
- self->device = new AUD_Reference<AUD_IDevice>(new AUD_OpenALDevice(specs, buffersize));
+ self->device = new boost::shared_ptr<AUD_IDevice>(new AUD_OpenALDevice(specs, buffersize));
#endif
break;
case AUD_DEVICE_SDL:
#ifdef WITH_SDL
- self->device = new AUD_Reference<AUD_IDevice>(new AUD_SDLDevice(specs, buffersize));
+ self->device = new boost::shared_ptr<AUD_IDevice>(new AUD_SDLDevice(specs, buffersize));
#endif
break;
case AUD_DEVICE_JACK:
#ifdef WITH_JACK
- self->device = new AUD_Reference<AUD_IDevice>(new AUD_JackDevice(name, specs, buffersize));
+ self->device = new boost::shared_ptr<AUD_IDevice>(new AUD_JackDevice(name, specs, buffersize));
#endif
break;
case AUD_DEVICE_READ:
@@ -2236,7 +2236,7 @@ Device_play(Device *self, PyObject *args, PyObject *kwds)
{
try
{
- handle->handle = new AUD_Reference<AUD_IHandle>((*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device))->play(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(sound->factory), keep));
+ handle->handle = new boost::shared_ptr<AUD_IHandle>((*reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device))->play(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(sound->factory), keep));
}
catch(AUD_Exception& e)
{
@@ -2258,7 +2258,7 @@ Device_stopAll(Device *self)
{
try
{
- (*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device))->stopAll();
+ (*reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device))->stopAll();
Py_RETURN_NONE;
}
catch(AUD_Exception& e)
@@ -2284,7 +2284,7 @@ Device_lock(Device *self)
{
try
{
- (*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device))->lock();
+ (*reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device))->lock();
Py_RETURN_NONE;
}
catch(AUD_Exception& e)
@@ -2304,7 +2304,7 @@ Device_unlock(Device *self)
{
try
{
- (*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device))->unlock();
+ (*reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device))->unlock();
Py_RETURN_NONE;
}
catch(AUD_Exception& e)
@@ -2338,7 +2338,7 @@ Device_get_rate(Device *self, void* nothing)
{
try
{
- AUD_DeviceSpecs specs = (*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device))->getSpecs();
+ AUD_DeviceSpecs specs = (*reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device))->getSpecs();
return Py_BuildValue("d", specs.rate);
}
catch(AUD_Exception& e)
@@ -2356,7 +2356,7 @@ Device_get_format(Device *self, void* nothing)
{
try
{
- AUD_DeviceSpecs specs = (*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device))->getSpecs();
+ AUD_DeviceSpecs specs = (*reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device))->getSpecs();
return Py_BuildValue("i", specs.format);
}
catch(AUD_Exception& e)
@@ -2374,7 +2374,7 @@ Device_get_channels(Device *self, void* nothing)
{
try
{
- AUD_DeviceSpecs specs = (*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device))->getSpecs();
+ AUD_DeviceSpecs specs = (*reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device))->getSpecs();
return Py_BuildValue("i", specs.channels);
}
catch(AUD_Exception& e)
@@ -2392,7 +2392,7 @@ Device_get_volume(Device *self, void* nothing)
{
try
{
- return Py_BuildValue("f", (*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device))->getVolume());
+ return Py_BuildValue("f", (*reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device))->getVolume());
}
catch(AUD_Exception& e)
{
@@ -2411,7 +2411,7 @@ Device_set_volume(Device *self, PyObject *args, void* nothing)
try
{
- (*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device))->setVolume(volume);
+ (*reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device))->setVolume(volume);
return 0;
}
catch(AUD_Exception& e)
@@ -2429,7 +2429,7 @@ Device_get_listener_location(Device *self, void* nothing)
{
try
{
- AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get());
+ AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device)->get());
if(device)
{
AUD_Vector3 v = device->getListenerLocation();
@@ -2458,7 +2458,7 @@ Device_set_listener_location(Device *self, PyObject *args, void* nothing)
try
{
- AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get());
+ AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device)->get());
if(device)
{
AUD_Vector3 location(x, y, z);
@@ -2484,7 +2484,7 @@ Device_get_listener_velocity(Device *self, void* nothing)
{
try
{
- AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get());
+ AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device)->get());
if(device)
{
AUD_Vector3 v = device->getListenerVelocity();
@@ -2513,7 +2513,7 @@ Device_set_listener_velocity(Device *self, PyObject *args, void* nothing)
try
{
- AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get());
+ AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device)->get());
if(device)
{
AUD_Vector3 velocity(x, y, z);
@@ -2539,7 +2539,7 @@ Device_get_listener_orientation(Device *self, void* nothing)
{
try
{
- AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get());
+ AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device)->get());
if(device)
{
AUD_Quaternion o = device->getListenerOrientation();
@@ -2568,7 +2568,7 @@ Device_set_listener_orientation(Device *self, PyObject *args, void* nothing)
try
{
- AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get());
+ AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device)->get());
if(device)
{
AUD_Quaternion orientation(w, x, y, z);
@@ -2595,7 +2595,7 @@ Device_get_speed_of_sound(Device *self, void* nothing)
{
try
{
- AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get());
+ AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device)->get());
if(device)
{
return Py_BuildValue("f", device->getSpeedOfSound());
@@ -2623,7 +2623,7 @@ Device_set_speed_of_sound(Device *self, PyObject *args, void* nothing)
try
{
- AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get());
+ AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device)->get());
if(device)
{
device->setSpeedOfSound(speed);
@@ -2651,7 +2651,7 @@ Device_get_doppler_factor(Device *self, void* nothing)
{
try
{
- AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get());
+ AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device)->get());
if(device)
{
return Py_BuildValue("f", device->getDopplerFactor());
@@ -2679,7 +2679,7 @@ Device_set_doppler_factor(Device *self, PyObject *args, void* nothing)
try
{
- AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get());
+ AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device)->get());
if(device)
{
device->setDopplerFactor(factor);
@@ -2705,7 +2705,7 @@ Device_get_distance_model(Device *self, void* nothing)
{
try
{
- AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get());
+ AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device)->get());
if(device)
{
return Py_BuildValue("i", int(device->getDistanceModel()));
@@ -2733,7 +2733,7 @@ Device_set_distance_model(Device *self, PyObject *args, void* nothing)
try
{
- AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get());
+ AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device)->get());
if(device)
{
device->setDistanceModel(AUD_DistanceModel(model));
diff --git a/intern/audaspace/SConscript b/intern/audaspace/SConscript
index 50c81db46dd..e2b6efacc96 100644
--- a/intern/audaspace/SConscript
+++ b/intern/audaspace/SConscript
@@ -3,7 +3,7 @@
Import ('env')
sources = env.Glob('intern/*.cpp') + env.Glob('FX/*.cpp')
-incs = '. intern FX ' + env['BF_PTHREADS_INC']
+incs = '. intern FX ' + env['BF_PTHREADS_INC'] + ' ' + env['BF_BOOST_INC']
defs = []
if env['WITH_BF_FFMPEG']:
diff --git a/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.cpp b/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.cpp
index c4c384f054c..403c367fccc 100644
--- a/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.cpp
+++ b/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.cpp
@@ -46,10 +46,10 @@ AUD_FFMPEGFactory::AUD_FFMPEGFactory(const data_t* buffer, int size) :
memcpy(m_buffer->getBuffer(), buffer, size);
}
-AUD_Reference<AUD_IReader> AUD_FFMPEGFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_FFMPEGFactory::createReader()
{
- if(m_buffer.isNull())
- return new AUD_FFMPEGReader(m_filename);
+ if(m_buffer.get())
+ return boost::shared_ptr<AUD_IReader>(new AUD_FFMPEGReader(m_buffer));
else
- return new AUD_FFMPEGReader(m_buffer);
+ return boost::shared_ptr<AUD_IReader>(new AUD_FFMPEGReader(m_filename));
}
diff --git a/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.h b/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.h
index 349f55dd7db..23d0f07ed0b 100644
--- a/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.h
+++ b/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.h
@@ -31,10 +31,10 @@
#define __AUD_FFMPEGFACTORY_H__
#include "AUD_IFactory.h"
-#include "AUD_Reference.h"
#include "AUD_Buffer.h"
#include <string>
+#include <boost/shared_ptr.hpp>
/**
* This factory reads a sound file via ffmpeg.
@@ -52,7 +52,7 @@ private:
/**
* The buffer to read from.
*/
- AUD_Reference<AUD_Buffer> m_buffer;
+ boost::shared_ptr<AUD_Buffer> m_buffer;
// hide copy constructor and operator=
AUD_FFMPEGFactory(const AUD_FFMPEGFactory&);
@@ -72,7 +72,7 @@ public:
*/
AUD_FFMPEGFactory(const data_t* buffer, int size);
- virtual AUD_Reference<AUD_IReader> createReader();
+ virtual boost::shared_ptr<AUD_IReader> createReader();
};
#endif //__AUD_FFMPEGFACTORY_H__
diff --git a/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp b/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp
index 28a14a9cfc7..0a3d0f8e85a 100644
--- a/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp
+++ b/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp
@@ -197,7 +197,7 @@ AUD_FFMPEGReader::AUD_FFMPEGReader(std::string filename) :
static const char* streamopen_error = "AUD_FFMPEGReader: Stream couldn't be "
"opened.";
-AUD_FFMPEGReader::AUD_FFMPEGReader(AUD_Reference<AUD_Buffer> buffer) :
+AUD_FFMPEGReader::AUD_FFMPEGReader(boost::shared_ptr<AUD_Buffer> buffer) :
m_pkgbuf(AVCODEC_MAX_AUDIO_FRAME_SIZE<<1),
m_membuffer(buffer),
m_membufferpos(0)
diff --git a/intern/audaspace/ffmpeg/AUD_FFMPEGReader.h b/intern/audaspace/ffmpeg/AUD_FFMPEGReader.h
index 2b354b0b2a1..d5d9fb300ff 100644
--- a/intern/audaspace/ffmpeg/AUD_FFMPEGReader.h
+++ b/intern/audaspace/ffmpeg/AUD_FFMPEGReader.h
@@ -32,10 +32,10 @@
#include "AUD_ConverterFunctions.h"
#include "AUD_IReader.h"
-#include "AUD_Reference.h"
#include "AUD_Buffer.h"
#include <string>
+#include <boost/shared_ptr.hpp>
struct AVCodecContext;
extern "C" {
@@ -99,7 +99,7 @@ private:
/**
* The memory file to read from.
*/
- AUD_Reference<AUD_Buffer> m_membuffer;
+ boost::shared_ptr<AUD_Buffer> m_membuffer;
/**
* The buffer to read with.
@@ -143,7 +143,7 @@ public:
* \exception AUD_Exception Thrown if the buffer specified cannot be read
* with ffmpeg.
*/
- AUD_FFMPEGReader(AUD_Reference<AUD_Buffer> buffer);
+ AUD_FFMPEGReader(boost::shared_ptr<AUD_Buffer> buffer);
/**
* Destroys the reader and closes the file.
diff --git a/intern/audaspace/intern/AUD_BufferReader.cpp b/intern/audaspace/intern/AUD_BufferReader.cpp
index dbff70095ad..b9d819ff774 100644
--- a/intern/audaspace/intern/AUD_BufferReader.cpp
+++ b/intern/audaspace/intern/AUD_BufferReader.cpp
@@ -33,7 +33,7 @@
#include <cstring>
-AUD_BufferReader::AUD_BufferReader(AUD_Reference<AUD_Buffer> buffer,
+AUD_BufferReader::AUD_BufferReader(boost::shared_ptr<AUD_Buffer> buffer,
AUD_Specs specs) :
m_position(0), m_buffer(buffer), m_specs(specs)
{
diff --git a/intern/audaspace/intern/AUD_BufferReader.h b/intern/audaspace/intern/AUD_BufferReader.h
index 0e8c5de9a9d..d0c90ce7e61 100644
--- a/intern/audaspace/intern/AUD_BufferReader.h
+++ b/intern/audaspace/intern/AUD_BufferReader.h
@@ -31,9 +31,10 @@
#define __AUD_BUFFERREADER_H__
#include "AUD_IReader.h"
-#include "AUD_Reference.h"
class AUD_Buffer;
+#include <boost/shared_ptr.hpp>
+
/**
* This class represents a simple reader from a buffer that exists in memory.
* \warning Notice that the buffer used for creating the reader must exist as
@@ -50,7 +51,7 @@ private:
/**
* The buffer that is read.
*/
- AUD_Reference<AUD_Buffer> m_buffer;
+ boost::shared_ptr<AUD_Buffer> m_buffer;
/**
* The specification of the sample data in the buffer.
@@ -67,7 +68,7 @@ public:
* \param buffer The buffer to read from.
* \param specs The specification of the sample data in the buffer.
*/
- AUD_BufferReader(AUD_Reference<AUD_Buffer> buffer, AUD_Specs specs);
+ AUD_BufferReader(boost::shared_ptr<AUD_Buffer> buffer, AUD_Specs specs);
virtual bool isSeekable() const;
virtual void seek(int position);
diff --git a/intern/audaspace/intern/AUD_C-API.cpp b/intern/audaspace/intern/AUD_C-API.cpp
index a1da90b073e..3150c1af011 100644
--- a/intern/audaspace/intern/AUD_C-API.cpp
+++ b/intern/audaspace/intern/AUD_C-API.cpp
@@ -91,10 +91,10 @@ extern "C" {
#include <cassert>
-typedef AUD_Reference<AUD_IFactory> AUD_Sound;
-typedef AUD_Reference<AUD_ReadDevice> AUD_Device;
-typedef AUD_Reference<AUD_IHandle> AUD_Handle;
-typedef AUD_Reference<AUD_SequencerEntry> AUD_SEntry;
+typedef boost::shared_ptr<AUD_IFactory> AUD_Sound;
+typedef boost::shared_ptr<AUD_ReadDevice> AUD_Device;
+typedef boost::shared_ptr<AUD_IHandle> AUD_Handle;
+typedef boost::shared_ptr<AUD_SequencerEntry> AUD_SEntry;
#define AUD_CAPI_IMPLEMENTATION
#include "AUD_C-API.h"
@@ -103,7 +103,7 @@ typedef AUD_Reference<AUD_SequencerEntry> AUD_SEntry;
# define NULL (void *)0
#endif
-static AUD_Reference<AUD_IDevice> AUD_device;
+static boost::shared_ptr<AUD_IDevice> AUD_device;
static AUD_I3DDevice *AUD_3ddevice;
void AUD_initOnce()
@@ -115,25 +115,25 @@ void AUD_initOnce()
int AUD_init(AUD_DeviceType device, AUD_DeviceSpecs specs, int buffersize)
{
- AUD_Reference<AUD_IDevice> dev;
+ boost::shared_ptr<AUD_IDevice> dev;
- if (!AUD_device.isNull()) {
+ if (AUD_device.get()) {
AUD_exit();
}
try {
switch(device) {
case AUD_NULL_DEVICE:
- dev = new AUD_NULLDevice();
+ dev = boost::shared_ptr<AUD_IDevice>(new AUD_NULLDevice());
break;
#ifdef WITH_SDL
case AUD_SDL_DEVICE:
- dev = new AUD_SDLDevice(specs, buffersize);
+ dev = boost::shared_ptr<AUD_IDevice>(new AUD_SDLDevice(specs, buffersize));
break;
#endif
#ifdef WITH_OPENAL
case AUD_OPENAL_DEVICE:
- dev = new AUD_OpenALDevice(specs, buffersize);
+ dev = boost::shared_ptr<AUD_IDevice>(new AUD_OpenALDevice(specs, buffersize));
break;
#endif
#ifdef WITH_JACK
@@ -147,7 +147,7 @@ int AUD_init(AUD_DeviceType device, AUD_DeviceSpecs specs, int buffersize)
else
{
#endif
- dev = new AUD_JackDevice("Blender", specs, buffersize);
+ dev = boost::shared_ptr<AUD_IDevice>(new AUD_JackDevice("Blender", specs, buffersize));
break;
#ifdef __APPLE__
}
@@ -170,17 +170,17 @@ int AUD_init(AUD_DeviceType device, AUD_DeviceSpecs specs, int buffersize)
void AUD_exit()
{
- AUD_device = AUD_Reference<AUD_IDevice>();
+ AUD_device = boost::shared_ptr<AUD_IDevice>();
AUD_3ddevice = NULL;
}
#ifdef WITH_PYTHON
static PyObject *AUD_getCDevice(PyObject *self)
{
- if (!AUD_device.isNull()) {
+ if (AUD_device.get()) {
Device *device = (Device *)Device_empty();
if (device != NULL) {
- device->device = new AUD_Reference<AUD_IDevice>(AUD_device);
+ device->device = new boost::shared_ptr<AUD_IDevice>(AUD_device);
return (PyObject *)device;
}
}
@@ -206,12 +206,12 @@ static PyObject *AUD_getSoundFromPointer(PyObject *self, PyObject *args)
if (PyArg_Parse(args, "l:_sound_from_pointer", &lptr)) {
if (lptr) {
- AUD_Reference<AUD_IFactory>* factory = (AUD_Reference<AUD_IFactory>*) sound_get_factory((void *) lptr);
+ boost::shared_ptr<AUD_IFactory>* factory = (boost::shared_ptr<AUD_IFactory>*) sound_get_factory((void *) lptr);
if (factory) {
Factory *obj = (Factory *)Factory_empty();
if (obj) {
- obj->factory = new AUD_Reference<AUD_IFactory>(*factory);
+ obj->factory = new boost::shared_ptr<AUD_IFactory>(*factory);
return (PyObject *) obj;
}
}
@@ -246,7 +246,7 @@ void *AUD_getPythonFactory(AUD_Sound *sound)
if (sound) {
Factory *obj = (Factory *) Factory_empty();
if (obj) {
- obj->factory = new AUD_Reference<AUD_IFactory>(*sound);
+ obj->factory = new boost::shared_ptr<AUD_IFactory>(*sound);
return (PyObject *) obj;
}
}
@@ -261,7 +261,7 @@ AUD_Sound *AUD_getPythonSound(void *sound)
if (!factory)
return NULL;
- return new AUD_Reference<AUD_IFactory>(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(factory->factory));
+ return new boost::shared_ptr<AUD_IFactory>(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(factory->factory));
}
#endif
@@ -286,9 +286,9 @@ AUD_SoundInfo AUD_getInfo(AUD_Sound *sound)
info.length = 0.0f;
try {
- AUD_Reference<AUD_IReader> reader = (*sound)->createReader();
+ boost::shared_ptr<AUD_IReader> reader = (*sound)->createReader();
- if (!reader.isNull()) {
+ if (reader.get()) {
info.specs = reader->getSpecs();
info.length = reader->getLength() / (float) info.specs.rate;
}
@@ -432,7 +432,7 @@ AUD_Handle *AUD_play(AUD_Sound *sound, int keep)
assert(sound);
try {
AUD_Handle handle = AUD_device->play(*sound, keep);
- if (!handle.isNull()) {
+ if (handle.get()) {
return new AUD_Handle(handle);
}
}
@@ -552,9 +552,9 @@ int AUD_setDistanceModel(AUD_DistanceModel model)
int AUD_setSourceLocation(AUD_Handle *handle, const float location[3])
{
assert(handle);
- AUD_Reference<AUD_I3DHandle> h(*handle);
+ boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
- if (!h.isNull()) {
+ if (h.get()) {
AUD_Vector3 v(location[0], location[1], location[2]);
return h->setSourceLocation(v);
}
@@ -565,9 +565,9 @@ int AUD_setSourceLocation(AUD_Handle *handle, const float location[3])
int AUD_setSourceVelocity(AUD_Handle *handle, const float velocity[3])
{
assert(handle);
- AUD_Reference<AUD_I3DHandle> h(*handle);
+ boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
- if (!h.isNull()) {
+ if (h.get()) {
AUD_Vector3 v(velocity[0], velocity[1], velocity[2]);
return h->setSourceVelocity(v);
}
@@ -578,9 +578,9 @@ int AUD_setSourceVelocity(AUD_Handle *handle, const float velocity[3])
int AUD_setSourceOrientation(AUD_Handle *handle, const float orientation[4])
{
assert(handle);
- AUD_Reference<AUD_I3DHandle> h(*handle);
+ boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
- if (!h.isNull()) {
+ if (h.get()) {
AUD_Quaternion q(orientation[3], orientation[0], orientation[1], orientation[2]);
return h->setSourceOrientation(q);
}
@@ -591,9 +591,9 @@ int AUD_setSourceOrientation(AUD_Handle *handle, const float orientation[4])
int AUD_setRelative(AUD_Handle *handle, int relative)
{
assert(handle);
- AUD_Reference<AUD_I3DHandle> h(*handle);
+ boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
- if (!h.isNull()) {
+ if (h.get()) {
return h->setRelative(relative);
}
@@ -603,9 +603,9 @@ int AUD_setRelative(AUD_Handle *handle, int relative)
int AUD_setVolumeMaximum(AUD_Handle *handle, float volume)
{
assert(handle);
- AUD_Reference<AUD_I3DHandle> h(*handle);
+ boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
- if (!h.isNull()) {
+ if (h.get()) {
return h->setVolumeMaximum(volume);
}
@@ -615,9 +615,9 @@ int AUD_setVolumeMaximum(AUD_Handle *handle, float volume)
int AUD_setVolumeMinimum(AUD_Handle *handle, float volume)
{
assert(handle);
- AUD_Reference<AUD_I3DHandle> h(*handle);
+ boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
- if (!h.isNull()) {
+ if (h.get()) {
return h->setVolumeMinimum(volume);
}
@@ -627,9 +627,9 @@ int AUD_setVolumeMinimum(AUD_Handle *handle, float volume)
int AUD_setDistanceMaximum(AUD_Handle *handle, float distance)
{
assert(handle);
- AUD_Reference<AUD_I3DHandle> h(*handle);
+ boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
- if (!h.isNull()) {
+ if (h.get()) {
return h->setDistanceMaximum(distance);
}
@@ -639,9 +639,9 @@ int AUD_setDistanceMaximum(AUD_Handle *handle, float distance)
int AUD_setDistanceReference(AUD_Handle *handle, float distance)
{
assert(handle);
- AUD_Reference<AUD_I3DHandle> h(*handle);
+ boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
- if (!h.isNull()) {
+ if (h.get()) {
return h->setDistanceReference(distance);
}
@@ -651,9 +651,9 @@ int AUD_setDistanceReference(AUD_Handle *handle, float distance)
int AUD_setAttenuation(AUD_Handle *handle, float factor)
{
assert(handle);
- AUD_Reference<AUD_I3DHandle> h(*handle);
+ boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
- if (!h.isNull()) {
+ if (h.get()) {
return h->setAttenuation(factor);
}
@@ -663,9 +663,9 @@ int AUD_setAttenuation(AUD_Handle *handle, float factor)
int AUD_setConeAngleOuter(AUD_Handle *handle, float angle)
{
assert(handle);
- AUD_Reference<AUD_I3DHandle> h(*handle);
+ boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
- if (!h.isNull()) {
+ if (h.get()) {
return h->setConeAngleOuter(angle);
}
@@ -675,9 +675,9 @@ int AUD_setConeAngleOuter(AUD_Handle *handle, float angle)
int AUD_setConeAngleInner(AUD_Handle *handle, float angle)
{
assert(handle);
- AUD_Reference<AUD_I3DHandle> h(*handle);
+ boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
- if (!h.isNull()) {
+ if (h.get()) {
return h->setConeAngleInner(angle);
}
@@ -687,9 +687,9 @@ int AUD_setConeAngleInner(AUD_Handle *handle, float angle)
int AUD_setConeVolumeOuter(AUD_Handle *handle, float volume)
{
assert(handle);
- AUD_Reference<AUD_I3DHandle> h(*handle);
+ boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
- if (!h.isNull()) {
+ if (h.get()) {
return h->setConeVolumeOuter(volume);
}
@@ -734,7 +734,7 @@ AUD_Handle *AUD_playDevice(AUD_Device *device, AUD_Sound *sound, float seek)
try {
AUD_Handle handle = (*device)->play(*sound);
- if (!handle.isNull()) {
+ if (handle.get()) {
handle->seek(seek);
return new AUD_Handle(handle);
}
@@ -793,38 +793,38 @@ float *AUD_readSoundBuffer(const char *filename, float low, float high,
AUD_DeviceSpecs specs;
specs.channels = AUD_CHANNELS_MONO;
specs.rate = (AUD_SampleRate)samplerate;
- AUD_Reference<AUD_IFactory> sound;
+ boost::shared_ptr<AUD_IFactory> sound;
- AUD_Reference<AUD_IFactory> file = new AUD_FileFactory(filename);
+ boost::shared_ptr<AUD_IFactory> file = boost::shared_ptr<AUD_IFactory>(new AUD_FileFactory(filename));
int position = 0;
try {
- AUD_Reference<AUD_IReader> reader = file->createReader();
+ boost::shared_ptr<AUD_IReader> reader = file->createReader();
AUD_SampleRate rate = reader->getSpecs().rate;
- sound = new AUD_ChannelMapperFactory(file, specs);
+ sound = boost::shared_ptr<AUD_IFactory>(new AUD_ChannelMapperFactory(file, specs));
if (high < rate)
- sound = new AUD_LowpassFactory(sound, high);
+ sound = boost::shared_ptr<AUD_IFactory>(new AUD_LowpassFactory(sound, high));
if (low > 0)
- sound = new AUD_HighpassFactory(sound, low);
+ sound = boost::shared_ptr<AUD_IFactory>(new AUD_HighpassFactory(sound, low));
- sound = new AUD_EnvelopeFactory(sound, attack, release, threshold, 0.1f);
- sound = new AUD_LinearResampleFactory(sound, specs);
+ sound = boost::shared_ptr<AUD_IFactory>(new AUD_EnvelopeFactory(sound, attack, release, threshold, 0.1f));
+ sound = boost::shared_ptr<AUD_IFactory>(new AUD_LinearResampleFactory(sound, specs));
if (square)
- sound = new AUD_SquareFactory(sound, sthreshold);
+ sound = boost::shared_ptr<AUD_IFactory>(new AUD_SquareFactory(sound, sthreshold));
if (accumulate)
- sound = new AUD_AccumulatorFactory(sound, additive);
+ sound = boost::shared_ptr<AUD_IFactory>(new AUD_AccumulatorFactory(sound, additive));
else if (additive)
- sound = new AUD_SumFactory(sound);
+ sound = boost::shared_ptr<AUD_IFactory>(new AUD_SumFactory(sound));
reader = sound->createReader();
- if (reader.isNull())
+ if (!reader.get())
return NULL;
int len;
@@ -856,14 +856,14 @@ static void pauseSound(AUD_Handle *handle)
AUD_Handle *AUD_pauseAfter(AUD_Handle *handle, float seconds)
{
- AUD_Reference<AUD_IFactory> silence = new AUD_SilenceFactory;
- AUD_Reference<AUD_IFactory> limiter = new AUD_LimiterFactory(silence, 0, seconds);
+ boost::shared_ptr<AUD_IFactory> silence = boost::shared_ptr<AUD_IFactory>(new AUD_SilenceFactory);
+ boost::shared_ptr<AUD_IFactory> limiter = boost::shared_ptr<AUD_IFactory>(new AUD_LimiterFactory(silence, 0, seconds));
AUD_MutexLock lock(*AUD_device);
try {
AUD_Handle handle2 = AUD_device->play(limiter);
- if (!handle2.isNull()) {
+ if (handle2.get()) {
handle2->setStopCallback((stopCallback)pauseSound, handle);
return new AUD_Handle(handle2);
}
@@ -881,7 +881,7 @@ AUD_Sound *AUD_createSequencer(float fps, int muted)
AUD_Specs specs;
specs.channels = AUD_CHANNELS_STEREO;
specs.rate = AUD_RATE_44100;
- AUD_Sound *sequencer = new AUD_Sound(AUD_Reference<AUD_SequencerFactory>(new AUD_SequencerFactory(specs, fps, muted)));
+ AUD_Sound *sequencer = new AUD_Sound(boost::shared_ptr<AUD_SequencerFactory>(new AUD_SequencerFactory(specs, fps, muted)));
return sequencer;
}
@@ -1070,7 +1070,7 @@ int AUD_readSound(AUD_Sound *sound, sample_t *buffer, int length, int samples_pe
specs.channels = AUD_CHANNELS_MONO;
specs.format = AUD_FORMAT_INVALID;
- AUD_Reference<AUD_IReader> reader = AUD_ChannelMapperFactory(*sound, specs).createReader();
+ boost::shared_ptr<AUD_IReader> reader = AUD_ChannelMapperFactory(*sound, specs).createReader();
specs.specs = reader->getSpecs();
int len;
@@ -1124,7 +1124,7 @@ int AUD_readSound(AUD_Sound *sound, sample_t *buffer, int length, int samples_pe
AUD_Sound *AUD_copy(AUD_Sound *sound)
{
- return new AUD_Reference<AUD_IFactory>(*sound);
+ return new boost::shared_ptr<AUD_IFactory>(*sound);
}
void AUD_freeHandle(AUD_Handle *handle)
@@ -1176,9 +1176,9 @@ const char *AUD_mixdown(AUD_Sound *sound, unsigned int start, unsigned int lengt
AUD_SequencerFactory *f = dynamic_cast<AUD_SequencerFactory *>(sound->get());
f->setSpecs(specs.specs);
- AUD_Reference<AUD_IReader> reader = f->createQualityReader();
+ boost::shared_ptr<AUD_IReader> reader = f->createQualityReader();
reader->seek(start);
- AUD_Reference<AUD_IWriter> writer = AUD_FileWriter::createWriter(filename, specs, format, codec, bitrate);
+ boost::shared_ptr<AUD_IWriter> writer = AUD_FileWriter::createWriter(filename, specs, format, codec, bitrate);
AUD_FileWriter::writeReader(reader, writer, length, buffersize);
return NULL;
@@ -1196,7 +1196,7 @@ const char *AUD_mixdown_per_channel(AUD_Sound *sound, unsigned int start, unsign
f->setSpecs(specs.specs);
- std::vector<AUD_Reference<AUD_IWriter> > writers;
+ std::vector<boost::shared_ptr<AUD_IWriter> > writers;
int channels = specs.channels;
specs.channels = AUD_CHANNELS_MONO;
@@ -1220,7 +1220,7 @@ const char *AUD_mixdown_per_channel(AUD_Sound *sound, unsigned int start, unsign
writers.push_back(AUD_FileWriter::createWriter(stream.str(), specs, format, codec, bitrate));
}
- AUD_Reference<AUD_IReader> reader = f->createQualityReader();
+ boost::shared_ptr<AUD_IReader> reader = f->createQualityReader();
reader->seek(start);
AUD_FileWriter::writeReader(reader, writers, length, buffersize);
@@ -1242,7 +1242,7 @@ AUD_Device *AUD_openMixdownDevice(AUD_DeviceSpecs specs, AUD_Sound *sequencer, f
dynamic_cast<AUD_SequencerFactory *>(sequencer->get())->setSpecs(specs.specs);
AUD_Handle handle = device->play(*sequencer);
- if (!handle.isNull()) {
+ if (handle.get()) {
handle->seek(start);
}
@@ -1254,7 +1254,7 @@ AUD_Device *AUD_openMixdownDevice(AUD_DeviceSpecs specs, AUD_Sound *sequencer, f
}
}
-AUD_Reference<AUD_IDevice> AUD_getDevice()
+boost::shared_ptr<AUD_IDevice> AUD_getDevice()
{
return AUD_device;
}
diff --git a/intern/audaspace/intern/AUD_C-API.h b/intern/audaspace/intern/AUD_C-API.h
index 75e3456de9a..9c6611fe04a 100644
--- a/intern/audaspace/intern/AUD_C-API.h
+++ b/intern/audaspace/intern/AUD_C-API.h
@@ -755,7 +755,7 @@ extern AUD_Sound *AUD_getPythonSound(void *sound);
#ifdef __cplusplus
}
-#include "AUD_Reference.h"
+#include <boost/shared_ptr.hpp>
class AUD_IDevice;
class AUD_I3DDevice;
@@ -763,7 +763,7 @@ class AUD_I3DDevice;
* Returns the current playback device.
* \return The playback device.
*/
-AUD_Reference<AUD_IDevice> AUD_getDevice();
+boost::shared_ptr<AUD_IDevice> AUD_getDevice();
/**
* Returns the current playback 3D device.
diff --git a/intern/audaspace/intern/AUD_ChannelMapperFactory.cpp b/intern/audaspace/intern/AUD_ChannelMapperFactory.cpp
index 7743ccf46da..f4ba5d05ff0 100644
--- a/intern/audaspace/intern/AUD_ChannelMapperFactory.cpp
+++ b/intern/audaspace/intern/AUD_ChannelMapperFactory.cpp
@@ -32,14 +32,14 @@
#include <cstring>
-AUD_ChannelMapperFactory::AUD_ChannelMapperFactory(AUD_Reference<AUD_IFactory> factory,
+AUD_ChannelMapperFactory::AUD_ChannelMapperFactory(boost::shared_ptr<AUD_IFactory> factory,
AUD_DeviceSpecs specs) :
AUD_MixerFactory(factory, specs)
{
}
-AUD_Reference<AUD_IReader> AUD_ChannelMapperFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_ChannelMapperFactory::createReader()
{
- AUD_Reference<AUD_IReader> reader = getReader();
- return new AUD_ChannelMapperReader(reader, m_specs.channels);
+ boost::shared_ptr<AUD_IReader> reader = getReader();
+ return boost::shared_ptr<AUD_IReader>(new AUD_ChannelMapperReader(reader, m_specs.channels));
}
diff --git a/intern/audaspace/intern/AUD_ChannelMapperFactory.h b/intern/audaspace/intern/AUD_ChannelMapperFactory.h
index b60a32d5510..611b5041c39 100644
--- a/intern/audaspace/intern/AUD_ChannelMapperFactory.h
+++ b/intern/audaspace/intern/AUD_ChannelMapperFactory.h
@@ -49,9 +49,9 @@ public:
* \param factory The input factory.
* \param specs The target specifications.
*/
- AUD_ChannelMapperFactory(AUD_Reference<AUD_IFactory> factory, AUD_DeviceSpecs specs);
+ AUD_ChannelMapperFactory(boost::shared_ptr<AUD_IFactory> factory, AUD_DeviceSpecs specs);
- virtual AUD_Reference<AUD_IReader> createReader();
+ virtual boost::shared_ptr<AUD_IReader> createReader();
};
#endif //__AUD_CHANNELMAPPERFACTORY_H__
diff --git a/intern/audaspace/intern/AUD_ChannelMapperReader.cpp b/intern/audaspace/intern/AUD_ChannelMapperReader.cpp
index 7a179c6f94a..8b983d5c43d 100644
--- a/intern/audaspace/intern/AUD_ChannelMapperReader.cpp
+++ b/intern/audaspace/intern/AUD_ChannelMapperReader.cpp
@@ -38,7 +38,7 @@
#include "AUD_ChannelMapperReader.h"
-AUD_ChannelMapperReader::AUD_ChannelMapperReader(AUD_Reference<AUD_IReader> reader,
+AUD_ChannelMapperReader::AUD_ChannelMapperReader(boost::shared_ptr<AUD_IReader> reader,
AUD_Channels channels) :
AUD_EffectReader(reader), m_target_channels(channels),
m_source_channels(AUD_CHANNELS_INVALID), m_mapping(0), m_map_size(0), m_mono_angle(0)
diff --git a/intern/audaspace/intern/AUD_ChannelMapperReader.h b/intern/audaspace/intern/AUD_ChannelMapperReader.h
index 32adb058115..b122b070d29 100644
--- a/intern/audaspace/intern/AUD_ChannelMapperReader.h
+++ b/intern/audaspace/intern/AUD_ChannelMapperReader.h
@@ -110,7 +110,7 @@ public:
* \param reader The reader to map.
* \param mapping The mapping specification as two dimensional float array.
*/
- AUD_ChannelMapperReader(AUD_Reference<AUD_IReader> reader, AUD_Channels channels);
+ AUD_ChannelMapperReader(boost::shared_ptr<AUD_IReader> reader, AUD_Channels channels);
/**
* Destroys the reader.
diff --git a/intern/audaspace/intern/AUD_ConverterFactory.cpp b/intern/audaspace/intern/AUD_ConverterFactory.cpp
index b61f9bc194c..7cbf64f1697 100644
--- a/intern/audaspace/intern/AUD_ConverterFactory.cpp
+++ b/intern/audaspace/intern/AUD_ConverterFactory.cpp
@@ -30,18 +30,18 @@
#include "AUD_ConverterFactory.h"
#include "AUD_ConverterReader.h"
-AUD_ConverterFactory::AUD_ConverterFactory(AUD_Reference<AUD_IFactory> factory,
+AUD_ConverterFactory::AUD_ConverterFactory(boost::shared_ptr<AUD_IFactory> factory,
AUD_DeviceSpecs specs) :
AUD_MixerFactory(factory, specs)
{
}
-AUD_Reference<AUD_IReader> AUD_ConverterFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_ConverterFactory::createReader()
{
- AUD_Reference<AUD_IReader> reader = getReader();
+ boost::shared_ptr<AUD_IReader> reader = getReader();
if(m_specs.format != AUD_FORMAT_FLOAT32)
- reader = new AUD_ConverterReader(reader, m_specs);
+ reader = boost::shared_ptr<AUD_IReader>(new AUD_ConverterReader(reader, m_specs));
return reader;
}
diff --git a/intern/audaspace/intern/AUD_ConverterFactory.h b/intern/audaspace/intern/AUD_ConverterFactory.h
index 3211b607517..2c9c82d235b 100644
--- a/intern/audaspace/intern/AUD_ConverterFactory.h
+++ b/intern/audaspace/intern/AUD_ConverterFactory.h
@@ -49,9 +49,9 @@ public:
* \param factory The input factory.
* \param specs The target specifications.
*/
- AUD_ConverterFactory(AUD_Reference<AUD_IFactory> factory, AUD_DeviceSpecs specs);
+ AUD_ConverterFactory(boost::shared_ptr<AUD_IFactory> factory, AUD_DeviceSpecs specs);
- virtual AUD_Reference<AUD_IReader> createReader();
+ virtual boost::shared_ptr<AUD_IReader> createReader();
};
#endif //__AUD_CONVERTERFACTORY_H__
diff --git a/intern/audaspace/intern/AUD_ConverterReader.cpp b/intern/audaspace/intern/AUD_ConverterReader.cpp
index 63178f316b2..a90a54670e8 100644
--- a/intern/audaspace/intern/AUD_ConverterReader.cpp
+++ b/intern/audaspace/intern/AUD_ConverterReader.cpp
@@ -29,7 +29,7 @@
#include "AUD_ConverterReader.h"
-AUD_ConverterReader::AUD_ConverterReader(AUD_Reference<AUD_IReader> reader,
+AUD_ConverterReader::AUD_ConverterReader(boost::shared_ptr<AUD_IReader> reader,
AUD_DeviceSpecs specs) :
AUD_EffectReader(reader),
m_format(specs.format)
diff --git a/intern/audaspace/intern/AUD_ConverterReader.h b/intern/audaspace/intern/AUD_ConverterReader.h
index 2dedbd89180..987b7c70279 100644
--- a/intern/audaspace/intern/AUD_ConverterReader.h
+++ b/intern/audaspace/intern/AUD_ConverterReader.h
@@ -65,7 +65,7 @@ public:
* \param reader The reader to convert.
* \param specs The target specification.
*/
- AUD_ConverterReader(AUD_Reference<AUD_IReader> reader, AUD_DeviceSpecs specs);
+ AUD_ConverterReader(boost::shared_ptr<AUD_IReader> reader, AUD_DeviceSpecs specs);
virtual void read(int& length, bool& eos, sample_t* buffer);
};
diff --git a/intern/audaspace/intern/AUD_FileFactory.cpp b/intern/audaspace/intern/AUD_FileFactory.cpp
index a27acff19cf..f9353db6677 100644
--- a/intern/audaspace/intern/AUD_FileFactory.cpp
+++ b/intern/audaspace/intern/AUD_FileFactory.cpp
@@ -56,15 +56,15 @@ AUD_FileFactory::AUD_FileFactory(const data_t* buffer, int size) :
static const char* read_error = "AUD_FileFactory: File couldn't be read.";
-AUD_Reference<AUD_IReader> AUD_FileFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_FileFactory::createReader()
{
#ifdef WITH_SNDFILE
try
{
- if(m_buffer.isNull())
- return new AUD_SndFileReader(m_filename);
+ if(m_buffer.get())
+ return boost::shared_ptr<AUD_IReader>(new AUD_SndFileReader(m_buffer));
else
- return new AUD_SndFileReader(m_buffer);
+ return boost::shared_ptr<AUD_IReader>(new AUD_SndFileReader(m_filename));
}
catch(AUD_Exception&) {}
#endif
@@ -72,10 +72,10 @@ AUD_Reference<AUD_IReader> AUD_FileFactory::createReader()
#ifdef WITH_FFMPEG
try
{
- if(m_buffer.isNull())
- return new AUD_FFMPEGReader(m_filename);
+ if(m_buffer.get())
+ return boost::shared_ptr<AUD_IReader>(new AUD_FFMPEGReader(m_buffer));
else
- return new AUD_FFMPEGReader(m_buffer);
+ return boost::shared_ptr<AUD_IReader>(new AUD_FFMPEGReader(m_filename));
}
catch(AUD_Exception&) {}
#endif
diff --git a/intern/audaspace/intern/AUD_FileFactory.h b/intern/audaspace/intern/AUD_FileFactory.h
index 4ea4a9392e9..35c8db731b4 100644
--- a/intern/audaspace/intern/AUD_FileFactory.h
+++ b/intern/audaspace/intern/AUD_FileFactory.h
@@ -31,10 +31,10 @@
#define __AUD_FILEFACTORY_H__
#include "AUD_IFactory.h"
-#include "AUD_Reference.h"
#include "AUD_Buffer.h"
#include <string>
+#include <boost/shared_ptr.hpp>
/**
* This factory tries to read a sound file via all available file readers.
@@ -50,7 +50,7 @@ private:
/**
* The buffer to read from.
*/
- AUD_Reference<AUD_Buffer> m_buffer;
+ boost::shared_ptr<AUD_Buffer> m_buffer;
// hide copy constructor and operator=
AUD_FileFactory(const AUD_FileFactory&);
@@ -70,7 +70,7 @@ public:
*/
AUD_FileFactory(const data_t* buffer, int size);
- virtual AUD_Reference<AUD_IReader> createReader();
+ virtual boost::shared_ptr<AUD_IReader> createReader();
};
#endif //__AUD_FILEFACTORY_H__
diff --git a/intern/audaspace/intern/AUD_FileWriter.cpp b/intern/audaspace/intern/AUD_FileWriter.cpp
index f74021acad1..e3072fa82e0 100644
--- a/intern/audaspace/intern/AUD_FileWriter.cpp
+++ b/intern/audaspace/intern/AUD_FileWriter.cpp
@@ -43,13 +43,13 @@
static const char* write_error = "AUD_FileWriter: File couldn't be written.";
-AUD_Reference<AUD_IWriter> AUD_FileWriter::createWriter(std::string filename,AUD_DeviceSpecs specs,
+boost::shared_ptr<AUD_IWriter> AUD_FileWriter::createWriter(std::string filename,AUD_DeviceSpecs specs,
AUD_Container format, AUD_Codec codec, unsigned int bitrate)
{
#ifdef WITH_SNDFILE
try
{
- return new AUD_SndFileWriter(filename, specs, format, codec, bitrate);
+ return boost::shared_ptr<AUD_IWriter>(new AUD_SndFileWriter(filename, specs, format, codec, bitrate));
}
catch(AUD_Exception&) {}
#endif
@@ -57,7 +57,7 @@ AUD_Reference<AUD_IWriter> AUD_FileWriter::createWriter(std::string filename,AUD
#ifdef WITH_FFMPEG
try
{
- return new AUD_FFMPEGWriter(filename, specs, format, codec, bitrate);
+ return boost::shared_ptr<AUD_IWriter>(new AUD_FFMPEGWriter(filename, specs, format, codec, bitrate));
}
catch(AUD_Exception&) {}
#endif
@@ -65,7 +65,7 @@ AUD_Reference<AUD_IWriter> AUD_FileWriter::createWriter(std::string filename,AUD
AUD_THROW(AUD_ERROR_SPECS, write_error);
}
-void AUD_FileWriter::writeReader(AUD_Reference<AUD_IReader> reader, AUD_Reference<AUD_IWriter> writer, unsigned int length, unsigned int buffersize)
+void AUD_FileWriter::writeReader(boost::shared_ptr<AUD_IReader> reader, boost::shared_ptr<AUD_IWriter> writer, unsigned int length, unsigned int buffersize)
{
AUD_Buffer buffer(buffersize * AUD_SAMPLE_SIZE(writer->getSpecs()));
sample_t* buf = buffer.getBuffer();
@@ -94,7 +94,7 @@ void AUD_FileWriter::writeReader(AUD_Reference<AUD_IReader> reader, AUD_Referenc
}
}
-void AUD_FileWriter::writeReader(AUD_Reference<AUD_IReader> reader, std::vector<AUD_Reference<AUD_IWriter> >& writers, unsigned int length, unsigned int buffersize)
+void AUD_FileWriter::writeReader(boost::shared_ptr<AUD_IReader> reader, std::vector<boost::shared_ptr<AUD_IWriter> >& writers, unsigned int length, unsigned int buffersize)
{
AUD_Buffer buffer(buffersize * AUD_SAMPLE_SIZE(reader->getSpecs()));
AUD_Buffer buffer2(buffersize * sizeof(sample_t));
diff --git a/intern/audaspace/intern/AUD_FileWriter.h b/intern/audaspace/intern/AUD_FileWriter.h
index 385aba5ef45..da52c7e0fb2 100644
--- a/intern/audaspace/intern/AUD_FileWriter.h
+++ b/intern/audaspace/intern/AUD_FileWriter.h
@@ -32,8 +32,7 @@
#include <string>
#include <vector>
-
-#include "AUD_Reference.h"
+#include <boost/shared_ptr.hpp>
#include "AUD_IWriter.h"
#include "AUD_IReader.h"
@@ -59,7 +58,7 @@ public:
* \param bitrate The bitrate for encoding.
* \return The writer to write data to.
*/
- static AUD_Reference<AUD_IWriter> createWriter(std::string filename, AUD_DeviceSpecs specs, AUD_Container format, AUD_Codec codec, unsigned int bitrate);
+ static boost::shared_ptr<AUD_IWriter> createWriter(std::string filename, AUD_DeviceSpecs specs, AUD_Container format, AUD_Codec codec, unsigned int bitrate);
/**
* Writes a reader to a writer.
@@ -68,7 +67,7 @@ public:
* \param length How many samples should be transfered.
* \param buffersize How many samples should be transfered at once.
*/
- static void writeReader(AUD_Reference<AUD_IReader> reader, AUD_Reference<AUD_IWriter> writer, unsigned int length, unsigned int buffersize);
+ static void writeReader(boost::shared_ptr<AUD_IReader> reader, boost::shared_ptr<AUD_IWriter> writer, unsigned int length, unsigned int buffersize);
/**
* Writes a reader to several writers.
@@ -77,7 +76,7 @@ public:
* \param length How many samples should be transfered.
* \param buffersize How many samples should be transfered at once.
*/
- static void writeReader(AUD_Reference<AUD_IReader> reader, std::vector<AUD_Reference<AUD_IWriter> >& writers, unsigned int length, unsigned int buffersize);
+ static void writeReader(boost::shared_ptr<AUD_IReader> reader, std::vector<boost::shared_ptr<AUD_IWriter> >& writers, unsigned int length, unsigned int buffersize);
};
#endif //__AUD_FILEWRITER_H__
diff --git a/intern/audaspace/intern/AUD_IDevice.h b/intern/audaspace/intern/AUD_IDevice.h
index f4d6635e79a..a7f9a985ce4 100644
--- a/intern/audaspace/intern/AUD_IDevice.h
+++ b/intern/audaspace/intern/AUD_IDevice.h
@@ -31,12 +31,13 @@
#define __AUD_IDEVICE_H__
#include "AUD_Space.h"
-#include "AUD_Reference.h"
#include "AUD_IFactory.h"
#include "AUD_IReader.h"
#include "AUD_IHandle.h"
#include "AUD_ILockable.h"
+#include <boost/shared_ptr.hpp>
+
/**
* This class represents an output device for sound sources.
* Output devices may be several backends such as plattform independand like
@@ -68,7 +69,7 @@ public:
* \exception AUD_Exception Thrown if there's an unexpected (from the
* device side) error during creation of the reader.
*/
- virtual AUD_Reference<AUD_IHandle> play(AUD_Reference<AUD_IReader> reader, bool keep = false)=0;
+ virtual boost::shared_ptr<AUD_IHandle> play(boost::shared_ptr<AUD_IReader> reader, bool keep = false)=0;
/**
* Plays a sound source.
@@ -80,7 +81,7 @@ public:
* \exception AUD_Exception Thrown if there's an unexpected (from the
* device side) error during creation of the reader.
*/
- virtual AUD_Reference<AUD_IHandle> play(AUD_Reference<AUD_IFactory> factory, bool keep = false)=0;
+ virtual boost::shared_ptr<AUD_IHandle> play(boost::shared_ptr<AUD_IFactory> factory, bool keep = false)=0;
/**
* Stops all playing sounds.
diff --git a/intern/audaspace/intern/AUD_IFactory.h b/intern/audaspace/intern/AUD_IFactory.h
index 95b4643072e..75103963c68 100644
--- a/intern/audaspace/intern/AUD_IFactory.h
+++ b/intern/audaspace/intern/AUD_IFactory.h
@@ -31,9 +31,10 @@
#define __AUD_IFACTORY_H__
#include "AUD_Space.h"
-#include "AUD_Reference.h"
#include "AUD_IReader.h"
+#include <boost/shared_ptr.hpp>
+
/**
* This class represents a type of sound source and saves the necessary values
* for it. It is able to create a reader that is actually usable for playback
@@ -54,7 +55,7 @@ public:
* \exception AUD_Exception An exception may be thrown if there has been
* a more unexpected error during reader creation.
*/
- virtual AUD_Reference<AUD_IReader> createReader()=0;
+ virtual boost::shared_ptr<AUD_IReader> createReader()=0;
};
#endif //__AUD_IFACTORY_H__
diff --git a/intern/audaspace/intern/AUD_JOSResampleFactory.cpp b/intern/audaspace/intern/AUD_JOSResampleFactory.cpp
index 21aae6b0547..188960f986f 100644
--- a/intern/audaspace/intern/AUD_JOSResampleFactory.cpp
+++ b/intern/audaspace/intern/AUD_JOSResampleFactory.cpp
@@ -30,13 +30,13 @@
#include "AUD_JOSResampleFactory.h"
#include "AUD_JOSResampleReader.h"
-AUD_JOSResampleFactory::AUD_JOSResampleFactory(AUD_Reference<AUD_IFactory> factory,
+AUD_JOSResampleFactory::AUD_JOSResampleFactory(boost::shared_ptr<AUD_IFactory> factory,
AUD_DeviceSpecs specs) :
AUD_MixerFactory(factory, specs)
{
}
-AUD_Reference<AUD_IReader> AUD_JOSResampleFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_JOSResampleFactory::createReader()
{
- return new AUD_JOSResampleReader(getReader(), m_specs.specs);
+ return boost::shared_ptr<AUD_IReader>(new AUD_JOSResampleReader(getReader(), m_specs.specs));
}
diff --git a/intern/audaspace/intern/AUD_JOSResampleFactory.h b/intern/audaspace/intern/AUD_JOSResampleFactory.h
index 6d18150d852..b6c2961c88a 100644
--- a/intern/audaspace/intern/AUD_JOSResampleFactory.h
+++ b/intern/audaspace/intern/AUD_JOSResampleFactory.h
@@ -48,9 +48,9 @@ public:
* \param factory The input factory.
* \param specs The target specifications.
*/
- AUD_JOSResampleFactory(AUD_Reference<AUD_IFactory> factory, AUD_DeviceSpecs specs);
+ AUD_JOSResampleFactory(boost::shared_ptr<AUD_IFactory> factory, AUD_DeviceSpecs specs);
- virtual AUD_Reference<AUD_IReader> createReader();
+ virtual boost::shared_ptr<AUD_IReader> createReader();
};
#endif //__AUD_JOSRESAMPLEFACTORY_H__
diff --git a/intern/audaspace/intern/AUD_JOSResampleReader.cpp b/intern/audaspace/intern/AUD_JOSResampleReader.cpp
index 0f7a038c88e..62fab48272b 100644
--- a/intern/audaspace/intern/AUD_JOSResampleReader.cpp
+++ b/intern/audaspace/intern/AUD_JOSResampleReader.cpp
@@ -68,7 +68,7 @@ static inline int lrint(double d)
#define fp_rest(x) (x & ((1 << SHIFT_BITS) - 1))
#define fp_rest_to_double(x) fp_to_double(fp_rest(x))
-AUD_JOSResampleReader::AUD_JOSResampleReader(AUD_Reference<AUD_IReader> reader, AUD_Specs specs) :
+AUD_JOSResampleReader::AUD_JOSResampleReader(boost::shared_ptr<AUD_IReader> reader, AUD_Specs specs) :
AUD_ResampleReader(reader, specs.rate),
m_channels(AUD_CHANNELS_INVALID),
m_n(0),
diff --git a/intern/audaspace/intern/AUD_JOSResampleReader.h b/intern/audaspace/intern/AUD_JOSResampleReader.h
index 94524c1db3e..fb68e4dc9f5 100644
--- a/intern/audaspace/intern/AUD_JOSResampleReader.h
+++ b/intern/audaspace/intern/AUD_JOSResampleReader.h
@@ -123,7 +123,7 @@ public:
* \param reader The reader to mix.
* \param specs The target specification.
*/
- AUD_JOSResampleReader(AUD_Reference<AUD_IReader> reader, AUD_Specs specs);
+ AUD_JOSResampleReader(boost::shared_ptr<AUD_IReader> reader, AUD_Specs specs);
virtual void seek(int position);
virtual int getLength() const;
diff --git a/intern/audaspace/intern/AUD_LinearResampleFactory.cpp b/intern/audaspace/intern/AUD_LinearResampleFactory.cpp
index 7f602599b7a..cd573f1047c 100644
--- a/intern/audaspace/intern/AUD_LinearResampleFactory.cpp
+++ b/intern/audaspace/intern/AUD_LinearResampleFactory.cpp
@@ -30,13 +30,13 @@
#include "AUD_LinearResampleFactory.h"
#include "AUD_LinearResampleReader.h"
-AUD_LinearResampleFactory::AUD_LinearResampleFactory(AUD_Reference<AUD_IFactory> factory,
+AUD_LinearResampleFactory::AUD_LinearResampleFactory(boost::shared_ptr<AUD_IFactory> factory,
AUD_DeviceSpecs specs) :
AUD_MixerFactory(factory, specs)
{
}
-AUD_Reference<AUD_IReader> AUD_LinearResampleFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_LinearResampleFactory::createReader()
{
- return new AUD_LinearResampleReader(getReader(), m_specs.specs);
+ return boost::shared_ptr<AUD_IReader>(new AUD_LinearResampleReader(getReader(), m_specs.specs));
}
diff --git a/intern/audaspace/intern/AUD_LinearResampleFactory.h b/intern/audaspace/intern/AUD_LinearResampleFactory.h
index 7d9efa01d2d..ceb29ef2edd 100644
--- a/intern/audaspace/intern/AUD_LinearResampleFactory.h
+++ b/intern/audaspace/intern/AUD_LinearResampleFactory.h
@@ -48,9 +48,9 @@ public:
* \param factory The input factory.
* \param specs The target specifications.
*/
- AUD_LinearResampleFactory(AUD_Reference<AUD_IFactory> factory, AUD_DeviceSpecs specs);
+ AUD_LinearResampleFactory(boost::shared_ptr<AUD_IFactory> factory, AUD_DeviceSpecs specs);
- virtual AUD_Reference<AUD_IReader> createReader();
+ virtual boost::shared_ptr<AUD_IReader> createReader();
};
#endif //__AUD_LINEARRESAMPLEFACTORY_H__
diff --git a/intern/audaspace/intern/AUD_LinearResampleReader.cpp b/intern/audaspace/intern/AUD_LinearResampleReader.cpp
index aff62d7c3aa..6aa0faed863 100644
--- a/intern/audaspace/intern/AUD_LinearResampleReader.cpp
+++ b/intern/audaspace/intern/AUD_LinearResampleReader.cpp
@@ -34,7 +34,7 @@
#define CC m_channels + channel
-AUD_LinearResampleReader::AUD_LinearResampleReader(AUD_Reference<AUD_IReader> reader,
+AUD_LinearResampleReader::AUD_LinearResampleReader(boost::shared_ptr<AUD_IReader> reader,
AUD_Specs specs) :
AUD_ResampleReader(reader, specs.rate),
m_channels(reader->getSpecs().channels),
diff --git a/intern/audaspace/intern/AUD_LinearResampleReader.h b/intern/audaspace/intern/AUD_LinearResampleReader.h
index 4f6d422f772..9beea251c07 100644
--- a/intern/audaspace/intern/AUD_LinearResampleReader.h
+++ b/intern/audaspace/intern/AUD_LinearResampleReader.h
@@ -74,7 +74,7 @@ public:
* \param reader The reader to mix.
* \param specs The target specification.
*/
- AUD_LinearResampleReader(AUD_Reference<AUD_IReader> reader, AUD_Specs specs);
+ AUD_LinearResampleReader(boost::shared_ptr<AUD_IReader> reader, AUD_Specs specs);
virtual void seek(int position);
virtual int getLength() const;
diff --git a/intern/audaspace/intern/AUD_Mixer.h b/intern/audaspace/intern/AUD_Mixer.h
index 0de9b7fc7dc..3dd03b0a3fe 100644
--- a/intern/audaspace/intern/AUD_Mixer.h
+++ b/intern/audaspace/intern/AUD_Mixer.h
@@ -32,9 +32,10 @@
#include "AUD_ConverterFunctions.h"
#include "AUD_Buffer.h"
-#include "AUD_Reference.h"
class AUD_IReader;
+#include <boost/shared_ptr.hpp>
+
/**
* This abstract class is able to mix audiosignals with same channel count
* and sample rate and convert it to a specific output format.
diff --git a/intern/audaspace/intern/AUD_MixerFactory.cpp b/intern/audaspace/intern/AUD_MixerFactory.cpp
index 95a7291d3eb..f3f00ea2cb6 100644
--- a/intern/audaspace/intern/AUD_MixerFactory.cpp
+++ b/intern/audaspace/intern/AUD_MixerFactory.cpp
@@ -30,12 +30,12 @@
#include "AUD_MixerFactory.h"
#include "AUD_IReader.h"
-AUD_Reference<AUD_IReader> AUD_MixerFactory::getReader() const
+boost::shared_ptr<AUD_IReader> AUD_MixerFactory::getReader() const
{
return m_factory->createReader();
}
-AUD_MixerFactory::AUD_MixerFactory(AUD_Reference<AUD_IFactory> factory,
+AUD_MixerFactory::AUD_MixerFactory(boost::shared_ptr<AUD_IFactory> factory,
AUD_DeviceSpecs specs) :
m_specs(specs), m_factory(factory)
{
@@ -46,7 +46,7 @@ AUD_DeviceSpecs AUD_MixerFactory::getSpecs() const
return m_specs;
}
-AUD_Reference<AUD_IFactory> AUD_MixerFactory::getFactory() const
+boost::shared_ptr<AUD_IFactory> AUD_MixerFactory::getFactory() const
{
return m_factory;
}
diff --git a/intern/audaspace/intern/AUD_MixerFactory.h b/intern/audaspace/intern/AUD_MixerFactory.h
index d65eb8ef6ae..1d2b6a4cc91 100644
--- a/intern/audaspace/intern/AUD_MixerFactory.h
+++ b/intern/audaspace/intern/AUD_MixerFactory.h
@@ -46,7 +46,7 @@ protected:
/**
* If there is no reader it is created out of this factory.
*/
- AUD_Reference<AUD_IFactory> m_factory;
+ boost::shared_ptr<AUD_IFactory> m_factory;
/**
* Returns the reader created out of the factory.
@@ -54,7 +54,7 @@ protected:
* classes.
* \return The reader to mix.
*/
- AUD_Reference<AUD_IReader> getReader() const;
+ boost::shared_ptr<AUD_IReader> getReader() const;
public:
/**
@@ -62,7 +62,7 @@ public:
* \param factory The factory to create the readers to mix out of.
* \param specs The target specification.
*/
- AUD_MixerFactory(AUD_Reference<AUD_IFactory> factory, AUD_DeviceSpecs specs);
+ AUD_MixerFactory(boost::shared_ptr<AUD_IFactory> factory, AUD_DeviceSpecs specs);
/**
* Returns the target specification for resampling.
@@ -73,7 +73,7 @@ public:
* Returns the saved factory.
* \return The factory.
*/
- AUD_Reference<AUD_IFactory> getFactory() const;
+ boost::shared_ptr<AUD_IFactory> getFactory() const;
};
#endif //__AUD_MIXERFACTORY_H__
diff --git a/intern/audaspace/intern/AUD_NULLDevice.cpp b/intern/audaspace/intern/AUD_NULLDevice.cpp
index f390971c686..98a0d324c61 100644
--- a/intern/audaspace/intern/AUD_NULLDevice.cpp
+++ b/intern/audaspace/intern/AUD_NULLDevice.cpp
@@ -127,14 +127,14 @@ AUD_DeviceSpecs AUD_NULLDevice::getSpecs() const
return specs;
}
-AUD_Reference<AUD_IHandle> AUD_NULLDevice::play(AUD_Reference<AUD_IReader> reader, bool keep)
+boost::shared_ptr<AUD_IHandle> AUD_NULLDevice::play(boost::shared_ptr<AUD_IReader> reader, bool keep)
{
- return new AUD_NULLHandle();
+ return boost::shared_ptr<AUD_IHandle>(new AUD_NULLHandle());
}
-AUD_Reference<AUD_IHandle> AUD_NULLDevice::play(AUD_Reference<AUD_IFactory> factory, bool keep)
+boost::shared_ptr<AUD_IHandle> AUD_NULLDevice::play(boost::shared_ptr<AUD_IFactory> factory, bool keep)
{
- return new AUD_NULLHandle();
+ return boost::shared_ptr<AUD_IHandle>(new AUD_NULLHandle());
}
void AUD_NULLDevice::stopAll()
diff --git a/intern/audaspace/intern/AUD_NULLDevice.h b/intern/audaspace/intern/AUD_NULLDevice.h
index ee97b151ebe..ae1435bbeea 100644
--- a/intern/audaspace/intern/AUD_NULLDevice.h
+++ b/intern/audaspace/intern/AUD_NULLDevice.h
@@ -72,8 +72,8 @@ public:
virtual ~AUD_NULLDevice();
virtual AUD_DeviceSpecs getSpecs() const;
- virtual AUD_Reference<AUD_IHandle> play(AUD_Reference<AUD_IReader> reader, bool keep = false);
- virtual AUD_Reference<AUD_IHandle> play(AUD_Reference<AUD_IFactory> factory, bool keep = false);
+ virtual boost::shared_ptr<AUD_IHandle> play(boost::shared_ptr<AUD_IReader> reader, bool keep = false);
+ virtual boost::shared_ptr<AUD_IHandle> play(boost::shared_ptr<AUD_IFactory> factory, bool keep = false);
virtual void stopAll();
virtual void lock();
virtual void unlock();
diff --git a/intern/audaspace/intern/AUD_Reference.h b/intern/audaspace/intern/AUD_Reference.h
deleted file mode 100644
index 5a1aa947148..00000000000
--- a/intern/audaspace/intern/AUD_Reference.h
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * Copyright 2009-2011 Jörg Hermann Müller
- *
- * This file is part of AudaSpace.
- *
- * Audaspace 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.
- *
- * AudaSpace 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 Audaspace; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file audaspace/intern/AUD_Reference.h
- * \ingroup audaspaceintern
- */
-
-#ifndef __AUD_REFERENCE_H__
-#define __AUD_REFERENCE_H__
-
-#include <map>
-#include <cstddef>
-#include <pthread.h>
-
-// #define MEM_DEBUG
-
-#ifdef MEM_DEBUG
-#include <iostream>
-#include <typeinfo>
-#endif
-
-/**
- * This class handles the reference counting.
- */
-class AUD_ReferenceHandler
-{
-private:
- /**
- * Saves the reference counts.
- */
- static std::map<void*, unsigned int> m_references;
- static pthread_mutex_t m_mutex;
- static bool m_mutex_initialised;
-
-public:
-
- static pthread_mutex_t* getMutex();
-
- /**
- * Reference increment.
- * \param reference The reference.
- */
- static inline void incref(void* reference)
- {
- if(!reference)
- return;
-
- std::map<void*, unsigned int>::iterator result = m_references.find(reference);
- if(result != m_references.end())
- {
- m_references[reference]++;
- }
- else
- {
- m_references[reference] = 1;
- }
- }
-
- /**
- * Reference decrement.
- * \param reference The reference.
- * \return Whether the reference has to be deleted.
- */
- static inline bool decref(void* reference)
- {
- if(!reference)
- return false;
-
- if(!--m_references[reference])
- {
- m_references.erase(reference);
- return true;
- }
- return false;
- }
-};
-
-template <class T>
-/**
- * This class provides reference counting functionality.
- */
-class AUD_Reference
-{
-private:
- /// The reference.
- T* m_reference;
- void* m_original;
-public:
- /**
- * Creates a new reference counter.
- * \param reference The reference.
- */
- template <class U>
- AUD_Reference(U* reference)
- {
- pthread_mutex_lock(AUD_ReferenceHandler::getMutex());
- m_original = reference;
- m_reference = dynamic_cast<T*>(reference);
- AUD_ReferenceHandler::incref(m_original);
-#ifdef MEM_DEBUG
- if(m_reference != NULL)
- std::cerr << "+" << typeid(*m_reference).name() << std::endl;
-#endif
- pthread_mutex_unlock(AUD_ReferenceHandler::getMutex());
- }
-
- AUD_Reference()
- {
- m_original = NULL;
- m_reference = NULL;
- }
-
- /**
- * Copies an AUD_Reference object.
- * \param ref The AUD_Reference object to copy.
- */
- AUD_Reference(const AUD_Reference& ref)
- {
- pthread_mutex_lock(AUD_ReferenceHandler::getMutex());
- m_original = ref.m_original;
- m_reference = ref.m_reference;
- AUD_ReferenceHandler::incref(m_original);
-#ifdef MEM_DEBUG
- if(m_reference != NULL)
- std::cerr << "+" << typeid(*m_reference).name() << std::endl;
-#endif
- pthread_mutex_unlock(AUD_ReferenceHandler::getMutex());
- }
-
- template <class U>
- explicit AUD_Reference(const AUD_Reference<U>& ref)
- {
- pthread_mutex_lock(AUD_ReferenceHandler::getMutex());
- m_original = ref.get();
- m_reference = dynamic_cast<T*>(ref.get());
- AUD_ReferenceHandler::incref(m_original);
-#ifdef MEM_DEBUG
- if(m_reference != NULL)
- std::cerr << "+" << typeid(*m_reference).name() << std::endl;
-#endif
- pthread_mutex_unlock(AUD_ReferenceHandler::getMutex());
- }
-
- /**
- * Destroys a AUD_Reference object, if there's no furthere reference on the
- * reference, it is destroyed as well.
- */
- ~AUD_Reference()
- {
- pthread_mutex_lock(AUD_ReferenceHandler::getMutex());
-#ifdef MEM_DEBUG
- if(m_reference != NULL)
- std::cerr << "-" << typeid(*m_reference).name() << std::endl;
-#endif
- if(AUD_ReferenceHandler::decref(m_original))
- {
- pthread_mutex_unlock(AUD_ReferenceHandler::getMutex());
- delete m_reference;
- }
- else
- {
- pthread_mutex_unlock(AUD_ReferenceHandler::getMutex());
- }
- }
-
- /**
- * Assigns an AUD_Reference to this object.
- * \param ref The AUD_Reference object to assign.
- */
- AUD_Reference& operator=(const AUD_Reference& ref)
- {
- if(&ref == this)
- return *this;
-
- pthread_mutex_lock(AUD_ReferenceHandler::getMutex());
-
-#ifdef MEM_DEBUG
- if(m_reference != NULL)
- std::cerr << "-" << typeid(*m_reference).name() << std::endl;
-#endif
- if(AUD_ReferenceHandler::decref(m_original))
- {
- pthread_mutex_unlock(AUD_ReferenceHandler::getMutex());
- delete m_reference;
- pthread_mutex_lock(AUD_ReferenceHandler::getMutex());
- }
-
- m_original = ref.m_original;
- m_reference = ref.m_reference;
- AUD_ReferenceHandler::incref(m_original);
-#ifdef MEM_DEBUG
- if(m_reference != NULL)
- std::cerr << "+" << typeid(*m_reference).name() << std::endl;
-#endif
-
- pthread_mutex_unlock(AUD_ReferenceHandler::getMutex());
-
- return *this;
- }
-
- /**
- * Returns whether the reference is NULL.
- */
- inline bool isNull() const
- {
- return m_reference == NULL;
- }
-
- /**
- * Returns the reference.
- */
- inline T* get() const
- {
- return m_reference;
- }
-
- /**
- * Returns the original pointer.
- */
- inline void* getOriginal() const
- {
- return m_original;
- }
-
- /**
- * Returns the reference.
- */
- inline T& operator*() const
- {
- return *m_reference;
- }
-
- /**
- * Returns the reference.
- */
- inline T* operator->() const
- {
- return m_reference;
- }
-};
-
-template<class T, class U>
-inline bool operator==(const AUD_Reference<T>& a, const AUD_Reference<U>& b)
-{
- return a.getOriginal() == b.getOriginal();
-}
-
-template<class T, class U>
-inline bool operator!=(const AUD_Reference<T>& a, const AUD_Reference<U>& b)
-{
- return a.getOriginal() != b.getOriginal();
-}
-
-#endif // __AUD_REFERENCE_H__
diff --git a/intern/audaspace/intern/AUD_ResampleReader.cpp b/intern/audaspace/intern/AUD_ResampleReader.cpp
index 514d790be09..4b247ffd862 100644
--- a/intern/audaspace/intern/AUD_ResampleReader.cpp
+++ b/intern/audaspace/intern/AUD_ResampleReader.cpp
@@ -29,7 +29,7 @@
#include "AUD_ResampleReader.h"
-AUD_ResampleReader::AUD_ResampleReader(AUD_Reference<AUD_IReader> reader, AUD_SampleRate rate) :
+AUD_ResampleReader::AUD_ResampleReader(boost::shared_ptr<AUD_IReader> reader, AUD_SampleRate rate) :
AUD_EffectReader(reader), m_rate(rate)
{
}
diff --git a/intern/audaspace/intern/AUD_ResampleReader.h b/intern/audaspace/intern/AUD_ResampleReader.h
index c423326489d..7e21989bfa8 100644
--- a/intern/audaspace/intern/AUD_ResampleReader.h
+++ b/intern/audaspace/intern/AUD_ResampleReader.h
@@ -47,7 +47,7 @@ protected:
* \param reader The reader to mix.
* \param rate The target sampling rate.
*/
- AUD_ResampleReader(AUD_Reference<AUD_IReader> reader, AUD_SampleRate rate);
+ AUD_ResampleReader(boost::shared_ptr<AUD_IReader> reader, AUD_SampleRate rate);
public:
/**
diff --git a/intern/audaspace/intern/AUD_Sequencer.cpp b/intern/audaspace/intern/AUD_Sequencer.cpp
new file mode 100644
index 00000000000..58e8f682714
--- /dev/null
+++ b/intern/audaspace/intern/AUD_Sequencer.cpp
@@ -0,0 +1,176 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * Copyright 2009-2011 Jörg Hermann Müller
+ *
+ * This file is part of AudaSpace.
+ *
+ * Audaspace 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.
+ *
+ * AudaSpace 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 Audaspace; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file audaspace/intern/AUD_Sequencer.cpp
+ * \ingroup audaspaceintern
+ */
+
+
+#include "AUD_Sequencer.h"
+#include "AUD_SequencerReader.h"
+#include "AUD_3DMath.h"
+#include "AUD_MutexLock.h"
+
+AUD_Sequencer::AUD_Sequencer(AUD_Specs specs, float fps, bool muted) :
+ m_specs(specs),
+ m_status(0),
+ m_entry_status(0),
+ m_id(0),
+ m_muted(muted),
+ m_fps(fps),
+ m_speed_of_sound(434),
+ m_doppler_factor(1),
+ m_distance_model(AUD_DISTANCE_MODEL_INVERSE_CLAMPED),
+ m_location(3),
+ m_orientation(4)
+{
+ AUD_Quaternion q;
+ m_orientation.write(q.get());
+ float f = 1;
+ m_volume.write(&f);
+
+ pthread_mutexattr_t attr;
+ pthread_mutexattr_init(&attr);
+ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+
+ pthread_mutex_init(&m_mutex, &attr);
+
+ pthread_mutexattr_destroy(&attr);
+}
+
+AUD_Sequencer::~AUD_Sequencer()
+{
+ pthread_mutex_destroy(&m_mutex);
+}
+
+void AUD_Sequencer::lock()
+{
+ pthread_mutex_lock(&m_mutex);
+}
+
+void AUD_Sequencer::unlock()
+{
+ pthread_mutex_unlock(&m_mutex);
+}
+
+void AUD_Sequencer::setSpecs(AUD_Specs specs)
+{
+ AUD_MutexLock lock(*this);
+
+ m_specs = specs;
+ m_status++;
+}
+
+void AUD_Sequencer::setFPS(float fps)
+{
+ AUD_MutexLock lock(*this);
+
+ m_fps = fps;
+}
+
+void AUD_Sequencer::mute(bool muted)
+{
+ AUD_MutexLock lock(*this);
+
+ m_muted = muted;
+}
+
+bool AUD_Sequencer::getMute() const
+{
+ return m_muted;
+}
+
+float AUD_Sequencer::getSpeedOfSound() const
+{
+ return m_speed_of_sound;
+}
+
+void AUD_Sequencer::setSpeedOfSound(float speed)
+{
+ AUD_MutexLock lock(*this);
+
+ m_speed_of_sound = speed;
+ m_status++;
+}
+
+float AUD_Sequencer::getDopplerFactor() const
+{
+ return m_doppler_factor;
+}
+
+void AUD_Sequencer::setDopplerFactor(float factor)
+{
+ AUD_MutexLock lock(*this);
+
+ m_doppler_factor = factor;
+ m_status++;
+}
+
+AUD_DistanceModel AUD_Sequencer::getDistanceModel() const
+{
+ return m_distance_model;
+}
+
+void AUD_Sequencer::setDistanceModel(AUD_DistanceModel model)
+{
+ AUD_MutexLock lock(*this);
+
+ m_distance_model = model;
+ m_status++;
+}
+
+AUD_AnimateableProperty* AUD_Sequencer::getAnimProperty(AUD_AnimateablePropertyType type)
+{
+ switch(type)
+ {
+ case AUD_AP_VOLUME:
+ return &m_volume;
+ case AUD_AP_LOCATION:
+ return &m_location;
+ case AUD_AP_ORIENTATION:
+ return &m_orientation;
+ default:
+ return NULL;
+ }
+}
+
+boost::shared_ptr<AUD_SequencerEntry> AUD_Sequencer::add(boost::shared_ptr<AUD_IFactory> sound, float begin, float end, float skip)
+{
+ AUD_MutexLock lock(*this);
+
+ boost::shared_ptr<AUD_SequencerEntry> entry = boost::shared_ptr<AUD_SequencerEntry>(new AUD_SequencerEntry(sound, begin, end, skip, m_id++));
+
+ m_entries.push_front(entry);
+ m_entry_status++;
+
+ return entry;
+}
+
+void AUD_Sequencer::remove(boost::shared_ptr<AUD_SequencerEntry> entry)
+{
+ AUD_MutexLock lock(*this);
+
+ m_entries.remove(entry);
+ m_entry_status++;
+}
diff --git a/intern/audaspace/intern/AUD_Sequencer.h b/intern/audaspace/intern/AUD_Sequencer.h
new file mode 100644
index 00000000000..9fdf537ff97
--- /dev/null
+++ b/intern/audaspace/intern/AUD_Sequencer.h
@@ -0,0 +1,206 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * Copyright 2009-2011 Jörg Hermann Müller
+ *
+ * This file is part of AudaSpace.
+ *
+ * Audaspace 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.
+ *
+ * AudaSpace 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 Audaspace; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file audaspace/intern/AUD_Sequencer.h
+ * \ingroup audaspaceintern
+ */
+
+
+#ifndef __AUD_SEQUENCER_H__
+#define __AUD_SEQUENCER_H__
+
+#include "AUD_AnimateableProperty.h"
+#include "AUD_IFactory.h"
+#include "AUD_ILockable.h"
+
+#include <list>
+#include <pthread.h>
+
+class AUD_SequencerEntry;
+
+/**
+ * This class represents sequenced entries to play a sound scene.
+ */
+class AUD_Sequencer : public AUD_ILockable
+{
+ friend class AUD_SequencerReader;
+private:
+ /// The target specification.
+ AUD_Specs m_specs;
+
+ /// The status of the sequence. Changes every time a non-animated parameter changes.
+ int m_status;
+
+ /// The entry status. Changes every time an entry is removed or added.
+ int m_entry_status;
+
+ /// The next unused ID for the entries.
+ int m_id;
+
+ /// The sequenced entries.
+ std::list<boost::shared_ptr<AUD_SequencerEntry> > m_entries;
+
+ /// Whether the whole scene is muted.
+ bool m_muted;
+
+ /// The FPS of the scene.
+ float m_fps;
+
+ /// Speed of Sound.
+ float m_speed_of_sound;
+
+ /// Doppler factor.
+ float m_doppler_factor;
+
+ /// Distance model.
+ AUD_DistanceModel m_distance_model;
+
+ /// The animated volume.
+ AUD_AnimateableProperty m_volume;
+
+ /// The animated listener location.
+ AUD_AnimateableProperty m_location;
+
+ /// The animated listener orientation.
+ AUD_AnimateableProperty m_orientation;
+
+ /// The mutex for locking.
+ pthread_mutex_t m_mutex;
+
+ // hide copy constructor and operator=
+ AUD_Sequencer(const AUD_Sequencer&);
+ AUD_Sequencer& operator=(const AUD_Sequencer&);
+
+public:
+ /**
+ * Creates a new sound scene.
+ * \param specs The output audio data specification.
+ * \param fps The FPS of the scene.
+ * \param muted Whether the whole scene is muted.
+ */
+ AUD_Sequencer(AUD_Specs specs, float fps, bool muted);
+ ~AUD_Sequencer();
+
+ /**
+ * Locks the sequence.
+ */
+ virtual void lock();
+
+ /**
+ * Unlocks the previously locked sequence.
+ */
+ virtual void unlock();
+
+ /**
+ * Sets the audio output specification.
+ * \param specs The new specification.
+ */
+ void setSpecs(AUD_Specs specs);
+
+ /**
+ * Sets the scene's FPS.
+ * \param fps The new FPS.
+ */
+ void setFPS(float fps);
+
+ /**
+ * Sets the muting state of the scene.
+ * \param muted Whether the scene is muted.
+ */
+ void mute(bool muted);
+
+ /**
+ * Retrieves the muting state of the scene.
+ * \return Whether the scene is muted.
+ */
+ bool getMute() const;
+
+ /**
+ * Retrieves the speed of sound.
+ * This value is needed for doppler effect calculation.
+ * \return The speed of sound.
+ */
+ float getSpeedOfSound() const;
+
+ /**
+ * Sets the speed of sound.
+ * This value is needed for doppler effect calculation.
+ * \param speed The new speed of sound.
+ */
+ void setSpeedOfSound(float speed);
+
+ /**
+ * Retrieves the doppler factor.
+ * This value is a scaling factor for the velocity vectors of sources and
+ * listener which is used while calculating the doppler effect.
+ * \return The doppler factor.
+ */
+ float getDopplerFactor() const;
+
+ /**
+ * Sets the doppler factor.
+ * This value is a scaling factor for the velocity vectors of sources and
+ * listener which is used while calculating the doppler effect.
+ * \param factor The new doppler factor.
+ */
+ void setDopplerFactor(float factor);
+
+ /**
+ * Retrieves the distance model.
+ * \return The distance model.
+ */
+ AUD_DistanceModel getDistanceModel() const;
+
+ /**
+ * Sets the distance model.
+ * \param model distance model.
+ */
+ void setDistanceModel(AUD_DistanceModel model);
+
+ /**
+ * Retrieves one of the animated properties of the sequence.
+ * \param type Which animated property to retrieve.
+ * \return A pointer to the animated property, valid as long as the
+ * sequence is.
+ */
+ AUD_AnimateableProperty* getAnimProperty(AUD_AnimateablePropertyType type);
+
+ /**
+ * Adds a new entry to the scene.
+ * \param sound The sound this entry should play.
+ * \param begin The start time.
+ * \param end The end time or a negative value if determined by the sound.
+ * \param skip How much seconds should be skipped at the beginning.
+ * \return The entry added.
+ */
+ boost::shared_ptr<AUD_SequencerEntry> add(boost::shared_ptr<AUD_IFactory> sound, float begin, float end, float skip);
+
+ /**
+ * Removes an entry from the scene.
+ * \param entry The entry to remove.
+ */
+ void remove(boost::shared_ptr<AUD_SequencerEntry> entry);
+};
+
+#endif //__AUD_SEQUENCER_H__
diff --git a/intern/audaspace/intern/AUD_SequencerEntry.cpp b/intern/audaspace/intern/AUD_SequencerEntry.cpp
index 96fd15a0bf8..005557bbed1 100644
--- a/intern/audaspace/intern/AUD_SequencerEntry.cpp
+++ b/intern/audaspace/intern/AUD_SequencerEntry.cpp
@@ -34,7 +34,7 @@
#include <cmath>
#include <limits>
-AUD_SequencerEntry::AUD_SequencerEntry(AUD_Reference<AUD_IFactory> sound, float begin, float end, float skip, int id) :
+AUD_SequencerEntry::AUD_SequencerEntry(boost::shared_ptr<AUD_IFactory> sound, float begin, float end, float skip, int id) :
m_status(0),
m_pos_status(1),
m_sound_status(0),
@@ -86,7 +86,7 @@ void AUD_SequencerEntry::unlock()
pthread_mutex_unlock(&m_mutex);
}
-void AUD_SequencerEntry::setSound(AUD_Reference<AUD_IFactory> sound)
+void AUD_SequencerEntry::setSound(boost::shared_ptr<AUD_IFactory> sound)
{
AUD_MutexLock lock(*this);
diff --git a/intern/audaspace/intern/AUD_SequencerEntry.h b/intern/audaspace/intern/AUD_SequencerEntry.h
index 46efc52d66b..aa1edebfc2f 100644
--- a/intern/audaspace/intern/AUD_SequencerEntry.h
+++ b/intern/audaspace/intern/AUD_SequencerEntry.h
@@ -30,12 +30,12 @@
#ifndef __AUD_SEQUENCERENTRY_H__
#define __AUD_SEQUENCERENTRY_H__
-#include "AUD_Reference.h"
#include "AUD_AnimateableProperty.h"
#include "AUD_IFactory.h"
#include "AUD_ILockable.h"
#include <pthread.h>
+#include <boost/shared_ptr.hpp>
/**
* This class represents a sequenced entry in a sequencer factory.
@@ -57,7 +57,7 @@ private:
int m_id;
/// The sound this entry plays.
- AUD_Reference<AUD_IFactory> m_sound;
+ boost::shared_ptr<AUD_IFactory> m_sound;
/// The begin time.
float m_begin;
@@ -125,7 +125,7 @@ public:
* \param skip How much seconds should be skipped at the beginning.
* \param id The ID of the entry.
*/
- AUD_SequencerEntry(AUD_Reference<AUD_IFactory> sound, float begin, float end, float skip, int id);
+ AUD_SequencerEntry(boost::shared_ptr<AUD_IFactory> sound, float begin, float end, float skip, int id);
virtual ~AUD_SequencerEntry();
/**
@@ -142,7 +142,7 @@ public:
* Sets the sound of the entry.
* \param sound The new sound.
*/
- void setSound(AUD_Reference<AUD_IFactory> sound);
+ void setSound(boost::shared_ptr<AUD_IFactory> sound);
/**
* Moves the entry.
diff --git a/intern/audaspace/intern/AUD_SequencerFactory.cpp b/intern/audaspace/intern/AUD_SequencerFactory.cpp
index 2cc0a656cf1..f6076603c2b 100644
--- a/intern/audaspace/intern/AUD_SequencerFactory.cpp
+++ b/intern/audaspace/intern/AUD_SequencerFactory.cpp
@@ -32,39 +32,12 @@
#include "AUD_3DMath.h"
#include "AUD_MutexLock.h"
-AUD_SequencerFactory::AUD_SequencerFactory(AUD_Specs specs, float fps, bool muted) :
- m_specs(specs),
- m_status(0),
- m_entry_status(0),
- m_id(0),
- m_muted(muted),
- m_fps(fps),
- m_speed_of_sound(434),
- m_doppler_factor(1),
- m_distance_model(AUD_DISTANCE_MODEL_INVERSE_CLAMPED),
- m_location(3),
- m_orientation(4)
+AUD_SequencerFactory::AUD_SequencerFactory(AUD_Specs specs, float fps, bool muted)
{
- AUD_Quaternion q;
- m_orientation.write(q.get());
- float f = 1;
- m_volume.write(&f);
-
- pthread_mutexattr_t attr;
- pthread_mutexattr_init(&attr);
- pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
-
- pthread_mutex_init(&m_mutex, &attr);
-
- pthread_mutexattr_destroy(&attr);
+ m_sequence = boost::shared_ptr<AUD_Sequencer>(new AUD_Sequencer(specs, fps, muted));
}
-AUD_SequencerFactory::~AUD_SequencerFactory()
-{
- pthread_mutex_destroy(&m_mutex);
-}
-
-void AUD_SequencerFactory::lock()
+/*void AUD_SequencerFactory::lock()
{
pthread_mutex_lock(&m_mutex);
}
@@ -72,115 +45,79 @@ void AUD_SequencerFactory::lock()
void AUD_SequencerFactory::unlock()
{
pthread_mutex_unlock(&m_mutex);
-}
+}*/
void AUD_SequencerFactory::setSpecs(AUD_Specs specs)
{
- AUD_MutexLock lock(*this);
-
- m_specs = specs;
- m_status++;
+ m_sequence->setSpecs(specs);
}
void AUD_SequencerFactory::setFPS(float fps)
{
- AUD_MutexLock lock(*this);
-
- m_fps = fps;
+ m_sequence->setFPS(fps);
}
void AUD_SequencerFactory::mute(bool muted)
{
- AUD_MutexLock lock(*this);
-
- m_muted = muted;
+ m_sequence->mute(muted);
}
bool AUD_SequencerFactory::getMute() const
{
- return m_muted;
+ return m_sequence->getMute();
}
float AUD_SequencerFactory::getSpeedOfSound() const
{
- return m_speed_of_sound;
+ return m_sequence->getSpeedOfSound();
}
void AUD_SequencerFactory::setSpeedOfSound(float speed)
{
- AUD_MutexLock lock(*this);
-
- m_speed_of_sound = speed;
- m_status++;
+ m_sequence->setSpeedOfSound(speed);
}
float AUD_SequencerFactory::getDopplerFactor() const
{
- return m_doppler_factor;
+ return m_sequence->getDopplerFactor();
}
void AUD_SequencerFactory::setDopplerFactor(float factor)
{
- AUD_MutexLock lock(*this);
-
- m_doppler_factor = factor;
- m_status++;
+ m_sequence->setDopplerFactor(factor);
}
AUD_DistanceModel AUD_SequencerFactory::getDistanceModel() const
{
- return m_distance_model;
+ return m_sequence->getDistanceModel();
}
void AUD_SequencerFactory::setDistanceModel(AUD_DistanceModel model)
{
- AUD_MutexLock lock(*this);
-
- m_distance_model = model;
- m_status++;
+ m_sequence->setDistanceModel(model);
}
AUD_AnimateableProperty* AUD_SequencerFactory::getAnimProperty(AUD_AnimateablePropertyType type)
{
- switch(type)
- {
- case AUD_AP_VOLUME:
- return &m_volume;
- case AUD_AP_LOCATION:
- return &m_location;
- case AUD_AP_ORIENTATION:
- return &m_orientation;
- default:
- return NULL;
- }
+ return m_sequence->getAnimProperty(type);
}
-AUD_Reference<AUD_SequencerEntry> AUD_SequencerFactory::add(AUD_Reference<AUD_IFactory> sound, float begin, float end, float skip)
+boost::shared_ptr<AUD_SequencerEntry> AUD_SequencerFactory::add(boost::shared_ptr<AUD_IFactory> sound, float begin, float end, float skip)
{
- AUD_MutexLock lock(*this);
-
- AUD_Reference<AUD_SequencerEntry> entry = new AUD_SequencerEntry(sound, begin, end, skip, m_id++);
-
- m_entries.push_front(entry);
- m_entry_status++;
-
- return entry;
+ return m_sequence->add(sound, begin, end, skip);
}
-void AUD_SequencerFactory::remove(AUD_Reference<AUD_SequencerEntry> entry)
+void AUD_SequencerFactory::remove(boost::shared_ptr<AUD_SequencerEntry> entry)
{
- AUD_MutexLock lock(*this);
-
- m_entries.remove(entry);
- m_entry_status++;
+ m_sequence->remove(entry);
}
-AUD_Reference<AUD_IReader> AUD_SequencerFactory::createQualityReader()
+boost::shared_ptr<AUD_IReader> AUD_SequencerFactory::createQualityReader()
{
- return new AUD_SequencerReader(this, true);
+ return boost::shared_ptr<AUD_IReader>(new AUD_SequencerReader(m_sequence, true));
}
-AUD_Reference<AUD_IReader> AUD_SequencerFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_SequencerFactory::createReader()
{
- return new AUD_SequencerReader(this);
+ return boost::shared_ptr<AUD_IReader>(new AUD_SequencerReader(m_sequence));
}
diff --git a/intern/audaspace/intern/AUD_SequencerFactory.h b/intern/audaspace/intern/AUD_SequencerFactory.h
index 38cbc2d1867..3ef847d4b34 100644
--- a/intern/audaspace/intern/AUD_SequencerFactory.h
+++ b/intern/audaspace/intern/AUD_SequencerFactory.h
@@ -32,7 +32,8 @@
#include "AUD_IFactory.h"
#include "AUD_AnimateableProperty.h"
-#include "AUD_ILockable.h"
+//#include "AUD_ILockable.h"
+#include "AUD_Sequencer.h"
#include <list>
#include <pthread.h>
@@ -42,51 +43,12 @@ class AUD_SequencerEntry;
/**
* This factory represents sequenced entries to play a sound scene.
*/
-class AUD_SequencerFactory : public AUD_IFactory, public AUD_ILockable
+class AUD_SequencerFactory : public AUD_IFactory//, public AUD_ILockable
{
friend class AUD_SequencerReader;
private:
- /// The target specification.
- AUD_Specs m_specs;
-
- /// The status of the factory. Changes every time a non-animated parameter changes.
- int m_status;
-
- /// The entry status. Changes every time an entry is removed or added.
- int m_entry_status;
-
- /// The next unused ID for the entries.
- int m_id;
-
- /// The sequenced entries.
- std::list<AUD_Reference<AUD_SequencerEntry> > m_entries;
-
- /// Whether the whole scene is muted.
- bool m_muted;
-
- /// The FPS of the scene.
- float m_fps;
-
- /// Speed of Sound.
- float m_speed_of_sound;
-
- /// Doppler factor.
- float m_doppler_factor;
-
- /// Distance model.
- AUD_DistanceModel m_distance_model;
-
- /// The animated volume.
- AUD_AnimateableProperty m_volume;
-
- /// The animated listener location.
- AUD_AnimateableProperty m_location;
-
- /// The animated listener orientation.
- AUD_AnimateableProperty m_orientation;
-
- /// The mutex for locking.
- pthread_mutex_t m_mutex;
+ /// The sequence.
+ boost::shared_ptr<AUD_Sequencer> m_sequence;
// hide copy constructor and operator=
AUD_SequencerFactory(const AUD_SequencerFactory&);
@@ -100,8 +62,8 @@ public:
* \param muted Whether the whole scene is muted.
*/
AUD_SequencerFactory(AUD_Specs specs, float fps, bool muted);
- ~AUD_SequencerFactory();
+#if 0
/**
* Locks the factory.
*/
@@ -111,6 +73,7 @@ public:
* Unlocks the previously locked factory.
*/
virtual void unlock();
+#endif
/**
* Sets the audio output specification.
@@ -194,21 +157,21 @@ public:
* \param skip How much seconds should be skipped at the beginning.
* \return The entry added.
*/
- AUD_Reference<AUD_SequencerEntry> add(AUD_Reference<AUD_IFactory> sound, float begin, float end, float skip);
+ boost::shared_ptr<AUD_SequencerEntry> add(boost::shared_ptr<AUD_IFactory> sound, float begin, float end, float skip);
/**
* Removes an entry from the scene.
* \param entry The entry to remove.
*/
- void remove(AUD_Reference<AUD_SequencerEntry> entry);
+ void remove(boost::shared_ptr<AUD_SequencerEntry> entry);
/**
* Creates a new reader with high quality resampling.
* \return The new reader.
*/
- AUD_Reference<AUD_IReader> createQualityReader();
+ boost::shared_ptr<AUD_IReader> createQualityReader();
- virtual AUD_Reference<AUD_IReader> createReader();
+ virtual boost::shared_ptr<AUD_IReader> createReader();
};
#endif //__AUD_SEQUENCERFACTORY_H__
diff --git a/intern/audaspace/intern/AUD_SequencerHandle.cpp b/intern/audaspace/intern/AUD_SequencerHandle.cpp
index 38d2ed38a7e..c9473cf274e 100644
--- a/intern/audaspace/intern/AUD_SequencerHandle.cpp
+++ b/intern/audaspace/intern/AUD_SequencerHandle.cpp
@@ -31,17 +31,17 @@
#include "AUD_ReadDevice.h"
#include "AUD_MutexLock.h"
-AUD_SequencerHandle::AUD_SequencerHandle(AUD_Reference<AUD_SequencerEntry> entry, AUD_ReadDevice& device) :
+AUD_SequencerHandle::AUD_SequencerHandle(boost::shared_ptr<AUD_SequencerEntry> entry, AUD_ReadDevice& device) :
m_entry(entry),
m_status(0),
m_pos_status(0),
m_sound_status(0),
m_device(device)
{
- if(!entry->m_sound.isNull())
+ if(entry->m_sound.get())
{
m_handle = device.play(entry->m_sound, true);
- m_3dhandle = AUD_Reference<AUD_I3DHandle>(m_handle);
+ m_3dhandle = boost::dynamic_pointer_cast<AUD_I3DHandle>(m_handle);
}
}
@@ -50,7 +50,7 @@ AUD_SequencerHandle::~AUD_SequencerHandle()
stop();
}
-int AUD_SequencerHandle::compare(AUD_Reference<AUD_SequencerEntry> entry) const
+int AUD_SequencerHandle::compare(boost::shared_ptr<AUD_SequencerEntry> entry) const
{
if(m_entry->getID() < entry->getID())
return -1;
@@ -61,13 +61,13 @@ int AUD_SequencerHandle::compare(AUD_Reference<AUD_SequencerEntry> entry) const
void AUD_SequencerHandle::stop()
{
- if(!m_handle.isNull())
+ if(m_handle.get())
m_handle->stop();
}
void AUD_SequencerHandle::update(float position, float frame, float fps)
{
- if(!m_handle.isNull())
+ if(m_handle.get())
{
AUD_MutexLock lock(*m_entry);
if(position >= m_entry->m_end && m_entry->m_end >= 0)
@@ -77,13 +77,13 @@ void AUD_SequencerHandle::update(float position, float frame, float fps)
if(m_sound_status != m_entry->m_sound_status)
{
- if(!m_handle.isNull())
+ if(m_handle.get())
m_handle->stop();
- if(!m_entry->m_sound.isNull())
+ if(m_entry->m_sound.get())
{
m_handle = m_device.play(m_entry->m_sound, true);
- m_3dhandle = AUD_Reference<AUD_I3DHandle>(m_handle);
+ m_3dhandle = boost::dynamic_pointer_cast<AUD_I3DHandle>(m_handle);
}
m_sound_status = m_entry->m_sound_status;
@@ -140,7 +140,7 @@ void AUD_SequencerHandle::update(float position, float frame, float fps)
void AUD_SequencerHandle::seek(float position)
{
- if(!m_handle.isNull())
+ if(m_handle.get())
{
AUD_MutexLock lock(*m_entry);
if(position >= m_entry->m_end && m_entry->m_end >= 0)
diff --git a/intern/audaspace/intern/AUD_SequencerHandle.h b/intern/audaspace/intern/AUD_SequencerHandle.h
index 72d3240a103..881bbdd43dc 100644
--- a/intern/audaspace/intern/AUD_SequencerHandle.h
+++ b/intern/audaspace/intern/AUD_SequencerHandle.h
@@ -43,13 +43,13 @@ class AUD_SequencerHandle
{
private:
/// The entry this handle belongs to.
- AUD_Reference<AUD_SequencerEntry> m_entry;
+ boost::shared_ptr<AUD_SequencerEntry> m_entry;
/// The handle in the read device.
- AUD_Reference<AUD_IHandle> m_handle;
+ boost::shared_ptr<AUD_IHandle> m_handle;
/// The 3D handle in the read device.
- AUD_Reference<AUD_I3DHandle> m_3dhandle;
+ boost::shared_ptr<AUD_I3DHandle> m_3dhandle;
/// The last read status from the entry.
int m_status;
@@ -69,7 +69,7 @@ public:
* \param entry The entry this handle plays.
* \param device The read device to play on.
*/
- AUD_SequencerHandle(AUD_Reference<AUD_SequencerEntry> entry, AUD_ReadDevice& device);
+ AUD_SequencerHandle(boost::shared_ptr<AUD_SequencerEntry> entry, AUD_ReadDevice& device);
/**
* Destroys the handle.
@@ -81,7 +81,7 @@ public:
* \param entry The entry to compare to.
* \return Whether the entries ID is smaller, equal or bigger.
*/
- int compare(AUD_Reference<AUD_SequencerEntry> entry) const;
+ int compare(boost::shared_ptr<AUD_SequencerEntry> entry) const;
/**
* Stops playing back the handle.
diff --git a/intern/audaspace/intern/AUD_SequencerReader.cpp b/intern/audaspace/intern/AUD_SequencerReader.cpp
index 39a4d29e6e4..d5e14590df5 100644
--- a/intern/audaspace/intern/AUD_SequencerReader.cpp
+++ b/intern/audaspace/intern/AUD_SequencerReader.cpp
@@ -30,11 +30,11 @@
#include "AUD_SequencerReader.h"
#include "AUD_MutexLock.h"
-typedef std::list<AUD_Reference<AUD_SequencerHandle> >::iterator AUD_HandleIterator;
-typedef std::list<AUD_Reference<AUD_SequencerEntry> >::iterator AUD_EntryIterator;
+typedef std::list<boost::shared_ptr<AUD_SequencerHandle> >::iterator AUD_HandleIterator;
+typedef std::list<boost::shared_ptr<AUD_SequencerEntry> >::iterator AUD_EntryIterator;
-AUD_SequencerReader::AUD_SequencerReader(AUD_Reference<AUD_SequencerFactory> factory, bool quality) :
- m_position(0), m_device(factory->m_specs), m_factory(factory), m_status(0), m_entry_status(0)
+AUD_SequencerReader::AUD_SequencerReader(boost::shared_ptr<AUD_Sequencer> sequence, bool quality) :
+ m_position(0), m_device(sequence->m_specs), m_sequence(sequence), m_status(0), m_entry_status(0)
{
m_device.setQuality(quality);
}
@@ -57,7 +57,7 @@ void AUD_SequencerReader::seek(int position)
for(AUD_HandleIterator it = m_handles.begin(); it != m_handles.end(); it++)
{
- (*it)->seek(position / m_factory->m_specs.rate);
+ (*it)->seek(position / m_sequence->m_specs.rate);
}
}
@@ -73,37 +73,37 @@ int AUD_SequencerReader::getPosition() const
AUD_Specs AUD_SequencerReader::getSpecs() const
{
- return m_factory->m_specs;
+ return m_sequence->m_specs;
}
void AUD_SequencerReader::read(int& length, bool& eos, sample_t* buffer)
{
- AUD_MutexLock lock(*m_factory);
+ AUD_MutexLock lock(*m_sequence);
- if(m_factory->m_status != m_status)
+ if(m_sequence->m_status != m_status)
{
- m_device.changeSpecs(m_factory->m_specs);
- m_device.setSpeedOfSound(m_factory->m_speed_of_sound);
- m_device.setDistanceModel(m_factory->m_distance_model);
- m_device.setDopplerFactor(m_factory->m_doppler_factor);
+ m_device.changeSpecs(m_sequence->m_specs);
+ m_device.setSpeedOfSound(m_sequence->m_speed_of_sound);
+ m_device.setDistanceModel(m_sequence->m_distance_model);
+ m_device.setDopplerFactor(m_sequence->m_doppler_factor);
- m_status = m_factory->m_status;
+ m_status = m_sequence->m_status;
}
- if(m_factory->m_entry_status != m_entry_status)
+ if(m_sequence->m_entry_status != m_entry_status)
{
- std::list<AUD_Reference<AUD_SequencerHandle> > handles;
+ std::list<boost::shared_ptr<AUD_SequencerHandle> > handles;
AUD_HandleIterator hit = m_handles.begin();
- AUD_EntryIterator eit = m_factory->m_entries.begin();
+ AUD_EntryIterator eit = m_sequence->m_entries.begin();
int result;
- AUD_Reference<AUD_SequencerHandle> handle;
+ boost::shared_ptr<AUD_SequencerHandle> handle;
- while(hit != m_handles.end() && eit != m_factory->m_entries.end())
+ while(hit != m_handles.end() && eit != m_sequence->m_entries.end())
{
handle = *hit;
- AUD_Reference<AUD_SequencerEntry> entry = *eit;
+ boost::shared_ptr<AUD_SequencerEntry> entry = *eit;
result = handle->compare(entry);
@@ -111,7 +111,7 @@ void AUD_SequencerReader::read(int& length, bool& eos, sample_t* buffer)
{
try
{
- handle = new AUD_SequencerHandle(entry, m_device);
+ handle = boost::shared_ptr<AUD_SequencerHandle>(new AUD_SequencerHandle(entry, m_device));
handles.push_front(handle);
}
catch(AUD_Exception&)
@@ -138,11 +138,11 @@ void AUD_SequencerReader::read(int& length, bool& eos, sample_t* buffer)
hit++;
}
- while(eit != m_factory->m_entries.end())
+ while(eit != m_sequence->m_entries.end())
{
try
{
- handle = new AUD_SequencerHandle(*eit, m_device);
+ handle = boost::shared_ptr<AUD_SequencerHandle>(new AUD_SequencerHandle(*eit, m_device));
handles.push_front(handle);
}
catch(AUD_Exception&)
@@ -153,10 +153,10 @@ void AUD_SequencerReader::read(int& length, bool& eos, sample_t* buffer)
m_handles = handles;
- m_entry_status = m_factory->m_entry_status;
+ m_entry_status = m_sequence->m_entry_status;
}
- AUD_Specs specs = m_factory->m_specs;
+ AUD_Specs specs = m_sequence->m_specs;
int pos = 0;
float time = float(m_position) / float(specs.rate);
float volume, frame;
@@ -167,30 +167,30 @@ void AUD_SequencerReader::read(int& length, bool& eos, sample_t* buffer)
while(pos < length)
{
- frame = time * m_factory->m_fps;
+ frame = time * m_sequence->m_fps;
cfra = int(floor(frame));
- len = int(ceil((cfra + 1) / m_factory->m_fps * specs.rate)) - m_position;
+ len = int(ceil((cfra + 1) / m_sequence->m_fps * specs.rate)) - m_position;
len = AUD_MIN(length - pos, len);
len = AUD_MAX(len, 1);
for(AUD_HandleIterator it = m_handles.begin(); it != m_handles.end(); it++)
{
- (*it)->update(time, frame, m_factory->m_fps);
+ (*it)->update(time, frame, m_sequence->m_fps);
}
- m_factory->m_volume.read(frame, &volume);
- if(m_factory->m_muted)
+ m_sequence->m_volume.read(frame, &volume);
+ if(m_sequence->m_muted)
volume = 0.0f;
m_device.setVolume(volume);
- m_factory->m_orientation.read(frame, q.get());
+ m_sequence->m_orientation.read(frame, q.get());
m_device.setListenerOrientation(q);
- m_factory->m_location.read(frame, v.get());
+ m_sequence->m_location.read(frame, v.get());
m_device.setListenerLocation(v);
- m_factory->m_location.read(frame + 1, v2.get());
+ m_sequence->m_location.read(frame + 1, v2.get());
v2 -= v;
- m_device.setListenerVelocity(v2 * m_factory->m_fps);
+ m_device.setListenerVelocity(v2 * m_sequence->m_fps);
m_device.read(reinterpret_cast<data_t*>(buffer + specs.channels * pos), len);
diff --git a/intern/audaspace/intern/AUD_SequencerReader.h b/intern/audaspace/intern/AUD_SequencerReader.h
index b3c3a3ea7a6..6b3dbc9313e 100644
--- a/intern/audaspace/intern/AUD_SequencerReader.h
+++ b/intern/audaspace/intern/AUD_SequencerReader.h
@@ -32,7 +32,7 @@
#include "AUD_IReader.h"
#include "AUD_ReadDevice.h"
-#include "AUD_SequencerFactory.h"
+#include "AUD_Sequencer.h"
#include "AUD_SequencerHandle.h"
/**
@@ -52,22 +52,22 @@ private:
AUD_ReadDevice m_device;
/**
- * Saves the SequencerFactory the reader belongs to.
+ * Saves the sequence the reader belongs to.
*/
- AUD_Reference<AUD_SequencerFactory> m_factory;
+ boost::shared_ptr<AUD_Sequencer> m_sequence;
/**
* The list of playback handles for the entries.
*/
- std::list<AUD_Reference<AUD_SequencerHandle> > m_handles;
+ std::list<boost::shared_ptr<AUD_SequencerHandle> > m_handles;
/**
- * Last status read from the factory.
+ * Last status read from the sequence.
*/
int m_status;
/**
- * Last entry status read from the factory.
+ * Last entry status read from the sequence.
*/
int m_entry_status;
@@ -81,7 +81,7 @@ public:
* \param reader The reader to mix.
* \param specs The target specification.
*/
- AUD_SequencerReader(AUD_Reference<AUD_SequencerFactory> factory, bool quality = false);
+ AUD_SequencerReader(boost::shared_ptr<AUD_Sequencer> sequence, bool quality = false);
/**
* Destroys the reader.
diff --git a/intern/audaspace/intern/AUD_SilenceFactory.cpp b/intern/audaspace/intern/AUD_SilenceFactory.cpp
index 0ba553f1c02..85034b316ca 100644
--- a/intern/audaspace/intern/AUD_SilenceFactory.cpp
+++ b/intern/audaspace/intern/AUD_SilenceFactory.cpp
@@ -35,7 +35,7 @@ AUD_SilenceFactory::AUD_SilenceFactory()
{
}
-AUD_Reference<AUD_IReader> AUD_SilenceFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_SilenceFactory::createReader()
{
- return new AUD_SilenceReader();
+ return boost::shared_ptr<AUD_IReader>(new AUD_SilenceReader());
}
diff --git a/intern/audaspace/intern/AUD_SilenceFactory.h b/intern/audaspace/intern/AUD_SilenceFactory.h
index 3bc7fc067ed..de62a2f94fc 100644
--- a/intern/audaspace/intern/AUD_SilenceFactory.h
+++ b/intern/audaspace/intern/AUD_SilenceFactory.h
@@ -48,7 +48,7 @@ public:
*/
AUD_SilenceFactory();
- virtual AUD_Reference<AUD_IReader> createReader();
+ virtual boost::shared_ptr<AUD_IReader> createReader();
};
#endif //__AUD_SILENCEFACTORY_H__
diff --git a/intern/audaspace/intern/AUD_SinusFactory.cpp b/intern/audaspace/intern/AUD_SinusFactory.cpp
index 3ef6a11de5b..2b9742cc90c 100644
--- a/intern/audaspace/intern/AUD_SinusFactory.cpp
+++ b/intern/audaspace/intern/AUD_SinusFactory.cpp
@@ -42,7 +42,7 @@ float AUD_SinusFactory::getFrequency() const
return m_frequency;
}
-AUD_Reference<AUD_IReader> AUD_SinusFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_SinusFactory::createReader()
{
- return new AUD_SinusReader(m_frequency, m_sampleRate);
+ return boost::shared_ptr<AUD_IReader>(new AUD_SinusReader(m_frequency, m_sampleRate));
}
diff --git a/intern/audaspace/intern/AUD_SinusFactory.h b/intern/audaspace/intern/AUD_SinusFactory.h
index d83323c6635..d1909dedb66 100644
--- a/intern/audaspace/intern/AUD_SinusFactory.h
+++ b/intern/audaspace/intern/AUD_SinusFactory.h
@@ -66,7 +66,7 @@ public:
*/
float getFrequency() const;
- virtual AUD_Reference<AUD_IReader> createReader();
+ virtual boost::shared_ptr<AUD_IReader> createReader();
};
#endif //__AUD_SINUSFACTORY_H__
diff --git a/intern/audaspace/intern/AUD_SoftwareDevice.cpp b/intern/audaspace/intern/AUD_SoftwareDevice.cpp
index 1fbd0ad82d2..a7e5b25664b 100644
--- a/intern/audaspace/intern/AUD_SoftwareDevice.cpp
+++ b/intern/audaspace/intern/AUD_SoftwareDevice.cpp
@@ -57,7 +57,7 @@ typedef enum
/********************** AUD_SoftwareHandle Handle Code ************************/
/******************************************************************************/
-AUD_SoftwareDevice::AUD_SoftwareHandle::AUD_SoftwareHandle(AUD_SoftwareDevice* device, AUD_Reference<AUD_IReader> reader, AUD_Reference<AUD_PitchReader> pitch, AUD_Reference<AUD_ResampleReader> resampler, AUD_Reference<AUD_ChannelMapperReader> mapper, bool keep) :
+AUD_SoftwareDevice::AUD_SoftwareHandle::AUD_SoftwareHandle(AUD_SoftwareDevice* device, boost::shared_ptr<AUD_IReader> reader, boost::shared_ptr<AUD_PitchReader> pitch, boost::shared_ptr<AUD_ResampleReader> resampler, boost::shared_ptr<AUD_ChannelMapperReader> mapper, bool keep) :
m_reader(reader), m_pitch(pitch), m_resampler(resampler), m_mapper(mapper), m_keep(keep), m_user_pitch(1.0f), m_user_volume(1.0f), m_user_pan(0.0f), m_volume(1.0f), m_loopcount(0),
m_relative(true), m_volume_max(1.0f), m_volume_min(0), m_distance_max(std::numeric_limits<float>::max()),
m_distance_reference(1.0f), m_attenuation(1.0f), m_cone_angle_outer(M_PI), m_cone_angle_inner(M_PI), m_cone_volume_outer(0),
@@ -231,14 +231,23 @@ bool AUD_SoftwareDevice::AUD_SoftwareHandle::pause()
if(m_status == AUD_STATUS_PLAYING)
{
- m_device->m_playingSounds.remove(this);
- m_device->m_pausedSounds.push_back(this);
+ for(AUD_HandleIterator it = m_device->m_playingSounds.begin(); it != m_device->m_playingSounds.end(); it++)
+ {
+ if(it->get() == this)
+ {
+ boost::shared_ptr<AUD_SoftwareHandle> This = *it;
- if(m_device->m_playingSounds.empty())
- m_device->playing(m_device->m_playback = false);
- m_status = AUD_STATUS_PAUSED;
+ m_device->m_playingSounds.erase(it);
+ m_device->m_pausedSounds.push_back(This);
- return true;
+ if(m_device->m_playingSounds.empty())
+ m_device->playing(m_device->m_playback = false);
+
+ m_status = AUD_STATUS_PAUSED;
+
+ return true;
+ }
+ }
}
}
@@ -253,13 +262,23 @@ bool AUD_SoftwareDevice::AUD_SoftwareHandle::resume()
if(m_status == AUD_STATUS_PAUSED)
{
- m_device->m_pausedSounds.remove(this);
- m_device->m_playingSounds.push_back(this);
+ for(AUD_HandleIterator it = m_device->m_pausedSounds.begin(); it != m_device->m_pausedSounds.end(); it++)
+ {
+ if(it->get() == this)
+ {
+ boost::shared_ptr<AUD_SoftwareHandle> This = *it;
- if(!m_device->m_playback)
- m_device->playing(m_device->m_playback = true);
- m_status = AUD_STATUS_PLAYING;
- return true;
+ m_device->m_pausedSounds.erase(it);
+
+ m_device->m_playingSounds.push_back(This);
+
+ if(!m_device->m_playback)
+ m_device->playing(m_device->m_playback = true);
+ m_status = AUD_STATUS_PLAYING;
+
+ return true;
+ }
+ }
}
}
@@ -283,7 +302,7 @@ bool AUD_SoftwareDevice::AUD_SoftwareHandle::stop()
{
if(it->get() == this)
{
- AUD_Reference<AUD_SoftwareHandle> This = *it;
+ boost::shared_ptr<AUD_SoftwareHandle> This = *it;
m_device->m_playingSounds.erase(it);
@@ -670,7 +689,7 @@ void AUD_SoftwareDevice::create()
{
m_playback = false;
m_volume = 1.0f;
- m_mixer = new AUD_Mixer(m_specs);
+ m_mixer = boost::shared_ptr<AUD_Mixer>(new AUD_Mixer(m_specs));
m_speed_of_sound = 343.0f;
m_doppler_factor = 1.0f;
m_distance_model = AUD_DISTANCE_MODEL_INVERSE_CLAMPED;
@@ -707,12 +726,12 @@ void AUD_SoftwareDevice::mix(data_t* buffer, int length)
AUD_MutexLock lock(*this);
{
- AUD_Reference<AUD_SoftwareDevice::AUD_SoftwareHandle> sound;
+ boost::shared_ptr<AUD_SoftwareDevice::AUD_SoftwareHandle> sound;
int len;
int pos;
bool eos;
- std::list<AUD_Reference<AUD_SoftwareDevice::AUD_SoftwareHandle> > stopSounds;
- std::list<AUD_Reference<AUD_SoftwareDevice::AUD_SoftwareHandle> > pauseSounds;
+ std::list<boost::shared_ptr<AUD_SoftwareDevice::AUD_SoftwareHandle> > stopSounds;
+ std::list<boost::shared_ptr<AUD_SoftwareDevice::AUD_SoftwareHandle> > pauseSounds;
sample_t* buf = m_buffer.getBuffer();
m_mixer->clear(length);
@@ -817,32 +836,32 @@ AUD_DeviceSpecs AUD_SoftwareDevice::getSpecs() const
return m_specs;
}
-AUD_Reference<AUD_IHandle> AUD_SoftwareDevice::play(AUD_Reference<AUD_IReader> reader, bool keep)
+boost::shared_ptr<AUD_IHandle> AUD_SoftwareDevice::play(boost::shared_ptr<AUD_IReader> reader, bool keep)
{
// prepare the reader
// pitch
- AUD_Reference<AUD_PitchReader> pitch = new AUD_PitchReader(reader, 1);
- reader = AUD_Reference<AUD_IReader>(pitch);
+ boost::shared_ptr<AUD_PitchReader> pitch = boost::shared_ptr<AUD_PitchReader>(new AUD_PitchReader(reader, 1));
+ reader = boost::shared_ptr<AUD_IReader>(pitch);
- AUD_Reference<AUD_ResampleReader> resampler;
+ boost::shared_ptr<AUD_ResampleReader> resampler;
// resample
if(m_quality)
- resampler = new AUD_JOSResampleReader(reader, m_specs.specs);
+ resampler = boost::shared_ptr<AUD_ResampleReader>(new AUD_JOSResampleReader(reader, m_specs.specs));
else
- resampler = new AUD_LinearResampleReader(reader, m_specs.specs);
- reader = AUD_Reference<AUD_IReader>(resampler);
+ resampler = boost::shared_ptr<AUD_ResampleReader>(new AUD_LinearResampleReader(reader, m_specs.specs));
+ reader = boost::shared_ptr<AUD_IReader>(resampler);
// rechannel
- AUD_Reference<AUD_ChannelMapperReader> mapper = new AUD_ChannelMapperReader(reader, m_specs.channels);
- reader = AUD_Reference<AUD_IReader>(mapper);
+ boost::shared_ptr<AUD_ChannelMapperReader> mapper = boost::shared_ptr<AUD_ChannelMapperReader>(new AUD_ChannelMapperReader(reader, m_specs.channels));
+ reader = boost::shared_ptr<AUD_IReader>(mapper);
- if(reader.isNull())
- return AUD_Reference<AUD_IHandle>();
+ if(!reader.get())
+ return boost::shared_ptr<AUD_IHandle>();
// play sound
- AUD_Reference<AUD_SoftwareDevice::AUD_SoftwareHandle> sound = new AUD_SoftwareDevice::AUD_SoftwareHandle(this, reader, pitch, resampler, mapper, keep);
+ boost::shared_ptr<AUD_SoftwareDevice::AUD_SoftwareHandle> sound = boost::shared_ptr<AUD_SoftwareDevice::AUD_SoftwareHandle>(new AUD_SoftwareDevice::AUD_SoftwareHandle(this, reader, pitch, resampler, mapper, keep));
AUD_MutexLock lock(*this);
@@ -851,10 +870,10 @@ AUD_Reference<AUD_IHandle> AUD_SoftwareDevice::play(AUD_Reference<AUD_IReader> r
if(!m_playback)
playing(m_playback = true);
- return AUD_Reference<AUD_IHandle>(sound);
+ return boost::shared_ptr<AUD_IHandle>(sound);
}
-AUD_Reference<AUD_IHandle> AUD_SoftwareDevice::play(AUD_Reference<AUD_IFactory> factory, bool keep)
+boost::shared_ptr<AUD_IHandle> AUD_SoftwareDevice::play(boost::shared_ptr<AUD_IFactory> factory, bool keep)
{
return play(factory->createReader(), keep);
}
diff --git a/intern/audaspace/intern/AUD_SoftwareDevice.h b/intern/audaspace/intern/AUD_SoftwareDevice.h
index c429508b622..8675a5ce2b8 100644
--- a/intern/audaspace/intern/AUD_SoftwareDevice.h
+++ b/intern/audaspace/intern/AUD_SoftwareDevice.h
@@ -59,16 +59,16 @@ protected:
{
public:
/// The reader source.
- AUD_Reference<AUD_IReader> m_reader;
+ boost::shared_ptr<AUD_IReader> m_reader;
/// The pitch reader in between.
- AUD_Reference<AUD_PitchReader> m_pitch;
+ boost::shared_ptr<AUD_PitchReader> m_pitch;
/// The resample reader in between.
- AUD_Reference<AUD_ResampleReader> m_resampler;
+ boost::shared_ptr<AUD_ResampleReader> m_resampler;
/// The channel mapper reader in between.
- AUD_Reference<AUD_ChannelMapperReader> m_mapper;
+ boost::shared_ptr<AUD_ChannelMapperReader> m_mapper;
/// Whether to keep the source if end of it is reached.
bool m_keep;
@@ -150,7 +150,7 @@ protected:
* \param mapper The channel mapping reader.
* \param keep Whether to keep the handle when the sound ends.
*/
- AUD_SoftwareHandle(AUD_SoftwareDevice* device, AUD_Reference<AUD_IReader> reader, AUD_Reference<AUD_PitchReader> pitch, AUD_Reference<AUD_ResampleReader> resampler, AUD_Reference<AUD_ChannelMapperReader> mapper, bool keep);
+ AUD_SoftwareHandle(AUD_SoftwareDevice* device, boost::shared_ptr<AUD_IReader> reader, boost::shared_ptr<AUD_PitchReader> pitch, boost::shared_ptr<AUD_ResampleReader> resampler, boost::shared_ptr<AUD_ChannelMapperReader> mapper, bool keep);
/**
* Updates the handle's playback parameters.
@@ -206,7 +206,7 @@ protected:
virtual bool setConeVolumeOuter(float volume);
};
- typedef std::list<AUD_Reference<AUD_SoftwareHandle> >::iterator AUD_HandleIterator;
+ typedef std::list<boost::shared_ptr<AUD_SoftwareHandle> >::iterator AUD_HandleIterator;
/**
* The specification of the device.
@@ -216,7 +216,7 @@ protected:
/**
* The mixer.
*/
- AUD_Reference<AUD_Mixer> m_mixer;
+ boost::shared_ptr<AUD_Mixer> m_mixer;
/**
* Whether to do high or low quality resampling.
@@ -261,12 +261,12 @@ private:
/**
* The list of sounds that are currently playing.
*/
- std::list<AUD_Reference<AUD_SoftwareHandle> > m_playingSounds;
+ std::list<boost::shared_ptr<AUD_SoftwareHandle> > m_playingSounds;
/**
* The list of sounds that are currently paused.
*/
- std::list<AUD_Reference<AUD_SoftwareHandle> > m_pausedSounds;
+ std::list<boost::shared_ptr<AUD_SoftwareHandle> > m_pausedSounds;
/**
* Whether there is currently playback.
@@ -320,8 +320,8 @@ public:
void setQuality(bool quality);
virtual AUD_DeviceSpecs getSpecs() const;
- virtual AUD_Reference<AUD_IHandle> play(AUD_Reference<AUD_IReader> reader, bool keep = false);
- virtual AUD_Reference<AUD_IHandle> play(AUD_Reference<AUD_IFactory> factory, bool keep = false);
+ virtual boost::shared_ptr<AUD_IHandle> play(boost::shared_ptr<AUD_IReader> reader, bool keep = false);
+ virtual boost::shared_ptr<AUD_IHandle> play(boost::shared_ptr<AUD_IFactory> factory, bool keep = false);
virtual void stopAll();
virtual void lock();
virtual void unlock();
diff --git a/intern/audaspace/intern/AUD_StreamBufferFactory.cpp b/intern/audaspace/intern/AUD_StreamBufferFactory.cpp
index 1c8d2a99351..daa714aeec3 100644
--- a/intern/audaspace/intern/AUD_StreamBufferFactory.cpp
+++ b/intern/audaspace/intern/AUD_StreamBufferFactory.cpp
@@ -33,10 +33,10 @@
#include <cstring>
-AUD_StreamBufferFactory::AUD_StreamBufferFactory(AUD_Reference<AUD_IFactory> factory) :
+AUD_StreamBufferFactory::AUD_StreamBufferFactory(boost::shared_ptr<AUD_IFactory> factory) :
m_buffer(new AUD_Buffer())
{
- AUD_Reference<AUD_IReader> reader = factory->createReader();
+ boost::shared_ptr<AUD_IReader> reader = factory->createReader();
m_specs = reader->getSpecs();
@@ -70,7 +70,7 @@ AUD_StreamBufferFactory::AUD_StreamBufferFactory(AUD_Reference<AUD_IFactory> fac
m_buffer->resize(index * sample_size, true);
}
-AUD_Reference<AUD_IReader> AUD_StreamBufferFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_StreamBufferFactory::createReader()
{
- return new AUD_BufferReader(m_buffer, m_specs);
+ return boost::shared_ptr<AUD_IReader>(new AUD_BufferReader(m_buffer, m_specs));
}
diff --git a/intern/audaspace/intern/AUD_StreamBufferFactory.h b/intern/audaspace/intern/AUD_StreamBufferFactory.h
index 99795d95d33..1bcd73d59b6 100644
--- a/intern/audaspace/intern/AUD_StreamBufferFactory.h
+++ b/intern/audaspace/intern/AUD_StreamBufferFactory.h
@@ -31,9 +31,10 @@
#define __AUD_STREAMBUFFERFACTORY_H__
#include "AUD_IFactory.h"
-#include "AUD_Reference.h"
#include "AUD_Buffer.h"
+#include <boost/shared_ptr.hpp>
+
/**
* This factory creates a buffer out of a reader. This way normally streamed
* sound sources can be loaded into memory for buffered playback.
@@ -44,7 +45,7 @@ private:
/**
* The buffer that holds the audio data.
*/
- AUD_Reference<AUD_Buffer> m_buffer;
+ boost::shared_ptr<AUD_Buffer> m_buffer;
/**
* The specification of the samples.
@@ -62,9 +63,9 @@ public:
* \param factory The factory that creates the reader for buffering.
* \exception AUD_Exception Thrown if the reader cannot be created.
*/
- AUD_StreamBufferFactory(AUD_Reference<AUD_IFactory> factory);
+ AUD_StreamBufferFactory(boost::shared_ptr<AUD_IFactory> factory);
- virtual AUD_Reference<AUD_IReader> createReader();
+ virtual boost::shared_ptr<AUD_IReader> createReader();
};
#endif //__AUD_STREAMBUFFERFACTORY_H__
diff --git a/intern/audaspace/sndfile/AUD_SndFileFactory.cpp b/intern/audaspace/sndfile/AUD_SndFileFactory.cpp
index 1fc77fbde66..106b2937a06 100644
--- a/intern/audaspace/sndfile/AUD_SndFileFactory.cpp
+++ b/intern/audaspace/sndfile/AUD_SndFileFactory.cpp
@@ -43,10 +43,10 @@ AUD_SndFileFactory::AUD_SndFileFactory(const data_t* buffer, int size) :
memcpy(m_buffer->getBuffer(), buffer, size);
}
-AUD_Reference<AUD_IReader> AUD_SndFileFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_SndFileFactory::createReader()
{
- if(m_buffer.isNull())
- return new AUD_SndFileReader(m_filename);
+ if(m_buffer.get())
+ return boost::shared_ptr<AUD_IReader>(new AUD_SndFileReader(m_buffer));
else
- return new AUD_SndFileReader(m_buffer);
+ return boost::shared_ptr<AUD_IReader>(new AUD_SndFileReader(m_filename));
}
diff --git a/intern/audaspace/sndfile/AUD_SndFileFactory.h b/intern/audaspace/sndfile/AUD_SndFileFactory.h
index 7039c7a2615..bc96325d6eb 100644
--- a/intern/audaspace/sndfile/AUD_SndFileFactory.h
+++ b/intern/audaspace/sndfile/AUD_SndFileFactory.h
@@ -31,10 +31,10 @@
#define __AUD_SNDFILEFACTORY_H__
#include "AUD_IFactory.h"
-#include "AUD_Reference.h"
#include "AUD_Buffer.h"
#include <string>
+#include <boost/shared_ptr.hpp>
/**
* This factory reads a sound file via libsndfile.
@@ -50,7 +50,7 @@ private:
/**
* The buffer to read from.
*/
- AUD_Reference<AUD_Buffer> m_buffer;
+ boost::shared_ptr<AUD_Buffer> m_buffer;
// hide copy constructor and operator=
AUD_SndFileFactory(const AUD_SndFileFactory&);
@@ -70,7 +70,7 @@ public:
*/
AUD_SndFileFactory(const data_t* buffer, int size);
- virtual AUD_Reference<AUD_IReader> createReader();
+ virtual boost::shared_ptr<AUD_IReader> createReader();
};
#endif //__AUD_SNDFILEFACTORY_H__
diff --git a/intern/audaspace/sndfile/AUD_SndFileReader.cpp b/intern/audaspace/sndfile/AUD_SndFileReader.cpp
index 8dbb43cb17e..aaee814f56b 100644
--- a/intern/audaspace/sndfile/AUD_SndFileReader.cpp
+++ b/intern/audaspace/sndfile/AUD_SndFileReader.cpp
@@ -100,7 +100,7 @@ AUD_SndFileReader::AUD_SndFileReader(std::string filename) :
m_seekable = sfinfo.seekable;
}
-AUD_SndFileReader::AUD_SndFileReader(AUD_Reference<AUD_Buffer> buffer) :
+AUD_SndFileReader::AUD_SndFileReader(boost::shared_ptr<AUD_Buffer> buffer) :
m_position(0),
m_membuffer(buffer),
m_memoffset(0)
diff --git a/intern/audaspace/sndfile/AUD_SndFileReader.h b/intern/audaspace/sndfile/AUD_SndFileReader.h
index 81d8b45120c..5cac5051ee2 100644
--- a/intern/audaspace/sndfile/AUD_SndFileReader.h
+++ b/intern/audaspace/sndfile/AUD_SndFileReader.h
@@ -31,11 +31,11 @@
#define __AUD_SNDFILEREADER_H__
#include "AUD_IReader.h"
-#include "AUD_Reference.h"
#include "AUD_Buffer.h"
#include <string>
#include <sndfile.h>
+#include <boost/shared_ptr.hpp>
typedef sf_count_t (*sf_read_f)(SNDFILE *sndfile, void *ptr, sf_count_t frames);
@@ -78,7 +78,7 @@ private:
/**
* The pointer to the memory file.
*/
- AUD_Reference<AUD_Buffer> m_membuffer;
+ boost::shared_ptr<AUD_Buffer> m_membuffer;
/**
* The current reading pointer of the memory file.
@@ -110,7 +110,7 @@ public:
* \exception AUD_Exception Thrown if the buffer specified cannot be read
* with libsndfile.
*/
- AUD_SndFileReader(AUD_Reference<AUD_Buffer> buffer);
+ AUD_SndFileReader(boost::shared_ptr<AUD_Buffer> buffer);
/**
* Destroys the reader and closes the file.
diff --git a/intern/bsp/intern/BOP_CarveInterface.cpp b/intern/bsp/intern/BOP_CarveInterface.cpp
index 49c999a1dd4..bb3a783548c 100644
--- a/intern/bsp/intern/BOP_CarveInterface.cpp
+++ b/intern/bsp/intern/BOP_CarveInterface.cpp
@@ -205,7 +205,7 @@ static void Carve_getIntersectedOperandMeshes(std::vector<MeshSet<3>::mesh_t*> &
std::vector<MeshSet<3>::mesh_t*>::iterator it = meshes.begin();
std::vector< RTreeNode<3, Face<3> *> *> meshRTree;
- while(it != meshes.end()) {
+ while (it != meshes.end()) {
MeshSet<3>::mesh_t *mesh = *it;
bool isAdded = false;
@@ -279,7 +279,7 @@ static MeshSet<3> *Carve_unionIntersectingMeshes(MeshSet<3> *poly,
return poly;
}
- while(orig_meshes.size()) {
+ while (orig_meshes.size()) {
MeshSet<3> *right = Carve_getIntersectedOperand(orig_meshes, otherAABB);
if (!right) {
@@ -559,8 +559,6 @@ static bool Carve_checkDegeneratedFace(std::map<MeshSet<3>::vertex_t*, uint> *ve
if (v1 == v2 || v2 == v3 || v1 == v3)
return true;
-
- return triangleArea(face->edge->prev->vert->v, face->edge->vert->v, face->edge->next->vert->v) < DBL_EPSILON;
}
else if (face->n_edges == 4) {
uint v1, v2, v3, v4;
@@ -572,9 +570,6 @@ static bool Carve_checkDegeneratedFace(std::map<MeshSet<3>::vertex_t*, uint> *ve
if (v1 == v2 || v1 == v3 || v1 == v4 || v2 == v3 || v2 == v4 || v3 == v4)
return true;
-
- return triangleArea(face->edge->vert->v, face->edge->next->vert->v, face->edge->next->next->vert->v) +
- triangleArea(face->edge->prev->vert->v, face->edge->vert->v, face->edge->next->next->vert->v) < DBL_EPSILON;
}
return false;
diff --git a/intern/cycles/blender/addon/enums.py b/intern/cycles/blender/addon/enums.py
index e63e1e84245..a98a6aab4c4 100644
--- a/intern/cycles/blender/addon/enums.py
+++ b/intern/cycles/blender/addon/enums.py
@@ -57,7 +57,8 @@ aperture_types = (
panorama_types = (
('EQUIRECTANGULAR', "Equirectangular", "Render the scene with a spherical camera, also known as Lat Long panorama"),
- ('FISHEYE_EQUIDISTANT', "Fisheye Equidistant", "Ideal for fulldomes, ignore the sensor dimensions"),
- ('FISHEYE_EQUISOLID', "Fisheye Equisolid", "Similar to most fisheye modern lens, take sensor dimensions into consideration"),
+ ('FISHEYE_EQUIDISTANT', "Fisheye Equidistant", "Ignore the sensor dimensions"),
+ ('FISHEYE_EQUISOLID', "Fisheye Equisolid",
+ "Similar to most fisheye modern lens, takes sensor dimensions into consideration "
+ "(for fulldomes use it with a square sensor ratio)"),
)
-
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index 52d2c6a2d89..9cc58e65bef 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -193,10 +193,10 @@ class CyclesRender_PT_performance(CyclesButtonsPanel, Panel):
sub.prop(rd, "threads")
sub = col.column(align=True)
- sub.label(text="Tiles:")
+ sub.label(text="Tile Size:")
- sub.prop(rd, "parts_x", text="X")
- sub.prop(rd, "parts_y", text="Y")
+ sub.prop(rd, "tile_x", text="X")
+ sub.prop(rd, "tile_y", text="Y")
sub.prop(cscene, "use_progressive_refine")
diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp
index b1b1a638219..c9748756d43 100644
--- a/intern/cycles/blender/blender_mesh.cpp
+++ b/intern/cycles/blender/blender_mesh.cpp
@@ -16,6 +16,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+
#include "mesh.h"
#include "object.h"
#include "scene.h"
@@ -115,46 +116,81 @@ static void mikk_set_tangent_space(const SMikkTSpaceContext *context, const floa
userdata->tangent[face*4 + vert] = make_float4(T[0], T[1], T[2], sign);
}
-static void mikk_compute_tangents(BL::Mesh b_mesh, BL::MeshTextureFaceLayer b_layer, Mesh *mesh, vector<int>& nverts)
+static void mikk_compute_tangents(BL::Mesh b_mesh, BL::MeshTextureFaceLayer b_layer, Mesh *mesh, vector<int>& nverts, bool need_sign, bool active_render)
{
/* setup userdata */
MikkUserData userdata(b_mesh, b_layer, nverts.size());
/* setup interface */
- SMikkTSpaceInterface interface;
- memset(&interface, 0, sizeof(interface));
- interface.m_getNumFaces = mikk_get_num_faces;
- interface.m_getNumVerticesOfFace = mikk_get_num_verts_of_face;
- interface.m_getPosition = mikk_get_position;
- interface.m_getTexCoord = mikk_get_texture_coordinate;
- interface.m_getNormal = mikk_get_normal;
- interface.m_setTSpaceBasic = mikk_set_tangent_space;
+ SMikkTSpaceInterface sm_interface;
+ memset(&sm_interface, 0, sizeof(sm_interface));
+ sm_interface.m_getNumFaces = mikk_get_num_faces;
+ sm_interface.m_getNumVerticesOfFace = mikk_get_num_verts_of_face;
+ sm_interface.m_getPosition = mikk_get_position;
+ sm_interface.m_getTexCoord = mikk_get_texture_coordinate;
+ sm_interface.m_getNormal = mikk_get_normal;
+ sm_interface.m_setTSpaceBasic = mikk_set_tangent_space;
/* setup context */
SMikkTSpaceContext context;
memset(&context, 0, sizeof(context));
context.m_pUserData = &userdata;
- context.m_pInterface = &interface;
+ context.m_pInterface = &sm_interface;
/* compute tangents */
genTangSpaceDefault(&context);
- /* create attribute */
- /* todo: create float4 attribute for sign */
- Attribute *attr = mesh->attributes.add(ATTR_STD_TANGENT, ustring("Tangent"));
+ /* create tangent attributes */
+ Attribute *attr;
+ ustring name = ustring((string(b_layer.name().c_str()) + ".tangent").c_str());
+
+ if(active_render)
+ attr = mesh->attributes.add(ATTR_STD_UV_TANGENT, name);
+ else
+ attr = mesh->attributes.add(name, TypeDesc::TypeVector, Attribute::CORNER);
+
float3 *tangent = attr->data_float3();
- for (int i = 0; i < nverts.size(); i++) {
+ /* create bitangent sign attribute */
+ float *tangent_sign = NULL;
+
+ if(need_sign) {
+ Attribute *attr_sign;
+ ustring name_sign = ustring((string(b_layer.name().c_str()) + ".tangent_sign").c_str());
+
+ if(active_render)
+ attr_sign = mesh->attributes.add(ATTR_STD_UV_TANGENT_SIGN, name_sign);
+ else
+ attr_sign = mesh->attributes.add(name_sign, TypeDesc::TypeFloat, Attribute::CORNER);
+
+ tangent_sign = attr_sign->data_float();
+ }
+
+ for(int i = 0; i < nverts.size(); i++) {
tangent[0] = float4_to_float3(userdata.tangent[i*4 + 0]);
tangent[1] = float4_to_float3(userdata.tangent[i*4 + 1]);
tangent[2] = float4_to_float3(userdata.tangent[i*4 + 2]);
tangent += 3;
+ if(tangent_sign) {
+ tangent_sign[0] = userdata.tangent[i*4 + 0].w;
+ tangent_sign[1] = userdata.tangent[i*4 + 1].w;
+ tangent_sign[2] = userdata.tangent[i*4 + 2].w;
+ tangent_sign += 3;
+ }
+
if(nverts[i] == 4) {
tangent[0] = float4_to_float3(userdata.tangent[i*4 + 0]);
tangent[1] = float4_to_float3(userdata.tangent[i*4 + 2]);
tangent[2] = float4_to_float3(userdata.tangent[i*4 + 3]);
tangent += 3;
+
+ if(tangent_sign) {
+ tangent_sign[0] = userdata.tangent[i*4 + 0].w;
+ tangent_sign[1] = userdata.tangent[i*4 + 2].w;
+ tangent_sign[2] = userdata.tangent[i*4 + 3].w;
+ tangent_sign += 3;
+ }
}
}
}
@@ -232,48 +268,49 @@ static void create_mesh(Scene *scene, Mesh *mesh, BL::Mesh b_mesh, const vector<
BL::Mesh::tessface_uv_textures_iterator l;
for(b_mesh.tessface_uv_textures.begin(l); l != b_mesh.tessface_uv_textures.end(); ++l) {
- AttributeStandard std = (l->active_render())? ATTR_STD_UV: ATTR_STD_NONE;
+ bool active_render = l->active_render();
+ AttributeStandard std = (active_render)? ATTR_STD_UV: ATTR_STD_NONE;
ustring name = ustring(l->name().c_str());
- if(!(mesh->need_attribute(scene, name) || mesh->need_attribute(scene, std)))
- continue;
+ /* UV map */
+ if(mesh->need_attribute(scene, name) || mesh->need_attribute(scene, std)) {
+ Attribute *attr;
- Attribute *attr;
-
- if(l->active_render())
- attr = mesh->attributes.add(std, name);
- else
- attr = mesh->attributes.add(name, TypeDesc::TypePoint, Attribute::CORNER);
-
- BL::MeshTextureFaceLayer::data_iterator t;
- float3 *fdata = attr->data_float3();
- size_t i = 0;
+ if(active_render)
+ attr = mesh->attributes.add(std, name);
+ else
+ attr = mesh->attributes.add(name, TypeDesc::TypePoint, Attribute::CORNER);
- for(l->data.begin(t); t != l->data.end(); ++t, ++i) {
- fdata[0] = get_float3(t->uv1());
- fdata[1] = get_float3(t->uv2());
- fdata[2] = get_float3(t->uv3());
- fdata += 3;
+ BL::MeshTextureFaceLayer::data_iterator t;
+ float3 *fdata = attr->data_float3();
+ size_t i = 0;
- if(nverts[i] == 4) {
+ for(l->data.begin(t); t != l->data.end(); ++t, ++i) {
fdata[0] = get_float3(t->uv1());
- fdata[1] = get_float3(t->uv3());
- fdata[2] = get_float3(t->uv4());
+ fdata[1] = get_float3(t->uv2());
+ fdata[2] = get_float3(t->uv3());
fdata += 3;
+
+ if(nverts[i] == 4) {
+ fdata[0] = get_float3(t->uv1());
+ fdata[1] = get_float3(t->uv3());
+ fdata[2] = get_float3(t->uv4());
+ fdata += 3;
+ }
}
}
- }
- }
- /* create texcoord-based tangent attributes */
- if(mesh->need_attribute(scene, ATTR_STD_TANGENT)) {
- BL::Mesh::tessface_uv_textures_iterator l;
+ /* UV tangent */
+ std = (active_render)? ATTR_STD_UV_TANGENT: ATTR_STD_NONE;
+ name = ustring((string(l->name().c_str()) + ".tangent").c_str());
- for(b_mesh.tessface_uv_textures.begin(l); l != b_mesh.tessface_uv_textures.end(); ++l) {
- if(!l->active_render())
- continue;
+ if(mesh->need_attribute(scene, name) || mesh->need_attribute(scene, std)) {
+ std = (active_render)? ATTR_STD_UV_TANGENT_SIGN: ATTR_STD_NONE;
+ name = ustring((string(l->name().c_str()) + ".tangent_sign").c_str());
+ bool need_sign = (mesh->need_attribute(scene, name) || mesh->need_attribute(scene, std));
- mikk_compute_tangents(b_mesh, *l, mesh, nverts);
+ mikk_compute_tangents(b_mesh, *l, mesh, nverts, need_sign, active_render);
+ }
}
}
diff --git a/intern/cycles/blender/blender_python.cpp b/intern/cycles/blender/blender_python.cpp
index c047805c6ae..3b78651a6a1 100644
--- a/intern/cycles/blender/blender_python.cpp
+++ b/intern/cycles/blender/blender_python.cpp
@@ -217,6 +217,7 @@ static PyObject *osl_update_node_func(PyObject *self, PyObject *args)
float default_float4[4] = {0.0f, 0.0f, 0.0f, 1.0f};
float default_float = 0.0f;
int default_int = 0;
+ std::string default_string = "";
if(param->isclosure) {
socket_type = BL::NodeSocket::type_SHADER;
@@ -252,6 +253,11 @@ static PyObject *osl_update_node_func(PyObject *self, PyObject *args)
if(param->validdefault)
default_float = param->fdefault[0];
}
+ else if(param->type.basetype == TypeDesc::STRING) {
+ socket_type = BL::NodeSocket::type_STRING;
+ if(param->validdefault)
+ default_string = param->sdefault[0];
+ }
}
else
continue;
@@ -286,6 +292,10 @@ static PyObject *osl_update_node_func(PyObject *self, PyObject *args)
BL::NodeSocketVectorNone b_vector_sock(b_sock.ptr);
b_vector_sock.default_value(default_float4);
}
+ else if(socket_type == BL::NodeSocket::type_STRING) {
+ BL::NodeSocketStringNone b_string_sock(b_sock.ptr);
+ b_string_sock.default_value(default_string);
+ }
}
used_sockets.insert(b_sock.ptr.data);
diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp
index 05db9f55380..01bd5f013e3 100644
--- a/intern/cycles/blender/blender_session.cpp
+++ b/intern/cycles/blender/blender_session.cpp
@@ -477,11 +477,15 @@ void BlenderSession::update_status_progress()
float progress;
double total_time;
char time_str[128];
+ float mem_used = (float)session->stats.mem_used / 1024.0f / 1024.0f;
+ float mem_peak = (float)session->stats.mem_peak / 1024.0f / 1024.0f;
get_status(status, substatus);
get_progress(progress, total_time);
- timestatus = b_scene.name();
+ timestatus = string_printf("Mem: %.2fM, Peak: %.2fM | ", mem_used, mem_peak);
+
+ timestatus += b_scene.name();
if(b_rlay_name != "")
timestatus += ", " + b_rlay_name;
timestatus += " | ";
@@ -494,6 +498,7 @@ void BlenderSession::update_status_progress()
if(status != last_status) {
b_engine.update_stats("", (timestatus + status).c_str());
+ b_engine.update_memory_stats(mem_used, mem_peak);
last_status = status;
}
if(progress != last_progress) {
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp
index 9e3380c6f8e..63cf719d010 100644
--- a/intern/cycles/blender/blender_shader.cpp
+++ b/intern/cycles/blender/blender_shader.cpp
@@ -90,6 +90,8 @@ static ShaderSocketType convert_socket_type(BL::NodeSocket::type_enum b_type)
return SHADER_SOCKET_COLOR;
case BL::NodeSocket::type_SHADER:
return SHADER_SOCKET_CLOSURE;
+ case BL::NodeSocket::type_STRING:
+ return SHADER_SOCKET_STRING;
case BL::NodeSocket::type_BOOLEAN:
case BL::NodeSocket::type_MESH:
@@ -98,7 +100,7 @@ static ShaderSocketType convert_socket_type(BL::NodeSocket::type_enum b_type)
}
}
-static void set_default_value(ShaderInput *input, BL::NodeSocket sock)
+static void set_default_value(ShaderInput *input, BL::NodeSocket sock, BL::BlendData b_data, BL::ID b_id)
{
/* copy values for non linked inputs */
switch(input->type) {
@@ -124,6 +126,11 @@ static void set_default_value(ShaderInput *input, BL::NodeSocket sock)
input->set(get_float3(vec_sock.default_value()));
break;
}
+ case SHADER_SOCKET_STRING: {
+ BL::NodeSocketStringNone string_sock(sock);
+ input->set((ustring)blender_absolute_path(b_data, b_id, string_sock.default_value()));
+ break;
+ }
case SHADER_SOCKET_CLOSURE:
break;
}
@@ -173,6 +180,7 @@ static ShaderNode *add_node(Scene *scene, BL::BlendData b_data, BL::Scene b_scen
case BL::ShaderNode::type_OUTPUT: break;
case BL::ShaderNode::type_SQUEEZE: break;
case BL::ShaderNode::type_TEXTURE: break;
+ case BL::ShaderNode::type_FRAME: break;
/* handled outside this function */
case BL::ShaderNode::type_GROUP: break;
/* existing blender nodes */
@@ -366,6 +374,23 @@ static ShaderNode *add_node(Scene *scene, BL::BlendData b_data, BL::Scene b_scen
node = glass;
break;
}
+ case BL::ShaderNode::type_BSDF_REFRACTION: {
+ BL::ShaderNodeBsdfRefraction b_refraction_node(b_node);
+ RefractionBsdfNode *refraction = new RefractionBsdfNode();
+ switch(b_refraction_node.distribution()) {
+ case BL::ShaderNodeBsdfRefraction::distribution_SHARP:
+ refraction->distribution = ustring("Sharp");
+ break;
+ case BL::ShaderNodeBsdfRefraction::distribution_BECKMANN:
+ refraction->distribution = ustring("Beckmann");
+ break;
+ case BL::ShaderNodeBsdfRefraction::distribution_GGX:
+ refraction->distribution = ustring("GGX");
+ break;
+ }
+ node = refraction;
+ break;
+ }
case BL::ShaderNode::type_BSDF_TRANSLUCENT: {
node = new TranslucentBsdfNode();
break;
@@ -382,6 +407,10 @@ static ShaderNode *add_node(Scene *scene, BL::BlendData b_data, BL::Scene b_scen
node = new EmissionNode();
break;
}
+ case BL::ShaderNode::type_AMBIENT_OCCLUSION: {
+ node = new AmbientOcclusionNode();
+ break;
+ }
case BL::ShaderNode::type_VOLUME_ISOTROPIC: {
node = new IsotropicVolumeNode();
break;
@@ -435,7 +464,7 @@ static ShaderNode *add_node(Scene *scene, BL::BlendData b_data, BL::Scene b_scen
for (b_script_node.inputs.begin(b_input); b_input != b_script_node.inputs.end(); ++b_input) {
script_node->input_names.push_back(ustring(b_input->name()));
ShaderInput *input = script_node->add_input(script_node->input_names.back().c_str(), convert_socket_type(b_input->type()));
- set_default_value(input, *b_input);
+ set_default_value(input, *b_input, b_data, b_ntree);
}
BL::Node::outputs_iterator b_output;
@@ -573,6 +602,23 @@ static ShaderNode *add_node(Scene *scene, BL::BlendData b_data, BL::Scene b_scen
node = sky;
break;
}
+ case BL::ShaderNode::type_NORMAL_MAP: {
+ BL::ShaderNodeNormalMap b_normal_map_node(b_node);
+ NormalMapNode *nmap = new NormalMapNode();
+ nmap->space = NormalMapNode::space_enum[(int)b_normal_map_node.space()];
+ nmap->attribute = b_normal_map_node.uv_map();
+ node = nmap;
+ break;
+ }
+ case BL::ShaderNode::type_TANGENT: {
+ BL::ShaderNodeTangent b_tangent_node(b_node);
+ TangentNode *tangent = new TangentNode();
+ tangent->direction_type = TangentNode::direction_type_enum[(int)b_tangent_node.direction_type()];
+ tangent->axis = TangentNode::axis_enum[(int)b_tangent_node.axis()];
+ tangent->attribute = b_tangent_node.uv_map();
+ node = tangent;
+ break;
+ }
}
if(node && node != graph->output())
@@ -687,7 +733,7 @@ static void add_nodes(Scene *scene, BL::BlendData b_data, BL::Scene b_scene, Sha
group_sockmap[b_input->group_socket().ptr.data] = SocketPair(proxy, proxy->outputs[0]->name);
/* default input values of the group node */
- set_default_value(proxy->inputs[0], *b_input);
+ set_default_value(proxy->inputs[0], *b_input, b_data, b_group_ntree);
}
for(b_node->outputs.begin(b_output); b_output != b_node->outputs.end(); ++b_output) {
@@ -701,7 +747,7 @@ static void add_nodes(Scene *scene, BL::BlendData b_data, BL::Scene b_scene, Sha
group_sockmap[b_output->group_socket().ptr.data] = SocketPair(proxy, proxy->inputs[0]->name);
/* default input values of internal, unlinked group outputs */
- set_default_value(proxy->inputs[0], b_output->group_socket());
+ set_default_value(proxy->inputs[0], b_output->group_socket(), b_data, b_group_ntree);
}
add_nodes(scene, b_data, b_scene, graph, b_group_ntree, group_sockmap);
@@ -721,7 +767,7 @@ static void add_nodes(Scene *scene, BL::BlendData b_data, BL::Scene b_scene, Sha
assert(input);
/* copy values for non linked inputs */
- set_default_value(input, *b_input);
+ set_default_value(input, *b_input, b_data, b_ntree);
}
}
}
diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp
index 5d3f23d954a..550da2982a3 100644
--- a/intern/cycles/device/device.cpp
+++ b/intern/cycles/device/device.cpp
@@ -78,36 +78,36 @@ void Device::draw_pixels(device_memory& rgba, int y, int w, int h, int dy, int w
glDisable(GL_BLEND);
}
-Device *Device::create(DeviceInfo& info, bool background, int threads)
+Device *Device::create(DeviceInfo& info, Stats &stats, bool background, int threads)
{
Device *device;
switch(info.type) {
case DEVICE_CPU:
- device = device_cpu_create(info, threads);
+ device = device_cpu_create(info, stats, threads);
break;
#ifdef WITH_CUDA
case DEVICE_CUDA:
if(cuLibraryInit())
- device = device_cuda_create(info, background);
+ device = device_cuda_create(info, stats, background);
else
device = NULL;
break;
#endif
#ifdef WITH_MULTI
case DEVICE_MULTI:
- device = device_multi_create(info, background);
+ device = device_multi_create(info, stats, background);
break;
#endif
#ifdef WITH_NETWORK
case DEVICE_NETWORK:
- device = device_network_create(info, "127.0.0.1");
+ device = device_network_create(info, stats, "127.0.0.1");
break;
#endif
#ifdef WITH_OPENCL
case DEVICE_OPENCL:
if(clLibraryInit())
- device = device_opencl_create(info, background);
+ device = device_opencl_create(info, stats, background);
else
device = NULL;
break;
diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h
index 2ee2e044618..95da0a89833 100644
--- a/intern/cycles/device/device.h
+++ b/intern/cycles/device/device.h
@@ -25,6 +25,7 @@
#include "device_task.h"
#include "util_list.h"
+#include "util_stats.h"
#include "util_string.h"
#include "util_thread.h"
#include "util_types.h"
@@ -72,7 +73,7 @@ public:
class Device {
protected:
- Device() {}
+ Device(Stats &stats_) : stats(stats_) {}
bool background;
string error_msg;
@@ -84,6 +85,9 @@ public:
DeviceInfo info;
virtual const string& error_message() { return error_msg; }
+ /* statistics */
+ Stats &stats;
+
/* regular memory */
virtual void mem_alloc(device_memory& mem, MemoryType type) = 0;
virtual void mem_copy_to(device_memory& mem) = 0;
@@ -130,7 +134,7 @@ public:
virtual int device_number(Device *sub_device) { return 0; }
/* static */
- static Device *create(DeviceInfo& info, bool background = true, int threads = 0);
+ static Device *create(DeviceInfo& info, Stats &stats, bool background = true, int threads = 0);
static DeviceType type_from_string(const char *name);
static string string_from_type(DeviceType type);
diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp
index b727a83d024..519c458ffdf 100644
--- a/intern/cycles/device/device_cpu.cpp
+++ b/intern/cycles/device/device_cpu.cpp
@@ -45,7 +45,7 @@ public:
TaskPool task_pool;
KernelGlobals *kg;
- CPUDevice(int threads_num)
+ CPUDevice(Stats &stats, int threads_num) : Device(stats)
{
kg = kernel_globals_create();
@@ -67,6 +67,8 @@ public:
void mem_alloc(device_memory& mem, MemoryType type)
{
mem.device_pointer = mem.data_pointer;
+
+ stats.mem_alloc(mem.memory_size());
}
void mem_copy_to(device_memory& mem)
@@ -87,6 +89,8 @@ public:
void mem_free(device_memory& mem)
{
mem.device_pointer = 0;
+
+ stats.mem_free(mem.memory_size());
}
void const_copy_to(const char *name, void *host, size_t size)
@@ -98,11 +102,15 @@ public:
{
kernel_tex_copy(kg, name, mem.data_pointer, mem.data_width, mem.data_height);
mem.device_pointer = mem.data_pointer;
+
+ stats.mem_alloc(mem.memory_size());
}
void tex_free(device_memory& mem)
{
mem.device_pointer = 0;
+
+ stats.mem_free(mem.memory_size());
}
void *osl_memory()
@@ -283,9 +291,9 @@ public:
}
};
-Device *device_cpu_create(DeviceInfo& info, int threads)
+Device *device_cpu_create(DeviceInfo& info, Stats &stats, int threads)
{
- return new CPUDevice(threads);
+ return new CPUDevice(stats, threads);
}
void device_cpu_info(vector<DeviceInfo>& devices)
diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp
index 04b4cb0950a..d797c0f09ca 100644
--- a/intern/cycles/device/device_cuda.cpp
+++ b/intern/cycles/device/device_cuda.cpp
@@ -157,7 +157,7 @@ public:
cuda_assert(cuCtxSetCurrent(NULL));
}
- CUDADevice(DeviceInfo& info, bool background_)
+ CUDADevice(DeviceInfo& info, Stats &stats, bool background_) : Device(stats)
{
background = background_;
@@ -316,8 +316,10 @@ public:
{
cuda_push_context();
CUdeviceptr device_pointer;
- cuda_assert(cuMemAlloc(&device_pointer, mem.memory_size()))
+ size_t size = mem.memory_size();
+ cuda_assert(cuMemAlloc(&device_pointer, size))
mem.device_pointer = (device_ptr)device_pointer;
+ stats.mem_alloc(size);
cuda_pop_context();
}
@@ -356,6 +358,8 @@ public:
cuda_pop_context();
mem.device_pointer = 0;
+
+ stats.mem_free(mem.memory_size());
}
}
@@ -424,6 +428,8 @@ public:
cuda_assert(cuTexRefSetFlags(texref, CU_TRSF_NORMALIZED_COORDINATES))
mem.device_pointer = (device_ptr)handle;
+
+ stats.mem_alloc(size);
}
else {
cuda_pop_context();
@@ -463,6 +469,8 @@ public:
tex_interp_map.erase(tex_interp_map.find(mem.device_pointer));
mem.device_pointer = 0;
+
+ stats.mem_free(mem.memory_size());
}
else {
tex_interp_map.erase(tex_interp_map.find(mem.device_pointer));
@@ -707,6 +715,8 @@ public:
mem.device_pointer = pmem.cuTexId;
pixel_mem_map[mem.device_pointer] = pmem;
+ stats.mem_alloc(mem.memory_size());
+
return;
}
else {
@@ -762,6 +772,8 @@ public:
pixel_mem_map.erase(pixel_mem_map.find(mem.device_pointer));
mem.device_pointer = 0;
+ stats.mem_free(mem.memory_size());
+
return;
}
@@ -896,9 +908,9 @@ public:
}
};
-Device *device_cuda_create(DeviceInfo& info, bool background)
+Device *device_cuda_create(DeviceInfo& info, Stats &stats, bool background)
{
- return new CUDADevice(info, background);
+ return new CUDADevice(info, stats, background);
}
void device_cuda_info(vector<DeviceInfo>& devices)
diff --git a/intern/cycles/device/device_intern.h b/intern/cycles/device/device_intern.h
index e3601aa8ad4..02fbac6860e 100644
--- a/intern/cycles/device/device_intern.h
+++ b/intern/cycles/device/device_intern.h
@@ -23,11 +23,11 @@ CCL_NAMESPACE_BEGIN
class Device;
-Device *device_cpu_create(DeviceInfo& info, int threads);
-Device *device_opencl_create(DeviceInfo& info, bool background);
-Device *device_cuda_create(DeviceInfo& info, bool background);
-Device *device_network_create(DeviceInfo& info, const char *address);
-Device *device_multi_create(DeviceInfo& info, bool background);
+Device *device_cpu_create(DeviceInfo& info, Stats &stats, int threads);
+Device *device_opencl_create(DeviceInfo& info, Stats &stats, bool background);
+Device *device_cuda_create(DeviceInfo& info, Stats &stats, bool background);
+Device *device_network_create(DeviceInfo& info, Stats &stats, const char *address);
+Device *device_multi_create(DeviceInfo& info, Stats &stats, bool background);
void device_cpu_info(vector<DeviceInfo>& devices);
void device_opencl_info(vector<DeviceInfo>& devices);
diff --git a/intern/cycles/device/device_multi.cpp b/intern/cycles/device/device_multi.cpp
index 546ffe5e4b9..807bfe578f3 100644
--- a/intern/cycles/device/device_multi.cpp
+++ b/intern/cycles/device/device_multi.cpp
@@ -46,14 +46,14 @@ public:
list<SubDevice> devices;
device_ptr unique_ptr;
- MultiDevice(DeviceInfo& info, bool background_)
- : unique_ptr(1)
+ MultiDevice(DeviceInfo& info, Stats &stats, bool background_)
+ : Device(stats), unique_ptr(1)
{
Device *device;
background = background_;
foreach(DeviceInfo& subinfo, info.multi_devices) {
- device = Device::create(subinfo, background);
+ device = Device::create(subinfo, stats, background);
devices.push_back(SubDevice(device));
}
@@ -314,9 +314,9 @@ public:
}
};
-Device *device_multi_create(DeviceInfo& info, bool background)
+Device *device_multi_create(DeviceInfo& info, Stats &stats, bool background)
{
- return new MultiDevice(info, background);
+ return new MultiDevice(info, stats, background);
}
static bool device_multi_add(vector<DeviceInfo>& devices, DeviceType type, bool with_display, bool with_advanced_shading, const char *id_fmt, int num)
diff --git a/intern/cycles/device/device_network.cpp b/intern/cycles/device/device_network.cpp
index 931890b5859..a5e0d39df73 100644
--- a/intern/cycles/device/device_network.cpp
+++ b/intern/cycles/device/device_network.cpp
@@ -32,8 +32,8 @@ public:
boost::asio::io_service io_service;
tcp::socket socket;
- NetworkDevice(const char *address)
- : socket(io_service)
+ NetworkDevice(Stats &stats, const char *address)
+ : Device(stats), socket(io_service)
{
stringstream portstr;
portstr << SERVER_PORT;
@@ -202,9 +202,9 @@ public:
}
};
-Device *device_network_create(DeviceInfo& info, const char *address)
+Device *device_network_create(DeviceInfo& info, Stats &stats, const char *address)
{
- return new NetworkDevice(address);
+ return new NetworkDevice(stats, address);
}
void device_network_info(vector<DeviceInfo>& devices)
diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp
index aa4f17ea325..69287f1a8bd 100644
--- a/intern/cycles/device/device_opencl.cpp
+++ b/intern/cycles/device/device_opencl.cpp
@@ -144,7 +144,8 @@ public:
}
}
- OpenCLDevice(DeviceInfo& info, bool background_)
+ OpenCLDevice(DeviceInfo& info, Stats &stats, bool background_)
+ : Device(stats)
{
background = background_;
cpPlatform = NULL;
@@ -473,6 +474,8 @@ public:
mem.device_pointer = (device_ptr)clCreateBuffer(cxContext, CL_MEM_READ_WRITE, size, NULL, &ciErr);
opencl_assert(ciErr);
+
+ stats.mem_alloc(size);
}
void mem_copy_to(device_memory& mem)
@@ -506,6 +509,8 @@ public:
ciErr = clReleaseMemObject(CL_MEM_PTR(mem.device_pointer));
mem.device_pointer = 0;
opencl_assert(ciErr);
+
+ stats.mem_free(mem.memory_size());
}
}
@@ -728,9 +733,9 @@ public:
}
};
-Device *device_opencl_create(DeviceInfo& info, bool background)
+Device *device_opencl_create(DeviceInfo& info, Stats &stats, bool background)
{
- return new OpenCLDevice(info, background);
+ return new OpenCLDevice(info, stats, background);
}
void device_opencl_info(vector<DeviceInfo>& devices)
diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt
index 82b0605ab6b..5a570328948 100644
--- a/intern/cycles/kernel/CMakeLists.txt
+++ b/intern/cycles/kernel/CMakeLists.txt
@@ -51,6 +51,7 @@ set(SRC_CLOSURE_HEADERS
closure/bsdf_diffuse.h
closure/bsdf_microfacet.h
closure/bsdf_oren_nayar.h
+ closure/bsdf_phong_ramp.h
closure/bsdf_reflection.h
closure/bsdf_refraction.h
closure/bsdf_transparent.h
diff --git a/intern/cycles/kernel/closure/bsdf_phong_ramp.h b/intern/cycles/kernel/closure/bsdf_phong_ramp.h
new file mode 100644
index 00000000000..a2df77c2d2b
--- /dev/null
+++ b/intern/cycles/kernel/closure/bsdf_phong_ramp.h
@@ -0,0 +1,140 @@
+/*
+ * Adapted from Open Shading Language with this license:
+ *
+ * Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al.
+ * All Rights Reserved.
+ *
+ * Modifications Copyright 2012, Blender Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Sony Pictures Imageworks nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __BSDF_PHONG_RAMP_H__
+#define __BSDF_PHONG_RAMP_H__
+
+CCL_NAMESPACE_BEGIN
+
+__device float3 bsdf_phong_ramp_get_color(const ShaderClosure *sc, const float3 colors[8], float pos)
+{
+ int MAXCOLORS = 8;
+
+ float npos = pos * (float)(MAXCOLORS - 1);
+ int ipos = (int)npos;
+ if (ipos >= (MAXCOLORS - 1))
+ return colors[MAXCOLORS - 1];
+ float offset = npos - (float)ipos;
+ return colors[ipos] * (1.0f - offset) + colors[ipos+1] * offset;
+}
+
+__device int bsdf_phong_ramp_setup(ShaderClosure *sc)
+{
+ sc->type = CLOSURE_BSDF_PHONG_RAMP_ID;
+ return SD_BSDF | SD_BSDF_HAS_EVAL | SD_BSDF_GLOSSY;
+}
+
+__device void bsdf_phong_ramp_blur(ShaderClosure *sc, float roughness)
+{
+}
+
+__device float3 bsdf_phong_ramp_eval_reflect(const ShaderClosure *sc, const float3 colors[8], const float3 I, const float3 omega_in, float *pdf)
+{
+ float m_exponent = sc->data0;
+ float cosNI = dot(sc->N, omega_in);
+ float cosNO = dot(sc->N, I);
+
+ if (cosNI > 0 && cosNO > 0) {
+ // reflect the view vector
+ float3 R = (2 * cosNO) * sc->N - I;
+ float cosRI = dot(R, omega_in);
+ if (cosRI > 0) {
+ float cosp = powf(cosRI, m_exponent);
+ float common = 0.5f * (float) M_1_PI_F * cosp;
+ float out = cosNI * (m_exponent + 2) * common;
+ *pdf = (m_exponent + 1) * common;
+ return bsdf_phong_ramp_get_color(sc, colors, cosp) * out;
+ }
+ }
+
+ return make_float3(0.0f, 0.0f, 0.0f);
+}
+
+__device float3 bsdf_phong_ramp_eval_transmit(const ShaderClosure *sc, const float3 colors[8], const float3 I, const float3 omega_in, float *pdf)
+{
+ return make_float3(0.0f, 0.0f, 0.0f);
+}
+
+__device int bsdf_phong_ramp_sample(const ShaderClosure *sc, const float3 colors[8], float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+{
+ float cosNO = dot(sc->N, I);
+ float m_exponent = sc->data0;
+
+ if (cosNO > 0) {
+ // reflect the view vector
+ float3 R = (2 * cosNO) * sc->N - I;
+
+#ifdef __RAY_DIFFERENTIALS__
+ *domega_in_dx = (2 * dot(sc->N, dIdx)) * sc->N - dIdx;
+ *domega_in_dy = (2 * dot(sc->N, dIdy)) * sc->N - dIdy;
+#endif
+
+ float3 T, B;
+ make_orthonormals (R, &T, &B);
+ float phi = 2 * M_PI_F * randu;
+ float cosTheta = powf(randv, 1 / (m_exponent + 1));
+ float sinTheta2 = 1 - cosTheta * cosTheta;
+ float sinTheta = sinTheta2 > 0 ? sqrtf(sinTheta2) : 0;
+ *omega_in = (cosf(phi) * sinTheta) * T +
+ (sinf(phi) * sinTheta) * B +
+ ( cosTheta) * R;
+ if (dot(Ng, *omega_in) > 0.0f)
+ {
+ // common terms for pdf and eval
+ float cosNI = dot(sc->N, *omega_in);
+ // make sure the direction we chose is still in the right hemisphere
+ if (cosNI > 0)
+ {
+ float cosp = powf(cosTheta, m_exponent);
+ float common = 0.5f * M_1_PI_F * cosp;
+ *pdf = (m_exponent + 1) * common;
+ float out = cosNI * (m_exponent + 2) * common;
+ *eval = bsdf_phong_ramp_get_color(sc, colors, cosp) * out;
+
+#ifdef __RAY_DIFFERENTIALS__
+ // Since there is some blur to this reflection, make the
+ // derivatives a bit bigger. In theory this varies with the
+ // exponent but the exact relationship is complex and
+ // requires more ops than are practical.
+ *domega_in_dx *= 10;
+ *domega_in_dy *= 10;
+#endif
+ }
+ }
+ }
+ return LABEL_REFLECT;
+}
+
+
+CCL_NAMESPACE_END
+
+#endif /* __BSDF_PHONG_RAMP_H__ */
diff --git a/intern/cycles/kernel/closure/bsdf_ward.h b/intern/cycles/kernel/closure/bsdf_ward.h
index 9c81548a2c3..dbddcf20dba 100644
--- a/intern/cycles/kernel/closure/bsdf_ward.h
+++ b/intern/cycles/kernel/closure/bsdf_ward.h
@@ -68,7 +68,10 @@ __device float3 bsdf_ward_eval_reflect(const ShaderClosure *sc, const float3 I,
float cosNO = dot(N, I);
float cosNI = dot(N, omega_in);
- if(cosNI > 0 && cosNO > 0) {
+ if(cosNI > 0.0f && cosNO > 0.0f) {
+ cosNO = max(cosNO, 1e-4f);
+ cosNI = max(cosNI, 1e-4f);
+
// get half vector and get x,y basis on the surface for anisotropy
float3 H = normalize(omega_in + I); // normalize needed for pdf
float3 X, Y;
@@ -103,7 +106,7 @@ __device int bsdf_ward_sample(const ShaderClosure *sc, float3 Ng, float3 I, floa
float3 T = sc->T;
float cosNO = dot(N, I);
- if(cosNO > 0) {
+ if(cosNO > 0.0f) {
// get x,y basis on the surface for anisotropy
float3 X, Y;
make_orthonormals_tangent(N, T, &X, &Y);
@@ -165,6 +168,9 @@ __device int bsdf_ward_sample(const ShaderClosure *sc, float3 Ng, float3 I, floa
if(dot(Ng, *omega_in) > 0) {
float cosNI = dot(N, *omega_in);
if(cosNI > 0) {
+ cosNO = max(cosNO, 1e-4f);
+ cosNI = max(cosNI, 1e-4f);
+
// eq. 9
float exp_arg = (dotx * dotx + doty * doty) / (dotn * dotn);
float denom = 4 * M_PI_F * m_ax * m_ay * oh * dotn * dotn * dotn;
diff --git a/intern/cycles/kernel/kernel_object.h b/intern/cycles/kernel/kernel_object.h
index 2fa9443766e..112bfbb86b5 100644
--- a/intern/cycles/kernel/kernel_object.h
+++ b/intern/cycles/kernel/kernel_object.h
@@ -84,7 +84,8 @@ __device_inline Transform object_fetch_transform_motion_test(KernelGlobals *kg,
}
else {
Transform tfm = object_fetch_transform(kg, object, OBJECT_TRANSFORM);
- *itfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM);
+ if(itfm)
+ *itfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM);
return tfm;
}
diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h
index 817f254a5e5..585068ce8e2 100644
--- a/intern/cycles/kernel/kernel_path.h
+++ b/intern/cycles/kernel/kernel_path.h
@@ -326,7 +326,7 @@ __device float4 kernel_path_progressive(KernelGlobals *kg, RNG *rng, int sample,
#ifdef __AO__
/* ambient occlusion */
- if(kernel_data.integrator.use_ambient_occlusion) {
+ if(kernel_data.integrator.use_ambient_occlusion || (sd.flag & SD_AO)) {
/* todo: solve correlation */
float bsdf_u = path_rng(kg, rng, sample, rng_offset + PRNG_BSDF_U);
float bsdf_v = path_rng(kg, rng, sample, rng_offset + PRNG_BSDF_V);
@@ -349,6 +349,7 @@ __device float4 kernel_path_progressive(KernelGlobals *kg, RNG *rng, int sample,
if(!shadow_blocked(kg, &state, &light_ray, &ao_shadow)) {
float3 ao_bsdf = shader_bsdf_diffuse(kg, &sd)*kernel_data.background.ao_factor;
+ ao_bsdf += shader_bsdf_ao(kg, &sd);
path_radiance_accum_ao(&L, throughput, ao_bsdf, ao_shadow, state.bounce);
}
}
@@ -503,7 +504,7 @@ __device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, int sample, Ray
#ifdef __AO__
/* ambient occlusion */
- if(kernel_data.integrator.use_ambient_occlusion) {
+ if(kernel_data.integrator.use_ambient_occlusion || (sd.flag & SD_AO)) {
/* todo: solve correlation */
float bsdf_u = path_rng(kg, rng, sample, rng_offset + PRNG_BSDF_U);
float bsdf_v = path_rng(kg, rng, sample, rng_offset + PRNG_BSDF_V);
@@ -526,6 +527,7 @@ __device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, int sample, Ray
if(!shadow_blocked(kg, &state, &light_ray, &ao_shadow)) {
float3 ao_bsdf = shader_bsdf_diffuse(kg, &sd)*kernel_data.background.ao_factor;
+ ao_bsdf += shader_bsdf_ao(kg, &sd);
path_radiance_accum_ao(L, throughput, ao_bsdf, ao_shadow, state.bounce);
}
}
@@ -706,7 +708,7 @@ __device float4 kernel_path_non_progressive(KernelGlobals *kg, RNG *rng, int sam
#ifdef __AO__
/* ambient occlusion */
- if(kernel_data.integrator.use_ambient_occlusion) {
+ if(kernel_data.integrator.use_ambient_occlusion || (sd.flag & SD_AO)) {
int num_samples = kernel_data.integrator.ao_samples;
float num_samples_inv = 1.0f/num_samples;
float ao_factor = kernel_data.background.ao_factor;
@@ -734,6 +736,7 @@ __device float4 kernel_path_non_progressive(KernelGlobals *kg, RNG *rng, int sam
if(!shadow_blocked(kg, &state, &light_ray, &ao_shadow)) {
float3 ao_bsdf = shader_bsdf_diffuse(kg, &sd)*ao_factor;
+ ao_bsdf += shader_bsdf_ao(kg, &sd);
path_radiance_accum_ao(&L, throughput*num_samples_inv, ao_bsdf, ao_shadow, state.bounce);
}
}
diff --git a/intern/cycles/kernel/kernel_shader.h b/intern/cycles/kernel/kernel_shader.h
index 86886a6a231..1af5e048ad9 100644
--- a/intern/cycles/kernel/kernel_shader.h
+++ b/intern/cycles/kernel/kernel_shader.h
@@ -599,6 +599,27 @@ __device float3 shader_bsdf_transmission(KernelGlobals *kg, ShaderData *sd)
#endif
}
+__device float3 shader_bsdf_ao(KernelGlobals *kg, ShaderData *sd)
+{
+#ifdef __MULTI_CLOSURE__
+ float3 eval = make_float3(0.0f, 0.0f, 0.0f);
+
+ for(int i = 0; i< sd->num_closure; i++) {
+ ShaderClosure *sc = &sd->closure[i];
+
+ if(CLOSURE_IS_AMBIENT_OCCLUSION(sc->type))
+ eval += sc->weight;
+ }
+
+ return eval;
+#else
+ if(CLOSURE_IS_AMBIENT_OCCLUSION(sd->closure.type))
+ return sd->closure.weight;
+ else
+ return make_float3(0.0f, 0.0f, 0.0f);
+#endif
+}
+
/* Emission */
__device float3 shader_emissive_eval(KernelGlobals *kg, ShaderData *sd)
diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h
index 930fffa3f40..d4d88466688 100644
--- a/intern/cycles/kernel/kernel_types.h
+++ b/intern/cycles/kernel/kernel_types.h
@@ -36,6 +36,8 @@ CCL_NAMESPACE_BEGIN
#define PARTICLE_SIZE 5
#define TIME_INVALID FLT_MAX
+#define TEX_NUM_FLOAT_IMAGES 5
+
/* device capabilities */
#ifdef __KERNEL_CPU__
#define __KERNEL_SHADING__
@@ -391,16 +393,17 @@ enum ShaderDataFlag {
SD_BSDF_GLOSSY = 16, /* have glossy bsdf */
SD_HOLDOUT = 32, /* have holdout closure? */
SD_VOLUME = 64, /* have volume closure? */
+ SD_AO = 128, /* have ao closure? */
/* shader flags */
- SD_SAMPLE_AS_LIGHT = 128, /* direct light sample */
- SD_HAS_SURFACE_TRANSPARENT = 256, /* has surface transparency */
- SD_HAS_VOLUME = 512, /* has volume shader */
- SD_HOMOGENEOUS_VOLUME = 1024, /* has homogeneous volume */
+ SD_SAMPLE_AS_LIGHT = 256, /* direct light sample */
+ SD_HAS_SURFACE_TRANSPARENT = 512, /* has surface transparency */
+ SD_HAS_VOLUME = 1024, /* has volume shader */
+ SD_HOMOGENEOUS_VOLUME = 2048, /* has homogeneous volume */
/* object flags */
- SD_HOLDOUT_MASK = 2048, /* holdout for camera rays */
- SD_OBJECT_MOTION = 4096 /* has object motion blur */
+ SD_HOLDOUT_MASK = 4096, /* holdout for camera rays */
+ SD_OBJECT_MOTION = 8192 /* has object motion blur */
};
typedef struct ShaderData {
diff --git a/intern/cycles/kernel/osl/CMakeLists.txt b/intern/cycles/kernel/osl/CMakeLists.txt
index 8938b16a48f..1b1bb558bc9 100644
--- a/intern/cycles/kernel/osl/CMakeLists.txt
+++ b/intern/cycles/kernel/osl/CMakeLists.txt
@@ -14,6 +14,7 @@ set(INC_SYS
set(SRC
background.cpp
+ bsdf_phong_ramp.cpp
emissive.cpp
osl_closures.cpp
osl_services.cpp
diff --git a/intern/cycles/kernel/osl/background.cpp b/intern/cycles/kernel/osl/background.cpp
index b6e9473b7bf..eed4446cddc 100644
--- a/intern/cycles/kernel/osl/background.cpp
+++ b/intern/cycles/kernel/osl/background.cpp
@@ -73,6 +73,22 @@ public:
void print_on(std::ostream &out) const { out << name() << " ()"; }
};
+/// ambient occlusion closure
+///
+/// We only have a ambient occlusion closure for the shaders
+/// to return a color in ambient occlusion shaders. No methods,
+/// only the weight is taking into account
+///
+class AmbientOcclusionClosure : public ClosurePrimitive {
+public:
+ AmbientOcclusionClosure () : ClosurePrimitive((ClosurePrimitive::Category)AmbientOcclusion) {}
+
+ void setup() {};
+ size_t memsize() const { return sizeof(*this); }
+ const char *name() const { return "ambient_occlusion"; }
+ void print_on(std::ostream &out) const { out << name() << " ()"; }
+};
+
ClosureParam *closure_background_params()
{
static ClosureParam params[] = {
@@ -94,5 +110,16 @@ ClosureParam *closure_holdout_params()
CLOSURE_PREPARE(closure_holdout_prepare, HoldoutClosure)
+ClosureParam *closure_ambient_occlusion_params()
+{
+ static ClosureParam params[] = {
+ CLOSURE_STRING_KEYPARAM("label"),
+ CLOSURE_FINISH_PARAM(AmbientOcclusionClosure)
+ };
+ return params;
+}
+
+CLOSURE_PREPARE(closure_ambient_occlusion_prepare, AmbientOcclusionClosure)
+
CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/osl/bsdf_phong_ramp.cpp b/intern/cycles/kernel/osl/bsdf_phong_ramp.cpp
new file mode 100644
index 00000000000..fb144be7e50
--- /dev/null
+++ b/intern/cycles/kernel/osl/bsdf_phong_ramp.cpp
@@ -0,0 +1,115 @@
+/*
+ * Adapted from Open Shading Language with this license:
+ *
+ * Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al.
+ * All Rights Reserved.
+ *
+ * Modifications Copyright 2011, Blender Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Sony Pictures Imageworks nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <OpenImageIO/fmath.h>
+
+#include <OSL/genclosure.h>
+
+#include "osl_closures.h"
+
+#include "kernel_types.h"
+#include "closure/bsdf_phong_ramp.h"
+
+CCL_NAMESPACE_BEGIN
+
+using namespace OSL;
+
+class PhongRampClosure : public CBSDFClosure {
+public:
+ PhongRampClosure() : CBSDFClosure(LABEL_GLOSSY) {}
+ Color3 colors[8];
+ float3 fcolors[8];
+
+ size_t memsize() const { return sizeof(*this); }
+ const char *name() const { return "phong_ramp"; }
+
+ void setup()
+ {
+ sc.N = TO_FLOAT3(N);
+ m_shaderdata_flag = bsdf_phong_ramp_setup(&sc);
+
+ for(int i = 0; i < 8; i++)
+ fcolors[i] = TO_FLOAT3(colors[i]);
+ }
+
+ bool mergeable(const ClosurePrimitive *other) const
+ {
+ return false;
+ }
+
+ void blur(float roughness)
+ {
+ bsdf_phong_ramp_blur(&sc, roughness);
+ }
+
+ void print_on(std::ostream &out) const
+ {
+ out << name() << " ((" << sc.N[0] << ", " << sc.N[1] << ", " << sc.N[2] << "))";
+ }
+
+ float3 eval_reflect(const float3 &omega_out, const float3 &omega_in, float& pdf) const
+ {
+ return bsdf_phong_ramp_eval_reflect(&sc, fcolors, omega_out, omega_in, &pdf);
+ }
+
+ float3 eval_transmit(const float3 &omega_out, const float3 &omega_in, float& pdf) const
+ {
+ return bsdf_phong_ramp_eval_transmit(&sc, fcolors, omega_out, omega_in, &pdf);
+ }
+
+ int sample(const float3 &Ng,
+ const float3 &omega_out, const float3 &domega_out_dx, const float3 &domega_out_dy,
+ float randu, float randv,
+ float3 &omega_in, float3 &domega_in_dx, float3 &domega_in_dy,
+ float &pdf, float3 &eval) const
+ {
+ return bsdf_phong_ramp_sample(&sc, fcolors, Ng, omega_out, domega_out_dx, domega_out_dy,
+ randu, randv, &eval, &omega_in, &domega_in_dx, &domega_in_dy, &pdf);
+ }
+};
+
+ClosureParam *closure_bsdf_phong_ramp_params()
+{
+ static ClosureParam params[] = {
+ CLOSURE_VECTOR_PARAM(PhongRampClosure, N),
+ CLOSURE_FLOAT_PARAM(PhongRampClosure, sc.data0),
+ CLOSURE_COLOR_ARRAY_PARAM(PhongRampClosure, colors, 8),
+ CLOSURE_STRING_KEYPARAM("label"),
+ CLOSURE_FINISH_PARAM(PhongRampClosure)
+ };
+ return params;
+}
+
+CLOSURE_PREPARE(closure_bsdf_phong_ramp_prepare, PhongRampClosure)
+
+CCL_NAMESPACE_END
+
diff --git a/intern/cycles/kernel/osl/osl_closures.cpp b/intern/cycles/kernel/osl/osl_closures.cpp
index 73e96643df7..d42d65608c8 100644
--- a/intern/cycles/kernel/osl/osl_closures.cpp
+++ b/intern/cycles/kernel/osl/osl_closures.cpp
@@ -48,6 +48,7 @@
#include "closure/bsdf_diffuse.h"
#include "closure/bsdf_microfacet.h"
#include "closure/bsdf_oren_nayar.h"
+#include "closure/bsdf_phong_ramp.h"
#include "closure/bsdf_reflection.h"
#include "closure/bsdf_refraction.h"
#include "closure/bsdf_transparent.h"
@@ -190,6 +191,10 @@ void OSLShader::register_closures(OSL::ShadingSystem *ss)
closure_background_params(), closure_background_prepare);
register_closure(ss, "holdout", id++,
closure_holdout_params(), closure_holdout_prepare);
+ register_closure(ss, "ambient_occlusion", id++,
+ closure_ambient_occlusion_params(), closure_ambient_occlusion_prepare);
+ register_closure(ss, "phong_ramp", id++,
+ closure_bsdf_phong_ramp_params(), closure_bsdf_phong_ramp_prepare);
}
CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/osl/osl_closures.h b/intern/cycles/kernel/osl/osl_closures.h
index 574cb685db5..71e9e5ae4fd 100644
--- a/intern/cycles/kernel/osl/osl_closures.h
+++ b/intern/cycles/kernel/osl/osl_closures.h
@@ -46,10 +46,18 @@ CCL_NAMESPACE_BEGIN
OSL::ClosureParam *closure_emission_params();
OSL::ClosureParam *closure_background_params();
OSL::ClosureParam *closure_holdout_params();
+OSL::ClosureParam *closure_ambient_occlusion_params();
+OSL::ClosureParam *closure_bsdf_phong_ramp_params();
void closure_emission_prepare(OSL::RendererServices *, int id, void *data);
void closure_background_prepare(OSL::RendererServices *, int id, void *data);
void closure_holdout_prepare(OSL::RendererServices *, int id, void *data);
+void closure_ambient_occlusion_prepare(OSL::RendererServices *, int id, void *data);
+void closure_bsdf_phong_ramp_prepare(OSL::RendererServices *, int id, void *data);
+
+enum {
+ AmbientOcclusion = 100
+};
#define CLOSURE_PREPARE(name, classname) \
void name(RendererServices *, int id, void *data) \
diff --git a/intern/cycles/kernel/osl/osl_globals.h b/intern/cycles/kernel/osl/osl_globals.h
index 8cbbfc8dbb1..5d557ffcb07 100644
--- a/intern/cycles/kernel/osl/osl_globals.h
+++ b/intern/cycles/kernel/osl/osl_globals.h
@@ -59,6 +59,7 @@ struct OSLGlobals {
vector<AttributeMap> attribute_map;
ObjectNameMap object_name_map;
+ vector<ustring> object_names;
/* thread key for thread specific data lookup */
struct ThreadData {
diff --git a/intern/cycles/kernel/osl/osl_services.cpp b/intern/cycles/kernel/osl/osl_services.cpp
index ade085c795d..54cbf49704f 100644
--- a/intern/cycles/kernel/osl/osl_services.cpp
+++ b/intern/cycles/kernel/osl/osl_services.cpp
@@ -22,6 +22,7 @@
#include "object.h"
#include "scene.h"
+#include "osl_closures.h"
#include "osl_services.h"
#include "osl_shader.h"
@@ -30,8 +31,14 @@
#include "kernel_compat_cpu.h"
#include "kernel_globals.h"
+#include "kernel_montecarlo.h"
+#include "kernel_projection.h"
+#include "kernel_differential.h"
#include "kernel_object.h"
+#include "kernel_bvh.h"
#include "kernel_triangle.h"
+#include "kernel_accumulate.h"
+#include "kernel_shader.h"
CCL_NAMESPACE_BEGIN
@@ -282,7 +289,7 @@ bool OSLRenderServices::get_array_attribute(void *renderstate, bool derivatives,
return false;
}
-static void set_attribute_float3(float3 f[3], TypeDesc type, bool derivatives, void *val)
+static bool set_attribute_float3(float3 f[3], TypeDesc type, bool derivatives, void *val)
{
if (type == TypeDesc::TypePoint || type == TypeDesc::TypeVector ||
type == TypeDesc::TypeNormal || type == TypeDesc::TypeColor)
@@ -302,8 +309,10 @@ static void set_attribute_float3(float3 f[3], TypeDesc type, bool derivatives, v
fval[7] = f[2].y;
fval[8] = f[2].z;
}
+
+ return true;
}
- else {
+ else if(type == TypeDesc::TypeFloat) {
float *fval = (float *)val;
fval[0] = average(f[0]);
@@ -311,10 +320,25 @@ static void set_attribute_float3(float3 f[3], TypeDesc type, bool derivatives, v
fval[1] = average(f[1]);
fval[2] = average(f[2]);
}
+
+ return true;
}
+
+ return false;
}
-static void set_attribute_float(float f[3], TypeDesc type, bool derivatives, void *val)
+static bool set_attribute_float3(float3 f, TypeDesc type, bool derivatives, void *val)
+{
+ float3 fv[3];
+
+ fv[0] = f;
+ fv[1] = make_float3(0.0f, 0.0f, 0.0f);
+ fv[2] = make_float3(0.0f, 0.0f, 0.0f);
+
+ return set_attribute_float3(fv, type, derivatives, val);
+}
+
+static bool set_attribute_float(float f[3], TypeDesc type, bool derivatives, void *val)
{
if (type == TypeDesc::TypePoint || type == TypeDesc::TypeVector ||
type == TypeDesc::TypeNormal || type == TypeDesc::TypeColor)
@@ -333,8 +357,10 @@ static void set_attribute_float(float f[3], TypeDesc type, bool derivatives, voi
fval[7] = f[2];
fval[8] = f[2];
}
+
+ return true;
}
- else {
+ else if(type == TypeDesc::TypeFloat) {
float *fval = (float *)val;
fval[0] = f[0];
@@ -342,7 +368,22 @@ static void set_attribute_float(float f[3], TypeDesc type, bool derivatives, voi
fval[1] = f[1];
fval[2] = f[2];
}
+
+ return true;
}
+
+ return false;
+}
+
+static bool set_attribute_float(float f, TypeDesc type, bool derivatives, void *val)
+{
+ float fv[3];
+
+ fv[0] = f;
+ fv[1] = 0.0f;
+ fv[2] = 0.0f;
+
+ return set_attribute_float(fv, type, derivatives, val);
}
static bool set_attribute_int(int i, TypeDesc type, bool derivatives, void *val)
@@ -362,6 +403,23 @@ static bool set_attribute_int(int i, TypeDesc type, bool derivatives, void *val)
return false;
}
+static bool set_attribute_string(ustring str, TypeDesc type, bool derivatives, void *val)
+{
+ if(type.basetype == TypeDesc::INT && type.aggregate == TypeDesc::SCALAR && type.arraylen == 0) {
+ ustring *sval = (ustring *)val;
+ sval[0] = str;
+
+ if (derivatives) {
+ sval[1] = OSLRenderServices::u_empty;
+ sval[2] = OSLRenderServices::u_empty;
+ }
+
+ return true;
+ }
+
+ return false;
+}
+
static bool set_attribute_float3_3(float3 P[3], TypeDesc type, bool derivatives, void *val)
{
if(type.vecsemantics == TypeDesc::POINT && type.arraylen >= 3) {
@@ -393,25 +451,23 @@ static bool set_attribute_float3_3(float3 P[3], TypeDesc type, bool derivatives,
static bool get_mesh_attribute(KernelGlobals *kg, const ShaderData *sd, const OSLGlobals::Attribute& attr,
const TypeDesc& type, bool derivatives, void *val)
{
- if (attr.type == TypeDesc::TypeFloat) {
- float fval[3];
- fval[0] = triangle_attribute_float(kg, sd, attr.elem, attr.offset,
- (derivatives) ? &fval[1] : NULL, (derivatives) ? &fval[2] : NULL);
- set_attribute_float(fval, type, derivatives, val);
- return true;
- }
- else if (attr.type == TypeDesc::TypePoint || attr.type == TypeDesc::TypeVector ||
- attr.type == TypeDesc::TypeNormal || attr.type == TypeDesc::TypeColor)
+ if (attr.type == TypeDesc::TypePoint || attr.type == TypeDesc::TypeVector ||
+ attr.type == TypeDesc::TypeNormal || attr.type == TypeDesc::TypeColor)
{
- /* todo: this won't work when float3 has w component */
float3 fval[3];
fval[0] = triangle_attribute_float3(kg, sd, attr.elem, attr.offset,
(derivatives) ? &fval[1] : NULL, (derivatives) ? &fval[2] : NULL);
- set_attribute_float3(fval, type, derivatives, val);
- return true;
+ return set_attribute_float3(fval, type, derivatives, val);
}
- else
+ else if (attr.type == TypeDesc::TypeFloat) {
+ float fval[3];
+ fval[0] = triangle_attribute_float(kg, sd, attr.elem, attr.offset,
+ (derivatives) ? &fval[1] : NULL, (derivatives) ? &fval[2] : NULL);
+ return set_attribute_float(fval, type, derivatives, val);
+ }
+ else {
return false;
+ }
}
static void get_object_attribute(const OSLGlobals::Attribute& attr, bool derivatives, void *val)
@@ -426,118 +482,76 @@ static void get_object_attribute(const OSLGlobals::Attribute& attr, bool derivat
static bool get_object_standard_attribute(KernelGlobals *kg, ShaderData *sd, ustring name,
TypeDesc type, bool derivatives, void *val)
{
- /* todo: turn this into hash table + callback once */
+ /* todo: turn this into hash table returning int, which can be used in switch */
/* Object Attributes */
if (name == "object:location") {
- float3 fval[3];
- fval[0] = object_location(kg, sd);
- fval[1] = fval[2] = make_float3(0.0, 0.0, 0.0); /* derivates set to 0 */
- set_attribute_float3(fval, type, derivatives, val);
- return true;
+ float3 f = object_location(kg, sd);
+ return set_attribute_float3(f, type, derivatives, val);
}
else if (name == "object:index") {
- float fval[3];
- fval[0] = object_pass_id(kg, sd->object);
- fval[1] = fval[2] = 0.0; /* derivates set to 0 */
- set_attribute_float(fval, type, derivatives, val);
- return true;
+ float f = object_pass_id(kg, sd->object);
+ return set_attribute_float(f, type, derivatives, val);
}
else if (name == "geom:dupli_generated") {
- float3 fval[3];
- fval[0] = object_dupli_generated(kg, sd->object);
- fval[1] = fval[2] = make_float3(0.0, 0.0, 0.0); /* derivates set to 0 */
- set_attribute_float3(fval, type, derivatives, val);
- return true;
+ float3 f = object_dupli_generated(kg, sd->object);
+ return set_attribute_float3(f, type, derivatives, val);
}
else if (name == "geom:dupli_uv") {
- float3 fval[3];
- fval[0] = object_dupli_uv(kg, sd->object);
- fval[1] = fval[2] = make_float3(0.0, 0.0, 0.0); /* derivates set to 0 */
- set_attribute_float3(fval, type, derivatives, val);
- return true;
+ float3 f = object_dupli_uv(kg, sd->object);
+ return set_attribute_float3(f, type, derivatives, val);
}
else if (name == "material:index") {
- float fval[3];
- fval[0] = shader_pass_id(kg, sd);
- fval[1] = fval[2] = 0.0; /* derivates set to 0 */
- set_attribute_float(fval, type, derivatives, val);
- return true;
+ float f = shader_pass_id(kg, sd);
+ return set_attribute_float(f, type, derivatives, val);
}
else if (name == "object:random") {
- float fval[3];
- fval[0] = object_random_number(kg, sd->object);
- fval[1] = fval[2] = 0.0; /* derivates set to 0 */
- set_attribute_float(fval, type, derivatives, val);
- return true;
+ float f = object_random_number(kg, sd->object);
+ return set_attribute_float(f, type, derivatives, val);
}
/* Particle Attributes */
else if (name == "particle:index") {
- float fval[3];
uint particle_id = object_particle_id(kg, sd->object);
- fval[0] = particle_index(kg, particle_id);
- fval[1] = fval[2] = 0.0; /* derivates set to 0 */
- set_attribute_float(fval, type, derivatives, val);
- return true;
+ float f = particle_index(kg, particle_id);
+ return set_attribute_float(f, type, derivatives, val);
}
else if (name == "particle:age") {
- float fval[3];
uint particle_id = object_particle_id(kg, sd->object);
- fval[0] = particle_age(kg, particle_id);
- fval[1] = fval[2] = 0.0; /* derivates set to 0 */
- set_attribute_float(fval, type, derivatives, val);
- return true;
+ float f = particle_age(kg, particle_id);
+ return set_attribute_float(f, type, derivatives, val);
}
else if (name == "particle:lifetime") {
- float fval[3];
uint particle_id = object_particle_id(kg, sd->object);
- fval[0] = particle_lifetime(kg, particle_id);
- fval[1] = fval[2] = 0.0; /* derivates set to 0 */
- set_attribute_float(fval, type, derivatives, val);
- return true;
+ float f= particle_lifetime(kg, particle_id);
+ return set_attribute_float(f, type, derivatives, val);
}
else if (name == "particle:location") {
- float3 fval[3];
uint particle_id = object_particle_id(kg, sd->object);
- fval[0] = particle_location(kg, particle_id);
- fval[1] = fval[2] = make_float3(0.0, 0.0, 0.0); /* derivates set to 0 */
- set_attribute_float3(fval, type, derivatives, val);
- return true;
+ float3 f = particle_location(kg, particle_id);
+ return set_attribute_float3(f, type, derivatives, val);
}
#if 0 /* unsupported */
else if (name == "particle:rotation") {
- float4 fval[3];
uint particle_id = object_particle_id(kg, sd->object);
- fval[0] = particle_rotation(kg, particle_id);
- fval[1] = fval[2] = make_float4(0.0, 0.0, 0.0, 0.0); /* derivates set to 0 */
- set_attribute_float4(fval, type, derivatives, val);
- return true;
+ float4 f = particle_rotation(kg, particle_id);
+ return set_attribute_float4(f, type, derivatives, val);
}
#endif
else if (name == "particle:size") {
- float fval[3];
uint particle_id = object_particle_id(kg, sd->object);
- fval[0] = particle_size(kg, particle_id);
- fval[1] = fval[2] = 0.0; /* derivates set to 0 */
- set_attribute_float(fval, type, derivatives, val);
- return true;
+ float f = particle_size(kg, particle_id);
+ return set_attribute_float(f, type, derivatives, val);
}
else if (name == "particle:velocity") {
- float3 fval[3];
uint particle_id = object_particle_id(kg, sd->object);
- fval[0] = particle_velocity(kg, particle_id);
- fval[1] = fval[2] = make_float3(0.0, 0.0, 0.0); /* derivates set to 0 */
- set_attribute_float3(fval, type, derivatives, val);
- return true;
+ float3 f = particle_velocity(kg, particle_id);
+ return set_attribute_float3(f, type, derivatives, val);
}
else if (name == "particle:angular_velocity") {
- float3 fval[3];
uint particle_id = object_particle_id(kg, sd->object);
- fval[0] = particle_angular_velocity(kg, particle_id);
- fval[1] = fval[2] = make_float3(0.0, 0.0, 0.0); /* derivates set to 0 */
- set_attribute_float3(fval, type, derivatives, val);
- return true;
+ float3 f = particle_angular_velocity(kg, particle_id);
+ return set_attribute_float3(f, type, derivatives, val);
}
else if (name == "geom:numpolyvertices") {
return set_attribute_int(3, type, derivatives, val);
@@ -550,6 +564,10 @@ static bool get_object_standard_attribute(KernelGlobals *kg, ShaderData *sd, ust
object_position_transform(kg, sd, &P[2]);
return set_attribute_float3_3(P, type, derivatives, val);
}
+ else if(name == "geom:name") {
+ ustring object_name = kg->osl.object_names[sd->object];
+ return set_attribute_string(object_name, type, derivatives, val);
+ }
else
return false;
}
@@ -559,11 +577,8 @@ static bool get_background_attribute(KernelGlobals *kg, ShaderData *sd, ustring
{
/* Ray Length */
if (name == "path:ray_length") {
- float fval[3];
- fval[0] = sd->ray_length;
- fval[1] = fval[2] = 0.0; /* derivates set to 0 */
- set_attribute_float(fval, type, derivatives, val);
- return true;
+ float f = sd->ray_length;
+ return set_attribute_float(f, type, derivatives, val);
}
else
@@ -598,7 +613,7 @@ bool OSLRenderServices::get_attribute(void *renderstate, bool derivatives, ustri
if (it != attribute_map.end()) {
const OSLGlobals::Attribute& attr = it->second;
-
+
if (attr.elem != ATTR_ELEMENT_VALUE) {
/* triangle and vertex attributes */
if (tri != ~0)
@@ -613,11 +628,11 @@ bool OSLRenderServices::get_attribute(void *renderstate, bool derivatives, ustri
else {
/* not found in attribute, check standard object info */
bool is_std_object_attribute = get_object_standard_attribute(kg, sd, name, type, derivatives, val);
+
if (is_std_object_attribute)
return true;
- else {
- return get_background_attribute(kg, sd, name, type, derivatives, val);
- }
+
+ return get_background_attribute(kg, sd, name, type, derivatives, val);
}
return false;
@@ -647,4 +662,107 @@ int OSLRenderServices::pointcloud_get(ustring filename, size_t *indices, int cou
return 0;
}
+bool OSLRenderServices::trace(TraceOpt &options, OSL::ShaderGlobals *sg,
+ const OSL::Vec3 &P, const OSL::Vec3 &dPdx,
+ const OSL::Vec3 &dPdy, const OSL::Vec3 &R,
+ const OSL::Vec3 &dRdx, const OSL::Vec3 &dRdy)
+{
+ /* todo: options.shader support, maybe options.traceset */
+ ShaderData *sd = (ShaderData *)(sg->renderstate);
+
+ /* setup ray */
+ Ray ray;
+
+ ray.P = TO_FLOAT3(P);
+ ray.D = TO_FLOAT3(R);
+ ray.t = (options.maxdist == 1.0e30)? FLT_MAX: options.maxdist - options.mindist;
+ ray.time = sd->time;
+
+ if(options.mindist == 0.0f) {
+ /* avoid self-intersections */
+ if(ray.P == sd->P) {
+ bool transmit = (dot(sd->Ng, ray.D) < 0.0f);
+ ray.P = ray_offset(sd->P, (transmit)? -sd->Ng: sd->Ng);
+ }
+ }
+ else {
+ /* offset for minimum distance */
+ ray.P += options.mindist*ray.D;
+ }
+
+ /* ray differentials */
+ ray.dP.dx = TO_FLOAT3(dPdx);
+ ray.dP.dy = TO_FLOAT3(dPdy);
+ ray.dD.dx = TO_FLOAT3(dRdx);
+ ray.dD.dy = TO_FLOAT3(dRdy);
+
+ /* allocate trace data */
+ TraceData *tracedata = new TraceData();
+ tracedata->ray = ray;
+ tracedata->setup = false;
+
+ if(sg->tracedata)
+ delete (TraceData*)sg->tracedata;
+ sg->tracedata = tracedata;
+
+ /* raytrace */
+ return scene_intersect(kernel_globals, &ray, ~0, &tracedata->isect);
+}
+
+
+bool OSLRenderServices::getmessage(OSL::ShaderGlobals *sg, ustring source, ustring name,
+ TypeDesc type, void *val, bool derivatives)
+{
+ TraceData *tracedata = (TraceData*)sg->tracedata;
+
+ if(source == "trace" && tracedata) {
+ if(name == "hit") {
+ return set_attribute_int((tracedata->isect.prim != ~0), type, derivatives, val);
+ }
+ else if(tracedata->isect.prim != ~0) {
+ if(name == "hitdist") {
+ float f[3] = {tracedata->isect.t, 0.0f, 0.0f};
+ return set_attribute_float(f, type, derivatives, val);
+ }
+ else {
+ KernelGlobals *kg = kernel_globals;
+ ShaderData *sd = &tracedata->sd;
+
+ if(!tracedata->setup) {
+ /* lazy shader data setup */
+ shader_setup_from_ray(kg, sd, &tracedata->isect, &tracedata->ray);
+ tracedata->setup = true;
+ }
+
+ if(name == "N") {
+ return set_attribute_float3(sd->N, type, derivatives, val);
+ }
+ else if(name == "Ng") {
+ return set_attribute_float3(sd->Ng, type, derivatives, val);
+ }
+ else if(name == "P") {
+ float3 f[3] = {sd->P, sd->dP.dx, sd->dP.dy};
+ return set_attribute_float3(f, type, derivatives, val);
+ }
+ else if(name == "I") {
+ float3 f[3] = {sd->I, sd->dI.dx, sd->dI.dy};
+ return set_attribute_float3(f, type, derivatives, val);
+ }
+ else if(name == "u") {
+ float f[3] = {sd->u, sd->du.dx, sd->du.dy};
+ return set_attribute_float(f, type, derivatives, val);
+ }
+ else if(name == "v") {
+ float f[3] = {sd->v, sd->dv.dx, sd->dv.dy};
+ return set_attribute_float(f, type, derivatives, val);
+ }
+
+ return get_attribute(sd, derivatives, u_empty, type, name, val);
+ }
+ }
+ }
+
+ return false;
+}
+
CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/osl/osl_services.h b/intern/cycles/kernel/osl/osl_services.h
index fa32d47a89f..ce62eaf8994 100644
--- a/intern/cycles/kernel/osl/osl_services.h
+++ b/intern/cycles/kernel/osl/osl_services.h
@@ -76,8 +76,20 @@ public:
int pointcloud_get(ustring filename, size_t *indices, int count, ustring attr_name,
TypeDesc attr_type, void *out_data);
-private:
- KernelGlobals *kernel_globals;
+ bool trace(TraceOpt &options, OSL::ShaderGlobals *sg,
+ const OSL::Vec3 &P, const OSL::Vec3 &dPdx,
+ const OSL::Vec3 &dPdy, const OSL::Vec3 &R,
+ const OSL::Vec3 &dRdx, const OSL::Vec3 &dRdy);
+
+ bool getmessage(OSL::ShaderGlobals *sg, ustring source, ustring name,
+ TypeDesc type, void *val, bool derivatives);
+
+ struct TraceData {
+ Ray ray;
+ Intersection isect;
+ ShaderData sd;
+ bool setup;
+ };
static ustring u_distance;
static ustring u_index;
@@ -86,6 +98,9 @@ private:
static ustring u_raster;
static ustring u_ndc;
static ustring u_empty;
+
+private:
+ KernelGlobals *kernel_globals;
};
CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/osl/osl_shader.cpp b/intern/cycles/kernel/osl/osl_shader.cpp
index 8b71ac30ab6..0c8de058b5b 100644
--- a/intern/cycles/kernel/osl/osl_shader.cpp
+++ b/intern/cycles/kernel/osl/osl_shader.cpp
@@ -93,6 +93,7 @@ static void shaderdata_to_shaderglobals(KernelGlobals *kg, ShaderData *sd,
/* shader data to be used in services callbacks */
globals->renderstate = sd;
+ globals->tracedata = NULL;
/* hacky, we leave it to services to fetch actual object matrix */
globals->shader2common = sd;
@@ -159,6 +160,20 @@ static void flatten_surface_closure_tree(ShaderData *sd, bool no_glossy,
sd->closure[sd->num_closure++] = sc;
break;
}
+ case AmbientOcclusion: {
+ if (sd->num_closure == MAX_CLOSURE)
+ return;
+
+ /* sample weight */
+ float sample_weight = fabsf(average(weight));
+
+ sc.sample_weight = sample_weight;
+ sc.type = CLOSURE_AMBIENT_OCCLUSION_ID;
+
+ sd->closure[sd->num_closure++] = sc;
+ sd->flag |= SD_AO;
+ break;
+ }
case OSL::ClosurePrimitive::Holdout:
if (sd->num_closure == MAX_CLOSURE)
return;
@@ -205,6 +220,10 @@ void OSLShader::eval_surface(KernelGlobals *kg, ShaderData *sd, float randb, int
if (kg->osl.surface_state[shader])
ss->execute(*ctx, *(kg->osl.surface_state[shader]), *globals);
+ /* free trace data */
+ if(globals->tracedata)
+ delete (OSLRenderServices::TraceData*)globals->tracedata;
+
/* flatten closure tree */
sd->num_closure = 0;
sd->randb_closure = randb;
@@ -260,6 +279,10 @@ float3 OSLShader::eval_background(KernelGlobals *kg, ShaderData *sd, int path_fl
if (kg->osl.background_state)
ss->execute(*ctx, *(kg->osl.background_state), *globals);
+ /* free trace data */
+ if(globals->tracedata)
+ delete (OSLRenderServices::TraceData*)globals->tracedata;
+
/* return background color immediately */
if (globals->Ci)
return flatten_background_closure_tree(globals->Ci);
@@ -338,6 +361,10 @@ void OSLShader::eval_volume(KernelGlobals *kg, ShaderData *sd, float randb, int
if (kg->osl.volume_state[shader])
ss->execute(*ctx, *(kg->osl.volume_state[shader]), *globals);
+ /* free trace data */
+ if(globals->tracedata)
+ delete (OSLRenderServices::TraceData*)globals->tracedata;
+
if (globals->Ci)
flatten_volume_closure_tree(sd, globals->Ci);
}
@@ -361,6 +388,10 @@ void OSLShader::eval_displacement(KernelGlobals *kg, ShaderData *sd)
if (kg->osl.displacement_state[shader])
ss->execute(*ctx, *(kg->osl.displacement_state[shader]), *globals);
+ /* free trace data */
+ if(globals->tracedata)
+ delete (OSLRenderServices::TraceData*)globals->tracedata;
+
/* get back position */
sd->P = TO_FLOAT3(globals->P);
}
diff --git a/intern/cycles/kernel/shaders/CMakeLists.txt b/intern/cycles/kernel/shaders/CMakeLists.txt
index 00ab52a1d13..4f5a97c1bb6 100644
--- a/intern/cycles/kernel/shaders/CMakeLists.txt
+++ b/intern/cycles/kernel/shaders/CMakeLists.txt
@@ -3,9 +3,11 @@
set(SRC_OSL
node_add_closure.osl
+ node_ambient_occlusion.osl
node_attribute.osl
node_background.osl
node_brick_texture.osl
+ node_brightness.osl
node_bump.osl
node_camera.osl
node_checker_texture.osl
@@ -21,35 +23,37 @@ set(SRC_OSL
node_environment_texture.osl
node_fresnel.osl
node_gamma.osl
- node_gradient_texture.osl
- node_brightness.osl
node_geometry.osl
node_glass_bsdf.osl
node_glossy_bsdf.osl
+ node_gradient_texture.osl
node_holdout.osl
node_hsv.osl
node_image_texture.osl
node_invert.osl
node_layer_weight.osl
- node_light_path.osl
node_light_falloff.osl
+ node_light_path.osl
node_magic_texture.osl
node_mapping.osl
node_math.osl
node_mix.osl
node_mix_closure.osl
node_musgrave_texture.osl
- node_normal.osl
node_noise_texture.osl
+ node_normal.osl
+ node_normal_map.osl
node_object_info.osl
node_output_displacement.osl
node_output_surface.osl
node_output_volume.osl
node_particle_info.osl
+ node_refraction_bsdf.osl
node_rgb_ramp.osl
node_separate_rgb.osl
node_set_normal.osl
node_sky_texture.osl
+ node_tangent.osl
node_texture_coordinate.osl
node_translucent_bsdf.osl
node_transparent_bsdf.osl
diff --git a/intern/cycles/kernel/shaders/node_ambient_occlusion.osl b/intern/cycles/kernel/shaders/node_ambient_occlusion.osl
new file mode 100644
index 00000000000..57a06f35461
--- /dev/null
+++ b/intern/cycles/kernel/shaders/node_ambient_occlusion.osl
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "stdosl.h"
+
+shader node_ambient_occlusion(
+ color Color = color(0.8, 0.8, 0.8),
+ output closure color AO = ambient_occlusion())
+{
+ AO = Color * ambient_occlusion();
+}
+
diff --git a/intern/cycles/kernel/shaders/node_geometry.osl b/intern/cycles/kernel/shaders/node_geometry.osl
index a3831cbec9c..3940b98eec1 100644
--- a/intern/cycles/kernel/shaders/node_geometry.osl
+++ b/intern/cycles/kernel/shaders/node_geometry.osl
@@ -32,7 +32,6 @@ shader node_geometry(
{
Position = P;
Normal = NormalIn;
- Tangent = normalize(dPdu);
TrueNormal = Ng;
Incoming = I;
Parametric = point(u, v, 0.0);
@@ -46,5 +45,19 @@ shader node_geometry(
Position += Dy(Position);
Parametric += Dy(Parametric);
}
+
+ /* first try to get tangent attribute */
+ point generated;
+
+ /* try to create spherical tangent from generated coordinates */
+ if (getattribute("geom:generated", generated)) {
+ vector T = vector(-(generated[1] - 0.5), (generated[0] - 0.5), 0.0);
+ T = transform("object", "world", T);
+ Tangent = cross(Normal, normalize(cross(T, Normal)));
+ }
+ else {
+ /* otherwise use surface derivatives */
+ Tangent = normalize(dPdu);
+ }
}
diff --git a/intern/cycles/kernel/shaders/node_normal_map.osl b/intern/cycles/kernel/shaders/node_normal_map.osl
new file mode 100644
index 00000000000..e238313509e
--- /dev/null
+++ b/intern/cycles/kernel/shaders/node_normal_map.osl
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "stdosl.h"
+
+shader node_normal_map(
+ normal NormalIn = N,
+ color Color = color(0.5, 0.5, 1.0),
+ string space = "Tangent",
+ string attr_name = "geom:tangent",
+ string attr_sign_name = "geom:tangent_sign",
+ output normal Normal = NormalIn)
+{
+ color mcolor = 2.0*color(Color[0] - 0.5, Color[1] - 0.5, Color[2] - 0.5);
+
+ if (space == "Tangent") {
+ vector tangent;
+ float tangent_sign;
+
+ getattribute(attr_name, tangent);
+ getattribute(attr_sign_name, tangent_sign);
+
+ tangent = transform("object", "world", tangent);
+
+ vector B = tangent_sign * cross(NormalIn, tangent);
+ Normal = normalize(mcolor[0] * tangent + mcolor[1] * B + mcolor[2] * NormalIn);
+ }
+ else if (space == "Object")
+ Normal = normalize(transform("object", "world", vector(mcolor)));
+ else if (space == "World")
+ Normal = normalize(vector(mcolor));
+}
+
diff --git a/intern/cycles/kernel/shaders/node_refraction_bsdf.osl b/intern/cycles/kernel/shaders/node_refraction_bsdf.osl
new file mode 100644
index 00000000000..0cf9d460c6e
--- /dev/null
+++ b/intern/cycles/kernel/shaders/node_refraction_bsdf.osl
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "stdosl.h"
+
+shader node_refraction_bsdf(
+ color Color = color(0.8, 0.8, 0.8),
+ string distribution = "Sharp",
+ float Roughness = 0.2,
+ float IOR = 1.45,
+ normal Normal = N,
+ output closure color BSDF = diffuse(Normal))
+{
+ float f = max(IOR, 1.0 + 1e-5);
+ float eta = backfacing() ? 1.0 / f: f;
+
+ if (distribution == "Sharp")
+ BSDF = Color * refraction(Normal, eta);
+ else if (distribution == "Beckmann")
+ BSDF = Color * microfacet_beckmann_refraction(Normal, Roughness, eta);
+ else if (distribution == "GGX")
+ BSDF = Color * microfacet_ggx_refraction(Normal, Roughness, eta);
+}
+
diff --git a/intern/cycles/kernel/shaders/node_tangent.osl b/intern/cycles/kernel/shaders/node_tangent.osl
new file mode 100644
index 00000000000..731af89231a
--- /dev/null
+++ b/intern/cycles/kernel/shaders/node_tangent.osl
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "stdosl.h"
+
+shader node_tangent(
+ normal NormalIn = N,
+ string attr_name = "geom:tangent",
+ string direction_type = "Radial",
+ string axis = "Z",
+ output normal Tangent = normalize(dPdu))
+{
+ vector T;
+
+ if (direction_type == "UV Map") {
+ getattribute(attr_name, T);
+ }
+ else if (direction_type == "Radial") {
+ point generated;
+
+ if (!getattribute("geom:generated", generated))
+ generated = P;
+
+ if (axis == "X")
+ T = vector(0.0, -(generated[2] - 0.5), (generated[1] - 0.5));
+ else if (axis == "Y")
+ T = vector(-(generated[2] - 0.5), 0.0, (generated[0] - 0.5));
+ else
+ T = vector(-(generated[1] - 0.5), (generated[0] - 0.5), 0.0);
+ }
+
+ T = transform("object", "world", T);
+ Tangent = cross(NormalIn, normalize(cross(T, NormalIn)));
+}
+
diff --git a/intern/cycles/kernel/shaders/node_ward_bsdf.osl b/intern/cycles/kernel/shaders/node_ward_bsdf.osl
index e204be123b8..e5c6f0ad705 100644
--- a/intern/cycles/kernel/shaders/node_ward_bsdf.osl
+++ b/intern/cycles/kernel/shaders/node_ward_bsdf.osl
@@ -20,11 +20,32 @@
shader node_ward_bsdf(
color Color = color(0.8, 0.8, 0.8),
- float RoughnessU = 0.0,
- float RoughnessV = 0.0,
+ float Roughness = 0.0,
+ float Anisotropy = 0.0,
+ float Rotation = 0.0,
normal Normal = N,
+ normal Tangent = normalize(dPdu),
output closure color BSDF = diffuse(Normal))
{
- BSDF = Color * ward(Normal, normalize(dPdu), RoughnessU, RoughnessV);
+ /* rotate tangent around normal */
+ vector T = Tangent;
+
+ if(Rotation != 0.0)
+ T = rotate(T, Rotation*2.0*M_PI, point(0.0, 0.0, 0.0), Normal);
+
+ /* compute roughness */
+ float RoughnessU, RoughnessV;
+ float aniso = clamp(Anisotropy, -0.99, 0.99);
+
+ if(aniso < 0.0) {
+ RoughnessU = Roughness/(1.0 + aniso);
+ RoughnessV = Roughness*(1.0 + aniso);
+ }
+ else {
+ RoughnessU = Roughness*(1.0 - aniso);
+ RoughnessV = Roughness/(1.0 - aniso);
+ }
+
+ BSDF = Color * ward(Normal, T, RoughnessU, RoughnessV);
}
diff --git a/intern/cycles/kernel/shaders/stdosl.h b/intern/cycles/kernel/shaders/stdosl.h
index 4237291c7a4..24c3a50e6f6 100644
--- a/intern/cycles/kernel/shaders/stdosl.h
+++ b/intern/cycles/kernel/shaders/stdosl.h
@@ -433,6 +433,7 @@ string concat (string a, string b, string c, string d, string e, string f) {
closure color diffuse(normal N) BUILTIN;
closure color oren_nayar(normal N, float sigma) BUILTIN;
+closure color phong_ramp(normal N, float exponent, color colors[8]) BUILTIN;
closure color translucent(normal N) BUILTIN;
closure color reflection(normal N) BUILTIN;
closure color refraction(normal N, float eta) BUILTIN;
@@ -446,6 +447,7 @@ closure color ashikhmin_velvet(normal N, float sigma) BUILTIN;
closure color emission() BUILTIN;
closure color background() BUILTIN;
closure color holdout() BUILTIN;
+closure color ambient_occlusion() BUILTIN;
// Renderer state
int raytype (string typename) BUILTIN;
diff --git a/intern/cycles/kernel/svm/svm.h b/intern/cycles/kernel/svm/svm.h
index 698ef5016f0..886fce63fd4 100644
--- a/intern/cycles/kernel/svm/svm.h
+++ b/intern/cycles/kernel/svm/svm.h
@@ -215,6 +215,9 @@ __device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ShaderT
case NODE_CLOSURE_HOLDOUT:
svm_node_closure_holdout(sd, stack, node);
break;
+ case NODE_CLOSURE_AMBIENT_OCCLUSION:
+ svm_node_closure_ambient_occlusion(sd, stack, node);
+ break;
case NODE_CLOSURE_VOLUME:
svm_node_closure_volume(kg, sd, stack, node, path_flag);
break;
@@ -398,6 +401,12 @@ __device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ShaderT
case NODE_LIGHT_FALLOFF:
svm_node_light_falloff(sd, stack, node);
break;
+ case NODE_TANGENT:
+ svm_node_tangent(kg, sd, stack, node);
+ break;
+ case NODE_NORMAL_MAP:
+ svm_node_normal_map(kg, sd, stack, node);
+ break;
#endif
case NODE_END:
default:
diff --git a/intern/cycles/kernel/svm/svm_bsdf.h b/intern/cycles/kernel/svm/svm_bsdf.h
index 07c20231d54..373710446e5 100644
--- a/intern/cycles/kernel/svm/svm_bsdf.h
+++ b/intern/cycles/kernel/svm/svm_bsdf.h
@@ -19,6 +19,7 @@
#include "../closure/bsdf_ashikhmin_velvet.h"
#include "../closure/bsdf_diffuse.h"
#include "../closure/bsdf_oren_nayar.h"
+#include "../closure/bsdf_phong_ramp.h"
#include "../closure/bsdf_microfacet.h"
#include "../closure/bsdf_reflection.h"
#include "../closure/bsdf_refraction.h"
@@ -44,6 +45,10 @@ __device int svm_bsdf_sample(const ShaderData *sd, const ShaderClosure *sc, floa
label = bsdf_oren_nayar_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
break;
+ /*case CLOSURE_BSDF_PHONG_RAMP_ID:
+ label = bsdf_phong_ramp_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
+ eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
+ break;*/
case CLOSURE_BSDF_TRANSLUCENT_ID:
label = bsdf_translucent_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
@@ -110,6 +115,9 @@ __device float3 svm_bsdf_eval(const ShaderData *sd, const ShaderClosure *sc, con
case CLOSURE_BSDF_OREN_NAYAR_ID:
eval = bsdf_oren_nayar_eval_reflect(sc, sd->I, omega_in, pdf);
break;
+ /*case CLOSURE_BSDF_PHONG_RAMP_ID:
+ eval = bsdf_phong_ramp_eval_reflect(sc, sd->I, omega_in, pdf);
+ break;*/
case CLOSURE_BSDF_TRANSLUCENT_ID:
eval = bsdf_translucent_eval_reflect(sc, sd->I, omega_in, pdf);
break;
@@ -213,6 +221,9 @@ __device void svm_bsdf_blur(ShaderClosure *sc, float roughness)
case CLOSURE_BSDF_OREN_NAYAR_ID:
bsdf_oren_nayar_blur(sc, roughness);
break;
+ /*case CLOSURE_BSDF_PHONG_RAMP_ID:
+ bsdf_phong_ramp_blur(sc, roughness);
+ break;*/
case CLOSURE_BSDF_TRANSLUCENT_ID:
bsdf_translucent_blur(sc, roughness);
break;
diff --git a/intern/cycles/kernel/svm/svm_closure.h b/intern/cycles/kernel/svm/svm_closure.h
index b72fad26a1f..f378d24463d 100644
--- a/intern/cycles/kernel/svm/svm_closure.h
+++ b/intern/cycles/kernel/svm/svm_closure.h
@@ -20,9 +20,9 @@ CCL_NAMESPACE_BEGIN
/* Closure Nodes */
-__device void svm_node_glossy_setup(ShaderData *sd, ShaderClosure *sc, int type, float eta, float roughness, bool refract)
+__device void svm_node_glass_setup(ShaderData *sd, ShaderClosure *sc, int type, float eta, float roughness, bool refract)
{
- if(type == CLOSURE_BSDF_REFRACTION_ID) {
+ if(type == CLOSURE_BSDF_SHARP_GLASS_ID) {
if(refract) {
sc->data0 = eta;
sd->flag |= bsdf_refraction_setup(sc);
@@ -30,7 +30,7 @@ __device void svm_node_glossy_setup(ShaderData *sd, ShaderClosure *sc, int type,
else
sd->flag |= bsdf_reflection_setup(sc);
}
- else if(type == CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID) {
+ else if(type == CLOSURE_BSDF_MICROFACET_BECKMANN_GLASS_ID) {
sc->data0 = roughness;
sc->data1 = eta;
@@ -159,6 +159,31 @@ __device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *st
if(kernel_data.integrator.no_caustics && (path_flag & PATH_RAY_DIFFUSE))
break;
#endif
+ ShaderClosure *sc = svm_node_closure_get(sd);
+ sc->N = N;
+ sc->data0 = param1;
+ svm_node_closure_set_mix_weight(sc, mix_weight);
+
+ float eta = fmaxf(param2, 1.0f + 1e-5f);
+ sc->data1 = (sd->flag & SD_BACKFACING)? 1.0f/eta: eta;
+
+ /* setup bsdf */
+ if(type == CLOSURE_BSDF_REFRACTION_ID)
+ sd->flag |= bsdf_refraction_setup(sc);
+ else if(type == CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID)
+ sd->flag |= bsdf_microfacet_beckmann_refraction_setup(sc);
+ else
+ sd->flag |= bsdf_microfacet_ggx_refraction_setup(sc);
+
+ break;
+ }
+ case CLOSURE_BSDF_SHARP_GLASS_ID:
+ case CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID:
+ case CLOSURE_BSDF_MICROFACET_BECKMANN_GLASS_ID: {
+#ifdef __CAUSTICS_TRICKS__
+ if(kernel_data.integrator.no_caustics && (path_flag & PATH_RAY_DIFFUSE))
+ break;
+#endif
/* index of refraction */
float eta = fmaxf(param2, 1.0f + 1e-5f);
eta = (sd->flag & SD_BACKFACING)? 1.0f/eta: eta;
@@ -177,7 +202,7 @@ __device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *st
float sample_weight = sc->sample_weight;
svm_node_closure_set_mix_weight(sc, mix_weight*fresnel);
- svm_node_glossy_setup(sd, sc, type, eta, roughness, false);
+ svm_node_glass_setup(sd, sc, type, eta, roughness, false);
/* refraction */
sc = svm_node_closure_get(sd);
@@ -187,7 +212,7 @@ __device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *st
sc->sample_weight = sample_weight;
svm_node_closure_set_mix_weight(sc, mix_weight*(1.0f - fresnel));
- svm_node_glossy_setup(sd, sc, type, eta, roughness, true);
+ svm_node_glass_setup(sd, sc, type, eta, roughness, true);
#else
ShaderClosure *sc = svm_node_closure_get(sd);
sc->N = N;
@@ -195,7 +220,7 @@ __device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *st
bool refract = (randb > fresnel);
svm_node_closure_set_mix_weight(sc, mix_weight);
- svm_node_glossy_setup(sd, sc, type, eta, roughness, refract);
+ svm_node_glass_setup(sd, sc, type, eta, roughness, refract);
#endif
break;
@@ -211,8 +236,24 @@ __device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *st
sc->T = stack_load_float3(stack, data_node.z);
svm_node_closure_set_mix_weight(sc, mix_weight);
- sc->data0 = param1;
- sc->data1 = param2;
+ /* rotate tangent */
+ float rotation = stack_load_float(stack, data_node.w);
+
+ if(rotation != 0.0f)
+ sc->T = rotate_around_axis(sc->T, sc->N, rotation * 2.0f * M_PI_F);
+
+ /* compute roughness */
+ float roughness = param1;
+ float anisotropy = clamp(param2, -0.99f, 0.99f);
+
+ if(anisotropy < 0.0f) {
+ sc->data0 = roughness/(1.0f + anisotropy);
+ sc->data1 = roughness*(1.0f + anisotropy);
+ }
+ else {
+ sc->data0 = roughness*(1.0f - anisotropy);
+ sc->data1 = roughness/(1.0f - anisotropy);
+ }
sd->flag |= bsdf_ward_setup(sc);
break;
@@ -356,6 +397,34 @@ __device void svm_node_closure_holdout(ShaderData *sd, float *stack, uint4 node)
sd->flag |= SD_HOLDOUT;
}
+__device void svm_node_closure_ambient_occlusion(ShaderData *sd, float *stack, uint4 node)
+{
+#ifdef __MULTI_CLOSURE__
+ uint mix_weight_offset = node.y;
+
+ if(stack_valid(mix_weight_offset)) {
+ float mix_weight = stack_load_float(stack, mix_weight_offset);
+
+ if(mix_weight == 0.0f)
+ return;
+
+ ShaderClosure *sc = svm_node_closure_get(sd);
+ sc->weight *= mix_weight;
+ sc->type = CLOSURE_AMBIENT_OCCLUSION_ID;
+ }
+ else {
+ ShaderClosure *sc = svm_node_closure_get(sd);
+ sc->type = CLOSURE_AMBIENT_OCCLUSION_ID;
+ }
+
+#else
+ ShaderClosure *sc = &sd->closure;
+ sc->type = CLOSURE_AMBIENT_OCCLUSION_ID;
+#endif
+
+ sd->flag |= SD_AO;
+}
+
/* Closure Nodes */
__device_inline void svm_node_closure_store_weight(ShaderData *sd, float3 weight)
diff --git a/intern/cycles/kernel/svm/svm_geometry.h b/intern/cycles/kernel/svm/svm_geometry.h
index 501fed95002..68177493f4e 100644
--- a/intern/cycles/kernel/svm/svm_geometry.h
+++ b/intern/cycles/kernel/svm/svm_geometry.h
@@ -20,22 +20,6 @@ CCL_NAMESPACE_BEGIN
/* Geometry Node */
-__device_inline float3 svm_tangent_from_generated(float3 P)
-{
- float length = len(P);
-
- if(length == 0.0f)
- return make_float3(0.0f, 0.0f, 0.0f);
-
- float u = 0.0f;
- if(!(P.x == 0.0f && P.y == 0.0f))
- u = (1.0f - atan2f(P.x, P.y))/(2.0f*M_PI_F);
-
- float v = 1.0f - acosf(clamp(P.z/length, -1.0f, 1.0f))/M_PI_F;
-
- return make_float3(u, v, 0.0f);
-}
-
__device void svm_node_geometry(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset)
{
float3 data;
@@ -45,27 +29,19 @@ __device void svm_node_geometry(KernelGlobals *kg, ShaderData *sd, float *stack,
case NODE_GEOM_N: data = sd->N; break;
#ifdef __DPDU__
case NODE_GEOM_T: {
- if(sd->object != ~0) {
- int attr_offset = find_attribute(kg, sd, ATTR_STD_TANGENT);
-
- if(attr_offset != ATTR_STD_NOT_FOUND) {
- data = triangle_attribute_float3(kg, sd, ATTR_ELEMENT_CORNER, attr_offset, NULL, NULL);
- object_normal_transform(kg, sd, &data);
- }
- else {
- attr_offset = find_attribute(kg, sd, ATTR_STD_GENERATED);
-
- if(attr_offset != ATTR_STD_NOT_FOUND) {
- data = triangle_attribute_float3(kg, sd, ATTR_ELEMENT_VERTEX, attr_offset, NULL, NULL);
- svm_tangent_from_generated(data);
- object_normal_transform(kg, sd, &data);
- }
- else
- data = normalize(sd->dPdu);
- }
+ /* try to create spherical tangent from generated coordinates */
+ int attr_offset = (sd->object != ~0)? find_attribute(kg, sd, ATTR_STD_GENERATED): ATTR_STD_NOT_FOUND;
+
+ if(attr_offset != ATTR_STD_NOT_FOUND) {
+ data = triangle_attribute_float3(kg, sd, ATTR_ELEMENT_VERTEX, attr_offset, NULL, NULL);
+ data = make_float3(-(data.y - 0.5), (data.x - 0.5), 0.0f);
+ object_normal_transform(kg, sd, &data);
+ data = cross(sd->N, normalize(cross(data, sd->N)));;
}
- else
+ else {
+ /* otherwise use surface derivatives */
data = normalize(sd->dPdu);
+ }
break;
}
diff --git a/intern/cycles/kernel/svm/svm_image.h b/intern/cycles/kernel/svm/svm_image.h
index 9877856fec2..0894c9c8290 100644
--- a/intern/cycles/kernel/svm/svm_image.h
+++ b/intern/cycles/kernel/svm/svm_image.h
@@ -52,6 +52,12 @@ __device_inline float svm_image_texture_frac(float x, int *ix)
__device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, uint srgb)
{
+ /* first slots are used by float textures, which are not supported here */
+ if(id < TEX_NUM_FLOAT_IMAGES)
+ return make_float4(1.0f, 0.0f, 1.0f, 1.0f);
+
+ id -= TEX_NUM_FLOAT_IMAGES;
+
uint4 info = kernel_tex_fetch(__tex_image_packed_info, id);
uint width = info.x;
uint height = info.y;
diff --git a/intern/cycles/kernel/svm/svm_tex_coord.h b/intern/cycles/kernel/svm/svm_tex_coord.h
index 6bd8f2ac69c..a9449c0ded9 100644
--- a/intern/cycles/kernel/svm/svm_tex_coord.h
+++ b/intern/cycles/kernel/svm/svm_tex_coord.h
@@ -225,5 +225,91 @@ __device void svm_node_tex_coord_bump_dy(KernelGlobals *kg, ShaderData *sd, floa
#endif
}
+__device void svm_node_normal_map(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
+{
+ uint color_offset, normal_offset, space;
+ decode_node_uchar4(node.y, &color_offset, &normal_offset, &space, NULL);
+
+ float3 color = stack_load_float3(stack, color_offset);
+ color = 2.0f*make_float3(color.x - 0.5f, color.y - 0.5f, color.z - 0.5f);
+
+ if(space == NODE_NORMAL_MAP_TANGENT) {
+ /* tangent space */
+ if(sd->object == ~0) {
+ stack_store_float3(stack, normal_offset, make_float3(0.0f, 0.0f, 0.0f));
+ return;
+ }
+
+ /* first try to get tangent attribute */
+ int attr_offset = find_attribute(kg, sd, node.z);
+ int attr_sign_offset = find_attribute(kg, sd, node.w);
+
+ if(attr_offset == ATTR_STD_NOT_FOUND || attr_sign_offset == ATTR_STD_NOT_FOUND) {
+ stack_store_float3(stack, normal_offset, make_float3(0.0f, 0.0f, 0.0f));
+ return;
+ }
+
+ /* ensure orthogonal and normalized (interpolation breaks it) */
+ float3 tangent = triangle_attribute_float3(kg, sd, ATTR_ELEMENT_CORNER, attr_offset, NULL, NULL);
+ float sign = triangle_attribute_float(kg, sd, ATTR_ELEMENT_CORNER, attr_sign_offset, NULL, NULL);
+
+ object_normal_transform(kg, sd, &tangent);
+ tangent = cross(sd->N, normalize(cross(tangent, sd->N)));;
+
+ float3 B = sign * cross(sd->N, tangent);
+ float3 N = color.x * tangent + color.y * B + color.z * sd->N;
+
+ stack_store_float3(stack, normal_offset, normalize(N));
+ }
+ else {
+ /* object, world space */
+ float3 N = color;
+
+ if(space == NODE_NORMAL_MAP_OBJECT)
+ object_normal_transform(kg, sd, &N);
+
+ stack_store_float3(stack, normal_offset, normalize(N));
+ }
+}
+
+__device void svm_node_tangent(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
+{
+ uint tangent_offset, direction_type, axis;
+ decode_node_uchar4(node.y, &tangent_offset, &direction_type, &axis, NULL);
+
+ float3 tangent;
+
+ if(direction_type == NODE_TANGENT_UVMAP) {
+ /* UV map */
+ int attr_offset = find_attribute(kg, sd, node.z);
+
+ if(attr_offset == ATTR_STD_NOT_FOUND)
+ tangent = make_float3(0.0f, 0.0f, 0.0f);
+ else
+ tangent = triangle_attribute_float3(kg, sd, ATTR_ELEMENT_CORNER, attr_offset, NULL, NULL);
+ }
+ else {
+ /* radial */
+ int attr_offset = find_attribute(kg, sd, node.z);
+ float3 generated;
+
+ if(attr_offset == ATTR_STD_NOT_FOUND)
+ generated = sd->P;
+ else
+ generated = triangle_attribute_float3(kg, sd, ATTR_ELEMENT_VERTEX, attr_offset, NULL, NULL);
+
+ if(axis == NODE_TANGENT_AXIS_X)
+ tangent = make_float3(0.0f, -(generated.z - 0.5f), (generated.y - 0.5f));
+ else if(axis == NODE_TANGENT_AXIS_Y)
+ tangent = make_float3(-(generated.z - 0.5f), 0.0f, (generated.x - 0.5f));
+ else
+ tangent = make_float3(-(generated.y - 0.5f), (generated.x - 0.5f), 0.0f);
+ }
+
+ object_normal_transform(kg, sd, &tangent);
+ tangent = cross(sd->N, normalize(cross(tangent, sd->N)));
+ stack_store_float3(stack, tangent_offset, tangent);
+}
+
CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/svm/svm_types.h b/intern/cycles/kernel/svm/svm_types.h
index 77df373a159..b41e34ab407 100644
--- a/intern/cycles/kernel/svm/svm_types.h
+++ b/intern/cycles/kernel/svm/svm_types.h
@@ -94,6 +94,9 @@ typedef enum NodeType {
NODE_PARTICLE_INFO,
NODE_TEX_BRICK,
NODE_CLOSURE_SET_NORMAL,
+ NODE_CLOSURE_AMBIENT_OCCLUSION,
+ NODE_TANGENT,
+ NODE_NORMAL_MAP
} NodeType;
typedef enum NodeAttributeType {
@@ -279,6 +282,23 @@ typedef enum NodeBlendWeightType {
NODE_LAYER_WEIGHT_FACING
} NodeBlendWeightType;
+typedef enum NodeTangentDirectionType {
+ NODE_TANGENT_RADIAL,
+ NODE_TANGENT_UVMAP
+} NodeTangentDirectionType;
+
+typedef enum NodeTangentAxis {
+ NODE_TANGENT_AXIS_X,
+ NODE_TANGENT_AXIS_Y,
+ NODE_TANGENT_AXIS_Z
+} NodeTangentAxis;
+
+typedef enum NodeNormalMapSpace {
+ NODE_NORMAL_MAP_TANGENT,
+ NODE_NORMAL_MAP_OBJECT,
+ NODE_NORMAL_MAP_WORLD
+} NodeNormalMapSpace;
+
typedef enum ShaderType {
SHADER_TYPE_SURFACE,
SHADER_TYPE_VOLUME,
@@ -300,6 +320,7 @@ typedef enum ClosureType {
CLOSURE_BSDF_WARD_ID,
CLOSURE_BSDF_ASHIKHMIN_VELVET_ID,
CLOSURE_BSDF_WESTIN_SHEEN_ID,
+ CLOSURE_BSDF_PHONG_RAMP_ID,
CLOSURE_BSDF_TRANSMISSION_ID,
CLOSURE_BSDF_TRANSLUCENT_ID,
@@ -307,7 +328,9 @@ typedef enum ClosureType {
CLOSURE_BSDF_WESTIN_BACKSCATTER_ID,
CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID,
CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID,
- CLOSURE_BSDF_GLASS_ID,
+ CLOSURE_BSDF_MICROFACET_BECKMANN_GLASS_ID,
+ CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID,
+ CLOSURE_BSDF_SHARP_GLASS_ID,
CLOSURE_BSDF_TRANSPARENT_ID,
@@ -317,6 +340,7 @@ typedef enum ClosureType {
CLOSURE_BACKGROUND_ID,
CLOSURE_HOLDOUT_ID,
CLOSURE_SUBSURFACE_ID,
+ CLOSURE_AMBIENT_OCCLUSION_ID,
CLOSURE_VOLUME_ID,
CLOSURE_VOLUME_TRANSPARENT_ID,
@@ -328,12 +352,13 @@ typedef enum ClosureType {
/* watch this, being lazy with memory usage */
#define CLOSURE_IS_BSDF(type) (type <= CLOSURE_BSDF_TRANSPARENT_ID)
#define CLOSURE_IS_BSDF_DIFFUSE(type) (type >= CLOSURE_BSDF_DIFFUSE_ID && type <= CLOSURE_BSDF_OREN_NAYAR_ID)
-#define CLOSURE_IS_BSDF_GLOSSY(type) (type >= CLOSURE_BSDF_GLOSSY_ID && type <= CLOSURE_BSDF_WESTIN_SHEEN_ID)
-#define CLOSURE_IS_BSDF_TRANSMISSION(type) (type >= CLOSURE_BSDF_TRANSMISSION_ID && type <= CLOSURE_BSDF_GLASS_ID)
+#define CLOSURE_IS_BSDF_GLOSSY(type) (type >= CLOSURE_BSDF_GLOSSY_ID && type <= CLOSURE_BSDF_PHONG_RAMP_ID)
+#define CLOSURE_IS_BSDF_TRANSMISSION(type) (type >= CLOSURE_BSDF_TRANSMISSION_ID && type <= CLOSURE_BSDF_SHARP_GLASS_ID)
#define CLOSURE_IS_VOLUME(type) (type >= CLOSURE_VOLUME_ID && type <= CLOSURE_VOLUME_ISOTROPIC_ID)
#define CLOSURE_IS_EMISSION(type) (type == CLOSURE_EMISSION_ID)
#define CLOSURE_IS_HOLDOUT(type) (type == CLOSURE_HOLDOUT_ID)
#define CLOSURE_IS_BACKGROUND(type) (type == CLOSURE_BACKGROUND_ID)
+#define CLOSURE_IS_AMBIENT_OCCLUSION(type) (type == CLOSURE_AMBIENT_OCCLUSION_ID)
CCL_NAMESPACE_END
diff --git a/intern/cycles/render/attribute.cpp b/intern/cycles/render/attribute.cpp
index c7a9ab3e51a..95941c14b6c 100644
--- a/intern/cycles/render/attribute.cpp
+++ b/intern/cycles/render/attribute.cpp
@@ -162,8 +162,10 @@ Attribute *AttributeSet::add(AttributeStandard std, ustring name)
attr = add(name, TypeDesc::TypeNormal, Attribute::FACE);
else if(std == ATTR_STD_UV)
attr = add(name, TypeDesc::TypePoint, Attribute::CORNER);
- else if(std == ATTR_STD_TANGENT)
+ else if(std == ATTR_STD_UV_TANGENT)
attr = add(name, TypeDesc::TypeVector, Attribute::CORNER);
+ else if(std == ATTR_STD_UV_TANGENT_SIGN)
+ attr = add(name, TypeDesc::TypeFloat, Attribute::CORNER);
else if(std == ATTR_STD_GENERATED)
attr = add(name, TypeDesc::TypePoint, Attribute::VERTEX);
else if(std == ATTR_STD_POSITION_UNDEFORMED)
diff --git a/intern/cycles/render/buffers.cpp b/intern/cycles/render/buffers.cpp
index 6f8740b8a51..3b61ccd176d 100644
--- a/intern/cycles/render/buffers.cpp
+++ b/intern/cycles/render/buffers.cpp
@@ -101,7 +101,7 @@ RenderTile::RenderTile()
RenderBuffers::RenderBuffers(Device *device_)
{
- device = device_;
+ device = device_;
}
RenderBuffers::~RenderBuffers()
diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp
index c1c976dc193..f71675dbda3 100644
--- a/intern/cycles/render/graph.cpp
+++ b/intern/cycles/render/graph.cpp
@@ -326,6 +326,7 @@ void ShaderGraph::remove_proxy_nodes(vector<bool>& removed)
/* transfer the default input value to the target socket */
to->set(input->value);
+ to->set(input->value_string);
}
}
diff --git a/intern/cycles/render/graph.h b/intern/cycles/render/graph.h
index b339c3c3847..373c7e0eaab 100644
--- a/intern/cycles/render/graph.h
+++ b/intern/cycles/render/graph.h
@@ -49,7 +49,8 @@ enum ShaderSocketType {
SHADER_SOCKET_VECTOR,
SHADER_SOCKET_POINT,
SHADER_SOCKET_NORMAL,
- SHADER_SOCKET_CLOSURE
+ SHADER_SOCKET_CLOSURE,
+ SHADER_SOCKET_STRING
};
/* Bump
@@ -120,6 +121,7 @@ public:
ShaderInput(ShaderNode *parent, const char *name, ShaderSocketType type);
void set(const float3& v) { value = v; }
void set(float f) { value = make_float3(f, 0, 0); }
+ void set(const ustring v) { value_string = v; }
const char *name;
ShaderSocketType type;
@@ -129,6 +131,7 @@ public:
DefaultValue default_value;
float3 value;
+ ustring value_string;
int stack_offset; /* for SVM compiler */
bool osl_only;
diff --git a/intern/cycles/render/image.h b/intern/cycles/render/image.h
index 8fb229282dc..485bfc5cbf5 100644
--- a/intern/cycles/render/image.h
+++ b/intern/cycles/render/image.h
@@ -25,9 +25,10 @@
#include "util_thread.h"
#include "util_vector.h"
+#include "kernel_types.h" /* for TEX_NUM_FLOAT_IMAGES */
+
CCL_NAMESPACE_BEGIN
-#define TEX_NUM_FLOAT_IMAGES 5
#define TEX_NUM_IMAGES 95
#define TEX_IMAGE_BYTE_START TEX_NUM_FLOAT_IMAGES
diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp
index 13c06a922cc..1958cfc10f7 100644
--- a/intern/cycles/render/mesh.cpp
+++ b/intern/cycles/render/mesh.cpp
@@ -325,6 +325,7 @@ void MeshManager::update_osl_attributes(Device *device, Scene *scene, vector<Att
og->object_name_map.clear();
og->attribute_map.clear();
+ og->object_names.clear();
og->attribute_map.resize(scene->objects.size());
@@ -332,6 +333,7 @@ void MeshManager::update_osl_attributes(Device *device, Scene *scene, vector<Att
/* set object name to object index map */
Object *object = scene->objects[i];
og->object_name_map[object->name] = i;
+ og->object_names.push_back(object->name);
/* set object attributes */
foreach(ParamValue& attr, object->attributes) {
@@ -355,6 +357,9 @@ void MeshManager::update_osl_attributes(Device *device, Scene *scene, vector<Att
/* set object attributes */
foreach(AttributeRequest& req, attributes.requests) {
+ if(req.element == ATTR_ELEMENT_NONE)
+ continue;
+
OSLGlobals::Attribute osl_attr;
osl_attr.elem = req.element;
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 42ab3fe17aa..4f50de11edf 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -1214,7 +1214,7 @@ BsdfNode::BsdfNode()
add_output("BSDF", SHADER_SOCKET_CLOSURE);
}
-void BsdfNode::compile(SVMCompiler& compiler, ShaderInput *param1, ShaderInput *param2)
+void BsdfNode::compile(SVMCompiler& compiler, ShaderInput *param1, ShaderInput *param2, ShaderInput *param3)
{
ShaderInput *color_in = input("Color");
ShaderInput *normal_in = input("Normal");
@@ -1231,6 +1231,14 @@ void BsdfNode::compile(SVMCompiler& compiler, ShaderInput *param1, ShaderInput *
compiler.stack_assign(param1);
if(param2)
compiler.stack_assign(param2);
+ if(param3)
+ compiler.stack_assign(param3);
+
+ if(normal_in->link)
+ compiler.stack_assign(normal_in);
+
+ if(tangent_in && tangent_in->link)
+ compiler.stack_assign(tangent_in);
compiler.add_node(NODE_CLOSURE_BSDF,
compiler.encode_uchar4(closure,
@@ -1240,14 +1248,9 @@ void BsdfNode::compile(SVMCompiler& compiler, ShaderInput *param1, ShaderInput *
__float_as_int((param1)? param1->value.x: 0.0f),
__float_as_int((param2)? param2->value.x: 0.0f));
- if(normal_in->link)
- compiler.stack_assign(normal_in);
-
if(tangent_in) {
- if(tangent_in->link)
- compiler.stack_assign(tangent_in);
-
- compiler.add_node(NODE_CLOSURE_BSDF, normal_in->stack_offset, tangent_in->stack_offset);
+ compiler.add_node(NODE_CLOSURE_BSDF, normal_in->stack_offset, tangent_in->stack_offset,
+ (param3)? param3->stack_offset: SVM_STACK_INVALID);
}
else {
compiler.add_node(NODE_CLOSURE_BSDF, normal_in->stack_offset);
@@ -1272,25 +1275,24 @@ WardBsdfNode::WardBsdfNode()
add_input("Tangent", SHADER_SOCKET_VECTOR, ShaderInput::TANGENT);
- add_input("Roughness U", SHADER_SOCKET_FLOAT, 0.2f);
- add_input("Roughness V", SHADER_SOCKET_FLOAT, 0.2f);
+ add_input("Roughness", SHADER_SOCKET_FLOAT, 0.2f);
+ add_input("Anisotropy", SHADER_SOCKET_FLOAT, 0.5f);
+ add_input("Rotation", SHADER_SOCKET_FLOAT, 0.0f);
}
void WardBsdfNode::attributes(AttributeRequestSet *attributes)
{
ShaderInput *tangent_in = input("Tangent");
- if(!tangent_in->link) {
- attributes->add(ATTR_STD_TANGENT);
+ if(!tangent_in->link)
attributes->add(ATTR_STD_GENERATED);
- }
ShaderNode::attributes(attributes);
}
void WardBsdfNode::compile(SVMCompiler& compiler)
{
- BsdfNode::compile(compiler, input("Roughness U"), input("Roughness V"));
+ BsdfNode::compile(compiler, input("Roughness"), input("Anisotropy"), input("Rotation"));
}
void WardBsdfNode::compile(OSLCompiler& compiler)
@@ -1342,9 +1344,9 @@ static ShaderEnum glass_distribution_init()
{
ShaderEnum enm;
- enm.insert("Sharp", CLOSURE_BSDF_REFRACTION_ID);
- enm.insert("Beckmann", CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID);
- enm.insert("GGX", CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID);
+ enm.insert("Sharp", CLOSURE_BSDF_SHARP_GLASS_ID);
+ enm.insert("Beckmann", CLOSURE_BSDF_MICROFACET_BECKMANN_GLASS_ID);
+ enm.insert("GGX", CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID);
return enm;
}
@@ -1363,7 +1365,7 @@ void GlassBsdfNode::compile(SVMCompiler& compiler)
{
closure = (ClosureType)distribution_enum[distribution];
- if(closure == CLOSURE_BSDF_REFRACTION_ID)
+ if(closure == CLOSURE_BSDF_SHARP_GLASS_ID)
BsdfNode::compile(compiler, NULL, input("IOR"));
else
BsdfNode::compile(compiler, input("Roughness"), input("IOR"));
@@ -1375,6 +1377,45 @@ void GlassBsdfNode::compile(OSLCompiler& compiler)
compiler.add(this, "node_glass_bsdf");
}
+/* Refraction BSDF Closure */
+
+static ShaderEnum refraction_distribution_init()
+{
+ ShaderEnum enm;
+
+ enm.insert("Sharp", CLOSURE_BSDF_REFRACTION_ID);
+ enm.insert("Beckmann", CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID);
+ enm.insert("GGX", CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID);
+
+ return enm;
+}
+
+ShaderEnum RefractionBsdfNode::distribution_enum = refraction_distribution_init();
+
+RefractionBsdfNode::RefractionBsdfNode()
+{
+ distribution = ustring("Sharp");
+
+ add_input("Roughness", SHADER_SOCKET_FLOAT, 0.0f);
+ add_input("IOR", SHADER_SOCKET_FLOAT, 0.3f);
+}
+
+void RefractionBsdfNode::compile(SVMCompiler& compiler)
+{
+ closure = (ClosureType)distribution_enum[distribution];
+
+ if(closure == CLOSURE_BSDF_REFRACTION_ID)
+ BsdfNode::compile(compiler, NULL, input("IOR"));
+ else
+ BsdfNode::compile(compiler, input("Roughness"), input("IOR"));
+}
+
+void RefractionBsdfNode::compile(OSLCompiler& compiler)
+{
+ compiler.parameter("distribution", distribution);
+ compiler.add(this, "node_refraction_bsdf");
+}
+
/* Velvet BSDF Closure */
VelvetBsdfNode::VelvetBsdfNode()
@@ -1532,6 +1573,34 @@ void HoldoutNode::compile(OSLCompiler& compiler)
compiler.add(this, "node_holdout");
}
+/* Ambient Occlusion */
+
+AmbientOcclusionNode::AmbientOcclusionNode()
+: ShaderNode("ambient_occlusion")
+{
+ add_input("Color", SHADER_SOCKET_COLOR, make_float3(0.8f, 0.8f, 0.8f));
+ add_output("AO", SHADER_SOCKET_CLOSURE);
+}
+
+void AmbientOcclusionNode::compile(SVMCompiler& compiler)
+{
+ ShaderInput *color_in = input("Color");
+
+ if(color_in->link) {
+ compiler.stack_assign(color_in);
+ compiler.add_node(NODE_CLOSURE_WEIGHT, color_in->stack_offset);
+ }
+ else
+ compiler.add_node(NODE_CLOSURE_SET_WEIGHT, color_in->value);
+
+ compiler.add_node(NODE_CLOSURE_AMBIENT_OCCLUSION, compiler.closure_mix_weight_offset());
+}
+
+void AmbientOcclusionNode::compile(OSLCompiler& compiler)
+{
+ compiler.add(this, "node_ambient_occlusion");
+}
+
/* Volume Closure */
VolumeNode::VolumeNode()
@@ -1631,10 +1700,8 @@ GeometryNode::GeometryNode()
void GeometryNode::attributes(AttributeRequestSet *attributes)
{
- if(!output("Tangent")->links.empty()) {
- attributes->add(ATTR_STD_TANGENT);
+ if(!output("Tangent")->links.empty())
attributes->add(ATTR_STD_GENERATED);
- }
ShaderNode::attributes(attributes);
}
@@ -2071,13 +2138,14 @@ void ParticleInfoNode::compile(SVMCompiler& compiler)
compiler.add_node(NODE_PARTICLE_INFO, NODE_INFO_PAR_LOCATION, out->stack_offset);
}
- #if 0 /* XXX Quaternion data is not yet supported by Cycles */
+ /* quaternion data is not yet supported by Cycles */
+#if 0
out = output("Rotation");
if(!out->links.empty()) {
compiler.stack_assign(out);
compiler.add_node(NODE_PARTICLE_INFO, NODE_INFO_PAR_ROTATION, out->stack_offset);
}
- #endif
+#endif
out = output("Size");
if(!out->links.empty()) {
@@ -2942,5 +3010,181 @@ void OSLScriptNode::compile(OSLCompiler& compiler)
compiler.add(this, bytecode_hash.c_str(), false);
}
+/* Normal Map */
+
+static ShaderEnum normal_map_space_init()
+{
+ ShaderEnum enm;
+
+ enm.insert("Tangent", NODE_NORMAL_MAP_TANGENT);
+ enm.insert("Object", NODE_NORMAL_MAP_OBJECT);
+ enm.insert("World", NODE_NORMAL_MAP_WORLD);
+
+ return enm;
+}
+
+ShaderEnum NormalMapNode::space_enum = normal_map_space_init();
+
+NormalMapNode::NormalMapNode()
+: ShaderNode("normal_map")
+{
+ space = ustring("Tangent");
+ attribute = ustring("");
+
+ add_input("NormalIn", SHADER_SOCKET_NORMAL, ShaderInput::NORMAL, true);
+ add_input("Color", SHADER_SOCKET_COLOR);
+ add_output("Normal", SHADER_SOCKET_NORMAL);
+}
+
+void NormalMapNode::attributes(AttributeRequestSet *attributes)
+{
+ if(space == ustring("Tangent")) {
+ if(attribute == ustring("")) {
+ attributes->add(ATTR_STD_UV_TANGENT);
+ attributes->add(ATTR_STD_UV_TANGENT_SIGN);
+ }
+ else {
+ attributes->add(ustring((string(attribute.c_str()) + ".tangent").c_str()));
+ attributes->add(ustring((string(attribute.c_str()) + ".tangent_sign").c_str()));
+ }
+ }
+
+ ShaderNode::attributes(attributes);
+}
+
+void NormalMapNode::compile(SVMCompiler& compiler)
+{
+ ShaderInput *color_in = input("Color");
+ ShaderOutput *normal_out = output("Normal");
+ int attr = 0, attr_sign = 0;
+
+ if(space == ustring("Tangent")) {
+ if(attribute == ustring("")) {
+ attr = compiler.attribute(ATTR_STD_UV_TANGENT);
+ attr_sign = compiler.attribute(ATTR_STD_UV_TANGENT_SIGN);
+ }
+ else {
+ attr = compiler.attribute(ustring((string(attribute.c_str()) + ".tangent").c_str()));
+ attr_sign = compiler.attribute(ustring((string(attribute.c_str()) + ".tangent_sign").c_str()));
+ }
+ }
+
+ compiler.stack_assign(color_in);
+ compiler.stack_assign(normal_out);
+
+ compiler.add_node(NODE_NORMAL_MAP,
+ compiler.encode_uchar4(
+ color_in->stack_offset,
+ normal_out->stack_offset,
+ space_enum[space]),
+ attr, attr_sign);
+}
+
+void NormalMapNode::compile(OSLCompiler& compiler)
+{
+ if(space == ustring("Tangent")) {
+ if(attribute == ustring("")) {
+ compiler.parameter("attr_name", ustring("geom:tangent"));
+ compiler.parameter("attr_sign_name", ustring("geom:tangent_sign"));
+ }
+ else {
+ compiler.parameter("attr_name", ustring((string(attribute.c_str()) + ".tangent").c_str()));
+ compiler.parameter("attr_sign_name", ustring((string(attribute.c_str()) + ".tangent_sign").c_str()));
+ }
+ }
+
+ compiler.parameter("space", space);
+
+ compiler.add(this, "node_normal_map");
+}
+
+/* Tangent */
+
+static ShaderEnum tangent_direction_type_init()
+{
+ ShaderEnum enm;
+
+ enm.insert("Radial", NODE_TANGENT_RADIAL);
+ enm.insert("UV Map", NODE_TANGENT_UVMAP);
+
+ return enm;
+}
+
+static ShaderEnum tangent_axis_init()
+{
+ ShaderEnum enm;
+
+ enm.insert("X", NODE_TANGENT_AXIS_X);
+ enm.insert("Y", NODE_TANGENT_AXIS_Y);
+ enm.insert("Z", NODE_TANGENT_AXIS_Z);
+
+ return enm;
+}
+
+ShaderEnum TangentNode::direction_type_enum = tangent_direction_type_init();
+ShaderEnum TangentNode::axis_enum = tangent_axis_init();
+
+TangentNode::TangentNode()
+: ShaderNode("normal_map")
+{
+ direction_type = ustring("Radial");
+ axis = ustring("X");
+ attribute = ustring("");
+
+ add_input("NormalIn", SHADER_SOCKET_NORMAL, ShaderInput::NORMAL, true);
+ add_output("Tangent", SHADER_SOCKET_NORMAL);
+}
+
+void TangentNode::attributes(AttributeRequestSet *attributes)
+{
+ if(direction_type == ustring("UV Map")) {
+ if(attribute == ustring(""))
+ attributes->add(ATTR_STD_UV_TANGENT);
+ else
+ attributes->add(ustring((string(attribute.c_str()) + ".tangent").c_str()));
+ }
+ else
+ attributes->add(ATTR_STD_GENERATED);
+
+ ShaderNode::attributes(attributes);
+}
+
+void TangentNode::compile(SVMCompiler& compiler)
+{
+ ShaderOutput *tangent_out = output("Tangent");
+ int attr;
+
+ if(direction_type == ustring("UV Map")) {
+ if(attribute == ustring(""))
+ attr = compiler.attribute(ATTR_STD_UV_TANGENT);
+ else
+ attr = compiler.attribute(ustring((string(attribute.c_str()) + ".tangent").c_str()));
+ }
+ else
+ attr = compiler.attribute(ATTR_STD_GENERATED);
+
+ compiler.stack_assign(tangent_out);
+
+ compiler.add_node(NODE_TANGENT,
+ compiler.encode_uchar4(
+ tangent_out->stack_offset,
+ direction_type_enum[direction_type],
+ axis_enum[axis]), attr);
+}
+
+void TangentNode::compile(OSLCompiler& compiler)
+{
+ if(direction_type == ustring("UV Map")) {
+ if(attribute == ustring(""))
+ compiler.parameter("attr_name", ustring("geom:tangent"));
+ else
+ compiler.parameter("attr_name", ustring((string(attribute.c_str()) + ".tangent").c_str()));
+ }
+
+ compiler.parameter("direction_type", direction_type);
+ compiler.parameter("axis", axis);
+ compiler.add(this, "node_tangent");
+}
+
CCL_NAMESPACE_END
diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h
index 0508bf6b266..27b07769e28 100644
--- a/intern/cycles/render/nodes.h
+++ b/intern/cycles/render/nodes.h
@@ -193,7 +193,7 @@ class BsdfNode : public ShaderNode {
public:
SHADER_NODE_CLASS(BsdfNode)
- void compile(SVMCompiler& compiler, ShaderInput *param1, ShaderInput *param2);
+ void compile(SVMCompiler& compiler, ShaderInput *param1, ShaderInput *param2, ShaderInput *param3 = NULL);
ClosureType closure;
};
@@ -240,6 +240,14 @@ public:
static ShaderEnum distribution_enum;
};
+class RefractionBsdfNode : public BsdfNode {
+public:
+ SHADER_NODE_CLASS(RefractionBsdfNode)
+
+ ustring distribution;
+ static ShaderEnum distribution_enum;
+};
+
class EmissionNode : public ShaderNode {
public:
SHADER_NODE_CLASS(EmissionNode)
@@ -257,6 +265,11 @@ public:
SHADER_NODE_CLASS(HoldoutNode)
};
+class AmbientOcclusionNode : public ShaderNode {
+public:
+ SHADER_NODE_CLASS(AmbientOcclusionNode)
+};
+
class VolumeNode : public ShaderNode {
public:
SHADER_NODE_CLASS(VolumeNode)
@@ -457,6 +470,31 @@ public:
vector<ustring> output_names;
};
+class NormalMapNode : public ShaderNode {
+public:
+ SHADER_NODE_CLASS(NormalMapNode)
+ void attributes(AttributeRequestSet *attributes);
+
+ ustring space;
+ static ShaderEnum space_enum;
+
+ ustring attribute;
+};
+
+class TangentNode : public ShaderNode {
+public:
+ SHADER_NODE_CLASS(TangentNode)
+ void attributes(AttributeRequestSet *attributes);
+
+ ustring direction_type;
+ static ShaderEnum direction_type_enum;
+
+ ustring axis;
+ static ShaderEnum axis_enum;
+
+ ustring attribute;
+};
+
CCL_NAMESPACE_END
#endif /* __NODES_H__ */
diff --git a/intern/cycles/render/osl.cpp b/intern/cycles/render/osl.cpp
index a8a40a4e596..8bdb09eaf70 100644
--- a/intern/cycles/render/osl.cpp
+++ b/intern/cycles/render/osl.cpp
@@ -403,6 +403,9 @@ void OSLCompiler::add(ShaderNode *node, const char *name, bool isfilepath)
case SHADER_SOCKET_INT:
parameter(param_name.c_str(), (int)input->value.x);
break;
+ case SHADER_SOCKET_STRING:
+ parameter(param_name.c_str(), input->value_string);
+ break;
case SHADER_SOCKET_CLOSURE:
break;
}
diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp
index bf8d8ade37d..7303cb52ad8 100644
--- a/intern/cycles/render/session.cpp
+++ b/intern/cycles/render/session.cpp
@@ -42,13 +42,14 @@ Session::Session(const SessionParams& params_)
: params(params_),
tile_manager(params.progressive, params.samples, params.tile_size, params.start_resolution,
params.background == false || params.progressive_refine, params.background,
- max(params.device.multi_devices.size(), 1))
+ max(params.device.multi_devices.size(), 1)),
+ stats()
{
device_use_gl = ((params.device.type != DEVICE_CPU) && !params.background);
TaskScheduler::init(params.threads);
- device = Device::create(params.device, params.background, params.threads);
+ device = Device::create(params.device, stats, params.background, params.threads);
if(params.background) {
buffers = NULL;
@@ -711,10 +712,13 @@ void Session::update_status_time(bool show_pause, bool show_done)
string status, substatus;
if(!params.progressive) {
+ bool is_gpu = params.device.type == DEVICE_CUDA || params.device.type == DEVICE_OPENCL;
+ bool is_multidevice = params.device.multi_devices.size() > 1;
+ bool is_cpu = params.device.type == DEVICE_CPU;
+
substatus = string_printf("Path Tracing Tile %d/%d", tile, num_tiles);
- if(params.device.type == DEVICE_CUDA || params.device.type == DEVICE_OPENCL ||
- (params.device.type == DEVICE_CPU && num_tiles == 1)) {
+ if((is_gpu && !is_multidevice) || (is_cpu && num_tiles == 1)) {
/* when rendering on GPU multithreading happens within single tile, as in
* tiles are handling sequentially and in this case we could display
* currently rendering sample number
diff --git a/intern/cycles/render/session.h b/intern/cycles/render/session.h
index 8941c6ac459..7bb0cd1ae01 100644
--- a/intern/cycles/render/session.h
+++ b/intern/cycles/render/session.h
@@ -24,6 +24,7 @@
#include "tile.h"
#include "util_progress.h"
+#include "util_stats.h"
#include "util_thread.h"
#include "util_vector.h"
@@ -112,6 +113,7 @@ public:
Progress progress;
SessionParams params;
TileManager tile_manager;
+ Stats stats;
boost::function<void(RenderTile&)> write_render_tile_cb;
boost::function<void(RenderTile&)> update_render_tile_cb;
diff --git a/intern/cycles/render/tile.cpp b/intern/cycles/render/tile.cpp
index c294239bac0..bbcdb47260e 100644
--- a/intern/cycles/render/tile.cpp
+++ b/intern/cycles/render/tile.cpp
@@ -84,8 +84,6 @@ void TileManager::gen_tiles_global()
int tile_w = (tile_size.x >= image_w)? 1: (image_w + tile_size.x - 1)/tile_size.x;
int tile_h = (tile_size.y >= image_h)? 1: (image_h + tile_size.y - 1)/tile_size.y;
- int sub_w = (image_w + tile_w - 1)/tile_w;
- int sub_h = (image_h + tile_h - 1)/tile_h;
int num_logical_devices = preserve_tile_device? num_devices: 1;
int num = min(image_h, num_logical_devices);
@@ -96,10 +94,10 @@ void TileManager::gen_tiles_global()
for(int tile_y = 0; tile_y < tile_h; tile_y++) {
for(int tile_x = 0; tile_x < tile_w; tile_x++, tile_index++) {
- int x = tile_x * sub_w;
- int y = tile_y * sub_h;
- int w = (tile_x == tile_w-1)? image_w - x: sub_w;
- int h = (tile_y == tile_h-1)? image_h - y: sub_h;
+ int x = tile_x * tile_size.x;
+ int y = tile_y * tile_size.y;
+ int w = (tile_x == tile_w-1)? image_w - x: tile_size.x;
+ int h = (tile_y == tile_h-1)? image_h - y: tile_size.y;
state.tiles.push_back(Tile(tile_index, x, y, w, h, cur_device));
cur_tiles++;
@@ -131,15 +129,13 @@ void TileManager::gen_tiles_sliced()
int tile_w = (tile_size.x >= image_w)? 1: (image_w + tile_size.x - 1)/tile_size.x;
int tile_h = (tile_size.y >= device_h)? 1: (device_h + tile_size.y - 1)/tile_size.y;
- int sub_w = (image_w + tile_w - 1)/tile_w;
- int sub_h = (device_h + tile_h - 1)/tile_h;
for(int tile_y = 0; tile_y < tile_h; tile_y++) {
for(int tile_x = 0; tile_x < tile_w; tile_x++, tile_index++) {
- int x = tile_x * sub_w;
- int y = tile_y * sub_h;
- int w = (tile_x == tile_w-1)? image_w - x: sub_w;
- int h = (tile_y == tile_h-1)? device_h - y: sub_h;
+ int x = tile_x * tile_size.x;
+ int y = tile_y * tile_size.y;
+ int w = (tile_x == tile_w-1)? image_w - x: tile_size.x;
+ int h = (tile_y == tile_h-1)? device_h - y: tile_size.y;
state.tiles.push_back(Tile(tile_index, x, y + device_y, w, h, device));
}
diff --git a/intern/cycles/util/util_attribute.cpp b/intern/cycles/util/util_attribute.cpp
index 3a1c2b6f332..057fb6213e9 100644
--- a/intern/cycles/util/util_attribute.cpp
+++ b/intern/cycles/util/util_attribute.cpp
@@ -30,6 +30,10 @@ const char *attribute_standard_name(AttributeStandard std)
return "uv";
else if(std == ATTR_STD_GENERATED)
return "generated";
+ else if(std == ATTR_STD_UV_TANGENT)
+ return "tangent";
+ else if(std == ATTR_STD_UV_TANGENT_SIGN)
+ return "tangent_sign";
else if(std == ATTR_STD_POSITION_UNDEFORMED)
return "undeformed";
else if(std == ATTR_STD_POSITION_UNDISPLACED)
diff --git a/intern/cycles/util/util_math.h b/intern/cycles/util/util_math.h
index 0b6f020ade5..70adee4385b 100644
--- a/intern/cycles/util/util_math.h
+++ b/intern/cycles/util/util_math.h
@@ -1069,6 +1069,29 @@ __device_inline float3 safe_divide_color(float3 a, float3 b)
return make_float3(x, y, z);
}
+/* Rotation of point around axis and angle */
+
+__device_inline float3 rotate_around_axis(float3 p, float3 axis, float angle)
+{
+ float costheta = cosf(angle);
+ float sintheta = sinf(angle);
+ float3 r;
+
+ r.x = ((costheta + (1 - costheta) * axis.x * axis.x) * p.x) +
+ (((1 - costheta) * axis.x * axis.y - axis.z * sintheta) * p.y) +
+ (((1 - costheta) * axis.x * axis.z + axis.y * sintheta) * p.z);
+
+ r.y = (((1 - costheta) * axis.x * axis.y + axis.z * sintheta) * p.x) +
+ ((costheta + (1 - costheta) * axis.y * axis.y) * p.y) +
+ (((1 - costheta) * axis.y * axis.z - axis.x * sintheta) * p.z);
+
+ r.z = (((1 - costheta) * axis.x * axis.z - axis.y * sintheta) * p.x) +
+ (((1 - costheta) * axis.y * axis.z + axis.x * sintheta) * p.y) +
+ ((costheta + (1 - costheta) * axis.z * axis.z) * p.z);
+
+ return r;
+}
+
CCL_NAMESPACE_END
#endif /* __UTIL_MATH_H__ */
diff --git a/intern/cycles/util/util_opencl.cpp b/intern/cycles/util/util_opencl.cpp
index 40b637f5cb7..c146c14b10c 100644
--- a/intern/cycles/util/util_opencl.cpp
+++ b/intern/cycles/util/util_opencl.cpp
@@ -140,6 +140,10 @@ int clLibraryInit()
#endif
int error = 0;
+ // OpenCL disabled for now, only works with this environment variable set
+ if(!getenv("CYCLES_OPENCL_TEST"))
+ return 0;
+
// Check if already initialized
if (module != NULL)
{
diff --git a/intern/cycles/util/util_stats.h b/intern/cycles/util/util_stats.h
new file mode 100644
index 00000000000..405c81a1e1f
--- /dev/null
+++ b/intern/cycles/util/util_stats.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __UTIL_STATS_H__
+#define __UTIL_STATS_H__
+
+#include "util_thread.h"
+
+CCL_NAMESPACE_BEGIN
+
+class Stats {
+public:
+ Stats() : lock(), mem_used(0), mem_peak(0) {}
+
+ void mem_alloc(size_t size) {
+ lock.lock();
+
+ mem_used += size;
+ if(mem_used > mem_peak)
+ mem_peak = mem_used;
+
+ lock.unlock();
+ }
+
+ void mem_free(size_t size) {
+ lock.lock();
+ mem_used -= size;
+ lock.unlock();
+ }
+
+ spin_lock lock;
+ size_t mem_used;
+ size_t mem_peak;
+};
+
+CCL_NAMESPACE_END
+
+#endif /* __UTIL_STATS_H__ */
diff --git a/intern/cycles/util/util_thread.h b/intern/cycles/util/util_thread.h
index 843764ca9d6..6d1bd0023a7 100644
--- a/intern/cycles/util/util_thread.h
+++ b/intern/cycles/util/util_thread.h
@@ -33,6 +33,9 @@ typedef boost::mutex thread_mutex;
typedef boost::mutex::scoped_lock thread_scoped_lock;
typedef boost::condition_variable thread_condition_variable;
+/* use boost for spinlocks as well */
+typedef boost::detail::spinlock spin_lock;
+
/* own pthread based implementation, to avoid boost version conflicts with
* dynamically loaded blender plugins */
diff --git a/intern/cycles/util/util_types.h b/intern/cycles/util/util_types.h
index f2c02cadcbf..fe530d727ad 100644
--- a/intern/cycles/util/util_types.h
+++ b/intern/cycles/util/util_types.h
@@ -449,7 +449,8 @@ typedef enum AttributeStandard {
ATTR_STD_VERTEX_NORMAL,
ATTR_STD_FACE_NORMAL,
ATTR_STD_UV,
- ATTR_STD_TANGENT,
+ ATTR_STD_UV_TANGENT,
+ ATTR_STD_UV_TANGENT_SIGN,
ATTR_STD_GENERATED,
ATTR_STD_POSITION_UNDEFORMED,
ATTR_STD_POSITION_UNDISPLACED,
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm
index 27720a01a3f..475ad2bdcb3 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -423,7 +423,7 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction)
#pragma mark defines for 10.6 api not documented in 10.5
-#ifndef MAC_OS_X_VERSION_10_6
+#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
enum {
/* The following event types are available on some hardware on 10.5.2 and later */
NSEventTypeGesture = 29,
@@ -435,12 +435,10 @@ enum {
};
@interface NSEvent(GestureEvents)
-/* This message is valid for events of type NSEventTypeMagnify, on 10.5.2 or later */
-#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
- (float)magnification; // change in magnification.
#else
-- (CGFloat)magnification; // change in magnification.
-#endif
+@interface NSEvent(GestureEvents)
+- (CGFloat)magnification; // change in magnification on 10.5.2 or later.
@end
#endif
diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp
index 52ebaf02404..46c71f57c6f 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -742,8 +742,6 @@ GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_IWindow *window, RAWINP
ascii = utf8_char[0] & 0x80 ? '?' : utf8_char[0];
}
- if (0x80 & state[VK_MENU]) utf8_char[0] = '\0';
-
event = new GHOST_EventKey(system->getMilliSeconds(), keyDown ? GHOST_kEventKeyDown : GHOST_kEventKeyUp, window, key, ascii, utf8_char);
#ifdef GHOST_DEBUG
diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm
index 23eefe17959..01705fe8f7b 100644
--- a/intern/ghost/intern/GHOST_WindowCocoa.mm
+++ b/intern/ghost/intern/GHOST_WindowCocoa.mm
@@ -28,7 +28,7 @@
#include <Cocoa/Cocoa.h>
-#ifndef MAC_OS_X_VERSION_10_6
+#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_5
//Use of the SetSystemUIMode function (64bit compatible)
#include <Carbon/Carbon.h>
#endif
@@ -58,7 +58,7 @@ extern "C" {
extern void wm_draw_update(bContext *C);
};*/
@interface CocoaWindowDelegate : NSObject
-#ifdef MAC_OS_X_VERSION_10_6
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
<NSWindowDelegate>
#endif
{
@@ -115,12 +115,12 @@ extern "C" {
- (void)windowDidResize:(NSNotification *)notification
{
-#ifdef MAC_OS_X_VERSION_10_6
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
//if (![[notification object] inLiveResize]) {
//Send event only once, at end of resize operation (when user has released mouse button)
#endif
systemCocoa->handleWindowEvent(GHOST_kEventWindowSize, associatedWindow);
-#ifdef MAC_OS_X_VERSION_10_6
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
//}
#endif
/* Live resize ugly patch. Needed because live resize runs in a modal loop, not letting main loop run
@@ -913,7 +913,7 @@ GHOST_TSuccess GHOST_WindowCocoa::setState(GHOST_TWindowState state)
* doesn't know view/window difference. */
m_fullScreen = true;
-#ifdef MAC_OS_X_VERSION_10_6
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
//10.6 provides Cocoa functions to autoshow menu bar, and to change a window style
//Hide menu & dock if needed
if ([[m_window screen] isEqual:[[NSScreen screens] objectAtIndex:0]]) {
@@ -972,7 +972,7 @@ GHOST_TSuccess GHOST_WindowCocoa::setState(GHOST_TWindowState state)
m_fullScreen = false;
//Exit fullscreen
-#ifdef MAC_OS_X_VERSION_10_6
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
//Show again menu & dock if needed
if ([[m_window screen] isEqual:[NSScreen mainScreen]]) {
[NSApp setPresentationOptions:NSApplicationPresentationDefault];
diff --git a/intern/itasc/kdl/chain.hpp b/intern/itasc/kdl/chain.hpp
index 773f472cc5c..24e40858bff 100644
--- a/intern/itasc/kdl/chain.hpp
+++ b/intern/itasc/kdl/chain.hpp
@@ -35,7 +35,7 @@ namespace KDL {
*/
class Chain {
private:
-#if !defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_5)
+#if !defined(__APPLE__)
// Eigen allocator is needed for alignment of Eigen data types
std::vector<Segment, Eigen::aligned_allocator<Segment> > segments;
#else
diff --git a/intern/itasc/kdl/tree.hpp b/intern/itasc/kdl/tree.hpp
index 08c1aadc6de..4da764ac6d6 100644
--- a/intern/itasc/kdl/tree.hpp
+++ b/intern/itasc/kdl/tree.hpp
@@ -27,7 +27,7 @@
#include <string>
#include <map>
-#if !defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_5)
+#if !defined(__APPLE__)
#include <Eigen/Core>
#endif
@@ -35,7 +35,7 @@ namespace KDL
{
//Forward declaration
class TreeElement;
-#if !defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_5)
+#if !defined(__APPLE__)
// Eigen allocator is needed for alignment of Eigen data types
typedef std::map<std::string,TreeElement, std::less<std::string>, Eigen::aligned_allocator<std::pair<std::string, TreeElement> > > SegmentMap;
#else
diff --git a/release/datafiles/blender_icons.png b/release/datafiles/blender_icons.png
index 55a83964a8b..257de8ae3c8 100644
--- a/release/datafiles/blender_icons.png
+++ b/release/datafiles/blender_icons.png
Binary files differ
diff --git a/release/datafiles/prvicons.png b/release/datafiles/prvicons.png
index dc31964b33f..1636e644b12 100644
--- a/release/datafiles/prvicons.png
+++ b/release/datafiles/prvicons.png
Binary files differ
diff --git a/release/scripts/modules/bl_i18n_utils/spell_check_utils.py b/release/scripts/modules/bl_i18n_utils/spell_check_utils.py
index 60a943d2bd4..34eab11f9d4 100644
--- a/release/scripts/modules/bl_i18n_utils/spell_check_utils.py
+++ b/release/scripts/modules/bl_i18n_utils/spell_check_utils.py
@@ -77,6 +77,7 @@ dict_uimsgs = {
"boxpack",
"buffersize",
"builtin", "builtins",
+ "bytecode",
"chunksize",
"de",
"defocus",
@@ -502,6 +503,8 @@ dict_uimsgs = {
"mtl",
"ogg",
"openjpeg",
+ "osl",
+ "oso",
"piz",
"png",
"po",
diff --git a/release/scripts/startup/bl_ui/properties_data_camera.py b/release/scripts/startup/bl_ui/properties_data_camera.py
index c8d3bf65ef6..5f6036c8945 100644
--- a/release/scripts/startup/bl_ui/properties_data_camera.py
+++ b/release/scripts/startup/bl_ui/properties_data_camera.py
@@ -88,7 +88,8 @@ class DATA_PT_lens(CameraButtonsPanel, Panel):
col.prop(cam, "ortho_scale")
elif cam.type == 'PANO':
- if context.scene.render.engine == 'CYCLES':
+ engine = context.scene.render.engine
+ if engine == 'CYCLES':
ccam = cam.cycles
col.prop(ccam, "panorama_type", text="Type")
if ccam.panorama_type == 'FISHEYE_EQUIDISTANT':
@@ -97,6 +98,13 @@ class DATA_PT_lens(CameraButtonsPanel, Panel):
row = layout.row()
row.prop(ccam, "fisheye_lens", text="Lens")
row.prop(ccam, "fisheye_fov")
+ elif engine == 'BLENDER_RENDER':
+ row = col.row()
+ if cam.lens_unit == 'MILLIMETERS':
+ row.prop(cam, "lens")
+ elif cam.lens_unit == 'DEGREES':
+ row.prop(cam, "angle")
+ row.prop(cam, "lens_unit", text="")
split = layout.split()
diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py
index aa7d78225d5..ba24874bc9d 100644
--- a/release/scripts/startup/bl_ui/properties_render.py
+++ b/release/scripts/startup/bl_ui/properties_render.py
@@ -236,9 +236,9 @@ class RENDER_PT_performance(RenderButtonsPanel, Panel):
subsub.prop(rd, "threads")
sub = col.column(align=True)
- sub.label(text="Tiles:")
- sub.prop(rd, "parts_x", text="X")
- sub.prop(rd, "parts_y", text="Y")
+ sub.label(text="Tile Size:")
+ sub.prop(rd, "tile_x", text="X")
+ sub.prop(rd, "tile_y", text="Y")
col = split.column()
col.label(text="Memory:")
diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py
index f7b9f59b066..cb88226b55a 100644
--- a/release/scripts/startup/bl_ui/space_clip.py
+++ b/release/scripts/startup/bl_ui/space_clip.py
@@ -320,6 +320,13 @@ class CLIP_PT_tools_solve(CLIP_PT_tracking_panel, Panel):
col.label(text="Refine:")
col.prop(settings, "refine_intrinsics", text="")
+ col = layout.column(align=True)
+ col.active = not settings.use_tripod_solver
+ col.prop(settings, "use_fallback_reconstruction", text="Allow Fallback")
+ sub = col.column()
+ sub.active = settings.use_fallback_reconstruction
+ sub.prop(settings, "reconstruction_success_threshold")
+
class CLIP_PT_tools_cleanup(CLIP_PT_tracking_panel, Panel):
bl_space_type = 'CLIP_EDITOR'
diff --git a/release/scripts/startup/bl_ui/space_logic.py b/release/scripts/startup/bl_ui/space_logic.py
index 846169b3339..730398171d6 100644
--- a/release/scripts/startup/bl_ui/space_logic.py
+++ b/release/scripts/startup/bl_ui/space_logic.py
@@ -107,5 +107,10 @@ class LOGIC_MT_view(Menu):
layout.operator("logic.properties", icon='MENU_PANEL')
+ layout.separator()
+
+ layout.operator("screen.area_dupli")
+ layout.operator("screen.screen_full_area")
+
if __name__ == "__main__": # only for live edit.
bpy.utils.register_module(__name__)
diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py
index 14fbc7c34be..cba45d4c2b7 100644
--- a/release/scripts/startup/bl_ui/space_sequencer.py
+++ b/release/scripts/startup/bl_ui/space_sequencer.py
@@ -601,6 +601,8 @@ class SEQUENCER_PT_input(SequencerButtonsPanel, Panel):
split.label(text="File:")
split.prop(elem, "filename", text="") # strip.elements[0] could be a fallback
+ layout.prop(strip.colorspace_settings, "name")
+
layout.operator("sequencer.change_path")
elif seq_type == 'MOVIE':
@@ -608,6 +610,8 @@ class SEQUENCER_PT_input(SequencerButtonsPanel, Panel):
split.label(text="Path:")
split.prop(strip, "filepath", text="")
+ layout.prop(strip.colorspace_settings, "name")
+
layout.prop(strip, "mpeg_preseek")
layout.prop(strip, "stream_index")
diff --git a/release/scripts/startup/bl_ui/space_text.py b/release/scripts/startup/bl_ui/space_text.py
index 8a853a09199..a64f8aa4aed 100644
--- a/release/scripts/startup/bl_ui/space_text.py
+++ b/release/scripts/startup/bl_ui/space_text.py
@@ -154,12 +154,7 @@ class TEXT_MT_view(Menu):
layout = self.layout
layout.operator("text.properties", icon='MENU_PANEL')
-
- layout.separator()
-
- layout.operator("screen.area_dupli")
- layout.operator("screen.screen_full_area")
-
+
layout.separator()
layout.operator("text.move",
@@ -169,6 +164,11 @@ class TEXT_MT_view(Menu):
text="Bottom of File",
).type = 'FILE_BOTTOM'
+ layout.separator()
+
+ layout.operator("screen.area_dupli")
+ layout.operator("screen.screen_full_area")
+
class TEXT_MT_text(Menu):
bl_label = "Text"
diff --git a/release/scripts/startup/bl_ui/space_time.py b/release/scripts/startup/bl_ui/space_time.py
index ed1d2a0ae24..cb9e2444793 100644
--- a/release/scripts/startup/bl_ui/space_time.py
+++ b/release/scripts/startup/bl_ui/space_time.py
@@ -127,6 +127,11 @@ class TIME_MT_view(Menu):
layout.operator("marker.camera_bind")
+ layout.separator()
+
+ layout.operator("screen.area_dupli")
+ layout.operator("screen.screen_full_area")
+
class TIME_MT_cache(Menu):
bl_label = "Cache"
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 5d949e89caa..01e9e627f76 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -356,6 +356,7 @@ class VIEW3D_MT_view(Menu):
layout.operator("view3d.clip_border", text="Clipping Border...")
layout.operator("view3d.zoom_border", text="Zoom Border...")
+ layout.operator("view3d.render_border", text="Render Border...")
layout.separator()
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 49355de4006..9bb8255356c 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -1048,7 +1048,7 @@ class VIEW3D_PT_tools_projectpaint(View3DPanel, Panel):
@classmethod
def poll(cls, context):
brush = context.tool_settings.image_paint.brush
- return (brush and brush.image_tool != 'SOFTEN')
+ return (brush is not None)
def draw_header(self, context):
ipaint = context.tool_settings.image_paint
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h
index fbdbf052878..e7033d8648d 100644
--- a/source/blender/blenkernel/BKE_blender.h
+++ b/source/blender/blenkernel/BKE_blender.h
@@ -42,7 +42,7 @@ extern "C" {
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 264
-#define BLENDER_SUBVERSION 6
+#define BLENDER_SUBVERSION 8
/* 262 was the last editmesh release but it has compatibility code for bmesh data */
#define BLENDER_MINVERSION 262
diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h
index f7af534c2c2..f6276a69d57 100644
--- a/source/blender/blenkernel/BKE_global.h
+++ b/source/blender/blenkernel/BKE_global.h
@@ -167,6 +167,9 @@ enum {
#define G_FILE_RELATIVE_REMAP (1 << 24)
#define G_FILE_HISTORY (1 << 25)
#define G_FILE_MESH_COMPAT (1 << 26) /* BMesh option to save as older mesh format */
+#define G_FILE_SAVE_COPY (1 << 27) /* restore paths after editing them */
+
+#define G_FILE_FLAGS_RUNTIME (G_FILE_NO_UI | G_FILE_RELATIVE_REMAP | G_FILE_MESH_COMPAT | G_FILE_SAVE_COPY)
/* G.windowstate */
#define G_WINDOWSTATE_USERDEF 0
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 29e03f66bcc..b365d93b246 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -553,6 +553,10 @@ struct ShadeResult;
#define SH_NODE_TEX_BRICK 169
#define SH_NODE_BUMP 170
#define SH_NODE_SCRIPT 171
+#define SH_NODE_AMBIENT_OCCLUSION 172
+#define SH_NODE_BSDF_REFRACTION 173
+#define SH_NODE_TANGENT 174
+#define SH_NODE_NORMAL_MAP 175
/* custom defines options for Material node */
#define SH_NODE_MAT_DIFF 1
diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h
index 1667c119790..ba611817c8f 100644
--- a/source/blender/blenkernel/BKE_sequencer.h
+++ b/source/blender/blenkernel/BKE_sequencer.h
@@ -356,6 +356,7 @@ typedef struct SeqLoadInfo {
typedef struct Sequence *(*SeqLoadFunc)(struct bContext *, ListBase *, struct SeqLoadInfo *);
struct Sequence *BKE_sequence_alloc(ListBase *lb, int cfra, int machine);
+void BKE_sequence_init_colorspace(struct Sequence *seq);
struct Sequence *BKE_sequencer_add_image_strip(struct bContext *C, ListBase *seqbasep, struct SeqLoadInfo *seq_load);
struct Sequence *BKE_sequencer_add_sound_strip(struct bContext *C, ListBase *seqbasep, struct SeqLoadInfo *seq_load);
diff --git a/source/blender/blenkernel/BKE_utildefines.h b/source/blender/blenkernel/BKE_utildefines.h
index 06f8b89ec05..7c1e0e97565 100644
--- a/source/blender/blenkernel/BKE_utildefines.h
+++ b/source/blender/blenkernel/BKE_utildefines.h
@@ -32,7 +32,11 @@
extern "C" {
#endif
-/* currently unused but we may want to add macros here for BKE later */
+#define BKE_BIT_TEST_SET(value, test, flag) \
+{ \
+ if (test) (value) |= flag; \
+ else (value) &= ~flag; \
+} (void)0
#ifdef __cplusplus
}
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index d3b7b3852fc..1aec4195354 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -980,9 +980,8 @@ KeyingSet *BKE_keyingset_add(ListBase *list, const char idname[], const char nam
/* allocate new KeyingSet */
ks = MEM_callocN(sizeof(KeyingSet), "KeyingSet");
- BLI_strncpy(ks->idname, idname ? idname : name ? name : "KeyingSet", sizeof(ks->idname));
-
- BLI_strncpy(ks->name, name ? name : idname ? idname : "Keying Set", sizeof(ks->name));
+ BLI_strncpy(ks->idname, (idname) ? idname : (name) ? name : "KeyingSet", sizeof(ks->idname));
+ BLI_strncpy(ks->name, (name) ? name : (idname) ? idname : "Keying Set", sizeof(ks->name));
ks->flag = flag;
ks->keyingflag = keyingflag;
@@ -990,10 +989,10 @@ KeyingSet *BKE_keyingset_add(ListBase *list, const char idname[], const char nam
/* add KeyingSet to list */
BLI_addtail(list, ks);
- /* Make sure KeyingSet has a unique idname. */
+ /* Make sure KeyingSet has a unique idname */
BLI_uniquename(list, ks, "KeyingSet", '.', offsetof(KeyingSet, idname), sizeof(ks->idname));
- /* Make sure KeyingSet has a unique label (this helps with identification). */
+ /* Make sure KeyingSet has a unique label (this helps with identification) */
BLI_uniquename(list, ks, "Keying Set", '.', offsetof(KeyingSet, name), sizeof(ks->name));
/* return new KeyingSet for further editing */
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index 950a0ca3d60..44b3917df7f 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -400,7 +400,8 @@ static void dag_add_material_driver_relations(DagForest *dag, DagNode *node, Mat
}
}
-static void dag_add_collision_field_relation(DagForest *dag, Scene *scene, Object *ob, DagNode *node, int skip_forcefield){
+static void dag_add_collision_field_relation(DagForest *dag, Scene *scene, Object *ob, DagNode *node, int skip_forcefield)
+{
Base *base;
DagNode *node2;
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 7a33d94b3dc..5b54154a489 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -1013,7 +1013,6 @@ void free_main(Main *mainvar)
#endif
}
}
- a = set_listbasepointers(mainvar, lbarray);
MEM_freeN(mainvar);
}
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index 4bd6676608e..4156b5b4367 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -520,6 +520,24 @@ static void movieclip_load_get_szie(MovieClip *clip)
}
}
+static void detect_clip_source(MovieClip *clip)
+{
+ ImBuf *ibuf;
+ char name[FILE_MAX];
+
+ BLI_strncpy(name, clip->name, sizeof(name));
+ BLI_path_abs(name, G.main->name);
+
+ ibuf = IMB_testiffname(name, IB_rect | IB_multilayer);
+ if (ibuf) {
+ clip->source = MCLIP_SRC_SEQUENCE;
+ IMB_freeImBuf(ibuf);
+ }
+ else {
+ clip->source = MCLIP_SRC_MOVIE;
+ }
+}
+
/* checks if image was already loaded, then returns same image
* otherwise creates new.
* does not load ibuf itself
@@ -565,10 +583,7 @@ MovieClip *BKE_movieclip_file_add(const char *name)
clip = movieclip_alloc(libname);
BLI_strncpy(clip->name, name, sizeof(clip->name));
- if (BLI_testextensie_array(name, imb_ext_movie))
- clip->source = MCLIP_SRC_MOVIE;
- else
- clip->source = MCLIP_SRC_SEQUENCE;
+ detect_clip_source(clip);
movieclip_load_get_szie(clip);
if (clip->lastsize[0]) {
@@ -1082,10 +1097,7 @@ void BKE_movieclip_reload(MovieClip *clip)
clip->tracking.stabilization.ok = FALSE;
/* update clip source */
- if (BLI_testextensie_array(clip->name, imb_ext_movie))
- clip->source = MCLIP_SRC_MOVIE;
- else
- clip->source = MCLIP_SRC_SEQUENCE;
+ detect_clip_source(clip);
clip->lastsize[0] = clip->lastsize[1] = 0;
movieclip_load_get_szie(clip);
@@ -1164,13 +1176,16 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip
search_ibuf = BKE_tracking_get_search_imbuf(ibuf, track, &undist_marker, TRUE, TRUE);
- if (!search_ibuf->rect_float) {
- /* sampling happens in float buffer */
- IMB_float_from_rect(search_ibuf);
+ if (search_ibuf) {
+ if (!search_ibuf->rect_float) {
+ /* sampling happens in float buffer */
+ IMB_float_from_rect(search_ibuf);
+ }
+
+ scopes->track_search = search_ibuf;
}
scopes->undist_marker = undist_marker;
- scopes->track_search = search_ibuf;
scopes->frame_width = ibuf->x;
scopes->frame_height = ibuf->y;
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 153eb5271c5..2d76484b60a 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -2293,17 +2293,21 @@ static void registerShaderNodes(bNodeTreeType *ttype)
register_node_type_sh_particle_info(ttype);
register_node_type_sh_bump(ttype);
register_node_type_sh_script(ttype);
+ register_node_type_sh_tangent(ttype);
+ register_node_type_sh_normal_map(ttype);
register_node_type_sh_background(ttype);
register_node_type_sh_bsdf_anisotropic(ttype);
register_node_type_sh_bsdf_diffuse(ttype);
register_node_type_sh_bsdf_glossy(ttype);
register_node_type_sh_bsdf_glass(ttype);
+ register_node_type_sh_bsdf_refraction(ttype);
register_node_type_sh_bsdf_translucent(ttype);
register_node_type_sh_bsdf_transparent(ttype);
register_node_type_sh_bsdf_velvet(ttype);
register_node_type_sh_emission(ttype);
register_node_type_sh_holdout(ttype);
+ register_node_type_sh_ambient_occlusion(ttype);
//register_node_type_sh_volume_transparent(ttype);
//register_node_type_sh_volume_isotropic(ttype);
register_node_type_sh_mix_shader(ttype);
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 2b95946f571..a780a9e8684 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -367,11 +367,12 @@ void psys_calc_dmcache(Object *ob, DerivedMesh *dm, ParticleSystem *psys)
nodedmelem= MEM_callocN(sizeof(LinkNode)*totdmelem, "psys node elems");
nodearray= MEM_callocN(sizeof(LinkNode *)*totelem, "psys node array");
- for (i=0, node=nodedmelem; i<totdmelem; i++, origindex++, node++) {
+ for (i=0, node=nodedmelem; i<totdmelem; i++, node++) {
int origindex_final;
node->link = SET_INT_IN_POINTER(i);
- origindex_final = *origindex;
+ /* may be vertex or face origindex */
+ origindex_final = origindex ? origindex[i] : ORIGINDEX_NONE;
/* if we have a poly source, do an index lookup */
if (origindex_poly && origindex_final != ORIGINDEX_NONE) {
@@ -466,13 +467,7 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys)
mv++;
for (i=1; i<totvert; i++, mv++) {
- min[0]=MIN2(min[0],mv->co[0]);
- min[1]=MIN2(min[1],mv->co[1]);
- min[2]=MIN2(min[2],mv->co[2]);
-
- max[0]=MAX2(max[0],mv->co[0]);
- max[1]=MAX2(max[1],mv->co[1]);
- max[2]=MAX2(max[2],mv->co[2]);
+ minmax_v3v3_v3(min, max, mv->co);
}
sub_v3_v3v3(delta, max, min);
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 721117d739f..49b405379eb 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -375,8 +375,8 @@ Scene *BKE_scene_add(const char *name)
sce->r.ysch = 1080;
sce->r.xasp = 1;
sce->r.yasp = 1;
- sce->r.xparts = 8;
- sce->r.yparts = 8;
+ sce->r.tilex = 256;
+ sce->r.tiley = 256;
sce->r.mblur_samples = 1;
sce->r.filtertype = R_FILTER_MITCH;
sce->r.size = 50;
@@ -1026,8 +1026,10 @@ static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scen
if (ob->dup_group && (ob->transflag & OB_DUPLIGROUP))
group_handle_recalc_and_update(scene_parent, ob, ob->dup_group);
- /* always update layer, so that animating layers works */
- base->lay = ob->lay;
+ /* always update layer, so that animating layers works (joshua july 2010) */
+ /* XXX commented out, this has depsgraph issues anyway - and this breaks setting scenes
+ (on scene-set, the base-lay is copied to ob-lay (ton nov 2012) */
+ // base->lay = ob->lay;
}
/* scene drivers... */
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index 80ea00fc703..af0cab98fe0 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -676,8 +676,8 @@ void BKE_sequence_reload_new_file(Scene *scene, Sequence *seq, int lock_range)
if (seq->anim) IMB_free_anim(seq->anim);
- /* OCIO_TODO: support configurable input space for strips */
- seq->anim = openanim(str, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), seq->streamindex, NULL);
+ seq->anim = openanim(str, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0),
+ seq->streamindex, seq->strip->colorspace_settings.name);
if (!seq->anim) {
return;
@@ -1174,8 +1174,8 @@ static void seq_open_anim_file(Sequence *seq)
seq->strip->dir, seq->strip->stripdata->name);
BLI_path_abs(name, G.main->name);
- /* OCIO_TODO: support configurable input space for strips */
- seq->anim = openanim(name, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), seq->streamindex, NULL);
+ seq->anim = openanim(name, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0),
+ seq->streamindex, seq->strip->colorspace_settings.name);
if (seq->anim == NULL) {
return;
@@ -1301,7 +1301,6 @@ static ImBuf *seq_proxy_fetch(SeqRenderData context, Sequence *seq, int cfra)
}
if (BLI_exists(name)) {
- /* OCIO_TODO: support configurable spaces for strips */
ImBuf *ibuf = IMB_loadiffname(name, IB_rect, NULL);
if (ibuf)
@@ -1346,7 +1345,6 @@ static void seq_proxy_build_frame(SeqRenderData context, Sequence *seq, int cfra
BLI_make_existing_file(name);
- /* OCIO_TODO: support per-strip color space settings */
ok = IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat);
if (ok == 0) {
perror(name);
@@ -2529,8 +2527,7 @@ static ImBuf *do_render_strip_uncached(SeqRenderData context, Sequence *seq, flo
BLI_path_abs(name, G.main->name);
}
- /* OCIO_TODO: support configurable space for image strips */
- if (s_elem && (ibuf = IMB_loadiffname(name, IB_rect, NULL))) {
+ if (s_elem && (ibuf = IMB_loadiffname(name, IB_rect, seq->strip->colorspace_settings.name))) {
/* we don't need both (speed reasons)! */
if (ibuf->rect_float && ibuf->rect)
imb_freerectImBuf(ibuf);
@@ -3940,6 +3937,25 @@ Sequence *BKE_sequence_alloc(ListBase *lb, int cfra, int machine)
return seq;
}
+void BKE_sequence_init_colorspace(Sequence *seq)
+{
+ if (seq->strip && seq->strip->stripdata) {
+ char name[FILE_MAX];
+ ImBuf *ibuf;
+
+ BLI_join_dirfile(name, sizeof(name), seq->strip->dir, seq->strip->stripdata->name);
+ BLI_path_abs(name, G.main->name);
+
+ /* initialize input color space */
+ if (seq->type == SEQ_TYPE_IMAGE) {
+ ibuf = IMB_loadiffname(name, IB_rect, seq->strip->colorspace_settings.name);
+
+ if (ibuf)
+ IMB_freeImBuf(ibuf);
+ }
+ }
+}
+
/* NOTE: this function doesn't fill in image names */
Sequence *BKE_sequencer_add_image_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo *seq_load)
{
@@ -4046,14 +4062,14 @@ Sequence *BKE_sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoad
Sequence *seq; /* generic strip vars */
Strip *strip;
StripElem *se;
+ char colorspace[64] = "\0"; /* MAX_COLORSPACE_NAME */
struct anim *an;
BLI_strncpy(path, seq_load->path, sizeof(path));
BLI_path_abs(path, G.main->name);
- /* OCIO_TODO: support configurable input space for strips */
- an = openanim(path, IB_rect, 0, NULL);
+ an = openanim(path, IB_rect, 0, colorspace);
if (an == NULL)
return NULL;
@@ -4072,6 +4088,8 @@ Sequence *BKE_sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoad
seq->len = IMB_anim_get_duration(an, IMB_TC_RECORD_RUN);
strip->us = 1;
+ BLI_strncpy(seq->strip->colorspace_settings.name, colorspace, sizeof(seq->strip->colorspace_settings.name));
+
/* we only need 1 element for MOVIE strips */
strip->stripdata = se = MEM_callocN(sizeof(StripElem), "stripelem");
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c
index 5586d8e4c29..96faec389df 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -159,7 +159,9 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
float *co = calc->vertexCos[i];
float tmp_co[3];
float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup);
- if (weight == 0.0f) continue;
+ if (weight == 0.0f) {
+ continue;
+ }
/* Convert the vertex to tree coordinates */
@@ -188,8 +190,10 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
if (nearest.index != -1) {
/* Adjusting the vertex weight,
* so that after interpolating it keeps a certain distance from the nearest position */
- float dist = sasqrt(nearest.dist);
- if (dist > FLT_EPSILON) weight *= (dist - calc->keepDist) / dist;
+ if (nearest.dist > FLT_EPSILON) {
+ const float dist = sqrtf(nearest.dist);
+ weight *= (dist - calc->keepDist) / dist;
+ }
/* Convert the coordinates back to mesh coordinates */
copy_v3_v3(tmp_co, nearest.co);
@@ -202,6 +206,7 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
free_bvhtree_from_mesh(&treeData);
}
+
/*
* This function raycast a single vertex and updates the hit if the "hit" is considered valid.
* Returns TRUE if "hit" was updated.
@@ -210,8 +215,16 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
* MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE (front faces hits are ignored)
* MOD_SHRINKWRAP_CULL_TARGET_BACKFACE (back faces hits are ignored)
*/
-int normal_projection_project_vertex(char options, const float vert[3], const float dir[3], const SpaceTransform *transf, BVHTree *tree, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata)
+int normal_projection_project_vertex(char options, const float vert[3], const float dir[3],
+ const SpaceTransform *transf,
+ BVHTree *tree, BVHTreeRayHit *hit,
+ BVHTree_RayCastCallback callback, void *userdata)
{
+ /* don't use this because this dist value could be incompatible
+ * this value used by the callback for comparing prev/new dist values.
+ * also, at the moment there is no need to have a corrected 'dist' value */
+// #define USE_DIST_CORRECT
+
float tmp_co[3], tmp_no[3];
const float *co, *no;
BVHTreeRayHit hit_tmp;
@@ -229,7 +242,9 @@ int normal_projection_project_vertex(char options, const float vert[3], const fl
space_transform_apply_normal(transf, tmp_no);
no = tmp_no;
+#ifdef USE_DIST_CORRECT
hit_tmp.dist *= mat4_to_scale(((SpaceTransform *)transf)->local2target);
+#endif
}
else {
co = vert;
@@ -250,7 +265,7 @@ int normal_projection_project_vertex(char options, const float vert[3], const fl
/* apply backface */
const float dot = dot_v3v3(dir, hit_tmp.no);
if (((options & MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE) && dot <= 0.0f) ||
- ((options & MOD_SHRINKWRAP_CULL_TARGET_BACKFACE) && dot >= 0.0f))
+ ((options & MOD_SHRINKWRAP_CULL_TARGET_BACKFACE) && dot >= 0.0f))
{
return FALSE; /* Ignore hit */
}
@@ -259,9 +274,13 @@ int normal_projection_project_vertex(char options, const float vert[3], const fl
if (transf) {
/* Inverting space transform (TODO make coeherent with the initial dist readjust) */
space_transform_invert(transf, hit_tmp.co);
- hit_tmp.dist = len_v3v3((float *)vert, hit_tmp.co);
+#ifdef USE_DIST_CORRECT
+ hit_tmp.dist = len_v3v3(vert, hit_tmp.co);
+#endif
}
+ BLI_assert(hit_tmp.dist <= hit->dist);
+
memcpy(hit, &hit_tmp, sizeof(hit_tmp));
return TRUE;
}
@@ -278,6 +297,10 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
float proj_axis[3] = {0.0f, 0.0f, 0.0f};
/* Raycast and tree stuff */
+
+ /** \note 'hit.dist' is kept in the targets space, this is only used
+ * for finding the best hit, to get the real dist,
+ * measure the len_v3v3() from the input coord to hit.co */
BVHTreeRayHit hit;
BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh;
@@ -306,8 +329,9 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
normalize_v3(proj_axis);
/* Invalid projection direction */
- if (dot_v3v3(proj_axis, proj_axis) < FLT_EPSILON)
- return;
+ if (len_squared_v3(proj_axis) < FLT_EPSILON) {
+ return;
+ }
}
if (calc->smd->auxTarget) {
@@ -328,9 +352,11 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
for (i = 0; i < calc->numVerts; ++i) {
float *co = calc->vertexCos[i];
float tmp_co[3], tmp_no[3];
- float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup);
+ const float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup);
- if (weight == 0.0f) continue;
+ if (weight == 0.0f) {
+ continue;
+ }
if (calc->vert) {
/* calc->vert contains verts from derivedMesh */
@@ -357,21 +383,31 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
/* Project over positive direction of axis */
if (use_normal & MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR) {
- if (auxData.tree)
- normal_projection_project_vertex(0, tmp_co, tmp_no, &local2aux, auxData.tree, &hit, auxData.raycast_callback, &auxData);
+ if (auxData.tree) {
+ normal_projection_project_vertex(0, tmp_co, tmp_no,
+ &local2aux, auxData.tree, &hit,
+ auxData.raycast_callback, &auxData);
+ }
- normal_projection_project_vertex(calc->smd->shrinkOpts, tmp_co, tmp_no, &calc->local2target, treeData.tree, &hit, treeData.raycast_callback, &treeData);
+ normal_projection_project_vertex(calc->smd->shrinkOpts, tmp_co, tmp_no,
+ &calc->local2target, treeData.tree, &hit,
+ treeData.raycast_callback, &treeData);
}
/* Project over negative direction of axis */
- if (use_normal & MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR && hit.index == -1) {
+ if (use_normal & MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR) {
float inv_no[3];
negate_v3_v3(inv_no, tmp_no);
- if (auxData.tree)
- normal_projection_project_vertex(0, tmp_co, inv_no, &local2aux, auxData.tree, &hit, auxData.raycast_callback, &auxData);
+ if (auxData.tree) {
+ normal_projection_project_vertex(0, tmp_co, inv_no,
+ &local2aux, auxData.tree, &hit,
+ auxData.raycast_callback, &auxData);
+ }
- normal_projection_project_vertex(calc->smd->shrinkOpts, tmp_co, inv_no, &calc->local2target, treeData.tree, &hit, treeData.raycast_callback, &treeData);
+ normal_projection_project_vertex(calc->smd->shrinkOpts, tmp_co, inv_no,
+ &calc->local2target, treeData.tree, &hit,
+ treeData.raycast_callback, &treeData);
}
@@ -453,10 +489,13 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
/* Adjusting the vertex weight,
* so that after interpolating it keeps a certain distance from the nearest position */
float dist = sasqrt(nearest.dist);
- if (dist > FLT_EPSILON)
- interp_v3_v3v3(tmp_co, tmp_co, nearest.co, (dist - calc->keepDist) / dist); /* linear interpolation */
- else
+ if (dist > FLT_EPSILON) {
+ /* linear interpolation */
+ interp_v3_v3v3(tmp_co, tmp_co, nearest.co, (dist - calc->keepDist) / dist);
+ }
+ else {
copy_v3_v3(tmp_co, nearest.co);
+ }
}
/* Convert the coordinates back to mesh coordinates */
@@ -469,7 +508,8 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
}
/* Main shrinkwrap function */
-void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedMesh *dm, float (*vertexCos)[3], int numVerts)
+void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedMesh *dm,
+ float (*vertexCos)[3], int numVerts)
{
DerivedMesh *ss_mesh = NULL;
@@ -561,4 +601,3 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM
if (ss_mesh)
ss_mesh->release(ss_mesh);
}
-
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index 443aed1fc41..f9925a41177 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -2267,7 +2267,8 @@ static void smokeModifier_process(SmokeModifierData *smd, Scene *scene, Object *
}
}
-struct DerivedMesh *smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm){
+struct DerivedMesh *smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm)
+{
smokeModifier_process(smd, scene, ob, dm);
/* return generated geometry for adaptive domain */
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index b3497b9932f..d230cf8f1fe 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -2862,7 +2862,7 @@ int txt_replace_char(Text *text, unsigned int add)
void txt_indent(Text *text)
{
- int len, num;
+ int len, num, curc_old;
char *tmp;
const char *add = "\t";
@@ -2885,6 +2885,8 @@ void txt_indent(Text *text)
indentlen = spaceslen;
}
+ curc_old = text->curc;
+
num = 0;
while (TRUE) {
tmp = MEM_mallocN(text->curl->len + indentlen + 1, "textline_string");
@@ -2905,7 +2907,7 @@ void txt_indent(Text *text)
txt_clean_text(text);
if (text->curl == text->sell) {
- text->selc = text->sell->len;
+ text->selc += indentlen;
break;
}
else {
@@ -2913,7 +2915,9 @@ void txt_indent(Text *text)
num++;
}
}
- text->curc = 0;
+ if (!curc_old) text->curc = 0;
+ else text->curc = curc_old + indentlen;
+
while (num > 0) {
text->curl = text->curl->prev;
num--;
@@ -2928,7 +2932,8 @@ void txt_unindent(Text *text)
{
int num = 0;
const char *remove = "\t";
- int indent = 1;
+ int indentlen = 1;
+ int unindented_first = FALSE;
/* hardcoded: TXT_TABSIZE = 4 spaces: */
int spaceslen = TXT_TABSIZE;
@@ -2940,25 +2945,26 @@ void txt_unindent(Text *text)
/* insert spaces rather than tabs */
if (text->flags & TXT_TABSTOSPACES) {
remove = tab_to_spaces;
- indent = spaceslen;
+ indentlen = spaceslen;
}
while (TRUE) {
int i = 0;
- if (BLI_strncasecmp(text->curl->line, remove, indent) == 0) {
+ if (BLI_strncasecmp(text->curl->line, remove, indentlen) == 0) {
+ if (num == 0) unindented_first = TRUE;
while (i < text->curl->len) {
- text->curl->line[i] = text->curl->line[i + indent];
+ text->curl->line[i] = text->curl->line[i + indentlen];
i++;
}
- text->curl->len -= indent;
+ text->curl->len -= indentlen;
}
txt_make_dirty(text);
txt_clean_text(text);
if (text->curl == text->sell) {
- text->selc = text->sell->len;
+ if (i > 0) text->selc = MAX2(text->selc - indentlen, 0);
break;
}
else {
@@ -2967,7 +2973,9 @@ void txt_unindent(Text *text)
}
}
- text->curc = 0;
+
+ if (unindented_first) text->curc = MAX2(text->curc - indentlen, 0);
+
while (num > 0) {
text->curl = text->curl->prev;
num--;
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index 26775eaac8c..b174f27b7e1 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -173,6 +173,7 @@ void BKE_tracking_settings_init(MovieTracking *tracking)
tracking->settings.default_search_size = 61;
tracking->settings.dist = 1;
tracking->settings.object_distance = 1;
+ tracking->settings.reconstruction_success_threshold = 1e-3;
tracking->stabilization.scaleinf = 1.0f;
tracking->stabilization.locinf = 1.0f;
@@ -1623,6 +1624,9 @@ ImBuf *BKE_tracking_sample_pattern(int frame_width, int frame_height, ImBuf *sea
double warped_position_x, warped_position_y;
float *mask = NULL;
+ if (num_samples_x <= 0 || num_samples_y <= 0)
+ return NULL;
+
pattern_ibuf = IMB_allocImBuf(num_samples_x, num_samples_y, 32, IB_rectfloat);
if (!search_ibuf->rect_float) {
@@ -1689,10 +1693,15 @@ ImBuf *BKE_tracking_get_pattern_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, Mo
search_ibuf = BKE_tracking_get_search_imbuf(ibuf, track, marker, anchored, disable_channels);
- pattern_ibuf = BKE_tracking_sample_pattern(ibuf->x, ibuf->y, search_ibuf, track, marker,
- FALSE, num_samples_x, num_samples_y, NULL);
+ if (search_ibuf) {
+ pattern_ibuf = BKE_tracking_sample_pattern(ibuf->x, ibuf->y, search_ibuf, track, marker,
+ FALSE, num_samples_x, num_samples_y, NULL);
- IMB_freeImBuf(search_ibuf);
+ IMB_freeImBuf(search_ibuf);
+ }
+ else {
+ pattern_ibuf = NULL;
+ }
return pattern_ibuf;
}
@@ -1717,6 +1726,9 @@ ImBuf *BKE_tracking_get_search_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, Mov
w = (marker->search_max[0] - marker->search_min[0]) * ibuf->x;
h = (marker->search_max[1] - marker->search_min[1]) * ibuf->y;
+ if (w <= 0 || h <= 0)
+ return NULL;
+
searchibuf = IMB_allocImBuf(w, h, 32, ibuf->rect_float ? IB_rectfloat : IB_rect);
IMB_rectcpy(searchibuf, ibuf, 0, 0, x, y, w, h);
@@ -2186,6 +2198,12 @@ static float *track_get_search_floatbuf(ImBuf *ibuf, MovieTrackingTrack *track,
searchibuf = BKE_tracking_get_search_imbuf(ibuf, track, marker, FALSE, TRUE);
+ if (!searchibuf) {
+ *width_r = 0;
+ *height_r = 0;
+ return NULL;
+ }
+
width = searchibuf->x;
height = searchibuf->y;
@@ -2505,6 +2523,9 @@ int BKE_tracking_context_step(MovieTrackingContext *context)
get_marker_coords_for_tracking(frame_width, frame_height, &track_context->marker, src_pixel_x, src_pixel_y);
get_marker_coords_for_tracking(frame_width, frame_height, marker, dst_pixel_x, dst_pixel_y);
+ if (!patch_new || !track_context->search_area)
+ continue;
+
/* run the tracker! */
tracked = libmv_trackRegion(&options,
track_context->search_area,
@@ -2561,6 +2582,9 @@ typedef struct MovieReconstructContext {
TracksMap *tracks_map;
+ float success_threshold;
+ int use_fallback_reconstruction;
+
int sfra, efra;
} MovieReconstructContext;
@@ -2830,6 +2854,9 @@ MovieReconstructContext *BKE_tracking_reconstruction_context_new(MovieTracking *
context->k2 = camera->k2;
context->k3 = camera->k3;
+ context->success_threshold = tracking->settings.reconstruction_success_threshold;
+ context->use_fallback_reconstruction = tracking->settings.reconstruction_flag & TRACKING_USE_FALLBACK_RECONSTRUCTION;
+
context->tracks_map = tracks_map_new(context->object_name, context->is_camera, num_tracks, 0);
track = tracksbase->first;
@@ -2929,12 +2956,18 @@ void BKE_tracking_reconstruction_solve(MovieReconstructContext *context, short *
reconstruct_update_solve_cb, &progressdata);
}
else {
+ struct libmv_reconstructionOptions options;
+
+ options.success_threshold = context->success_threshold;
+ options.use_fallback_reconstruction = context->use_fallback_reconstruction;
+
context->reconstruction = libmv_solveReconstruction(context->tracks,
context->keyframe1, context->keyframe2,
context->refine_flags,
context->focal_length,
context->principal_point[0], context->principal_point[1],
context->k1, context->k2, context->k3,
+ &options,
reconstruct_update_solve_cb, &progressdata);
}
diff --git a/source/blender/blenlib/BLI_bpath.h b/source/blender/blenlib/BLI_bpath.h
index a86b362c271..438bffb2fc5 100644
--- a/source/blender/blenlib/BLI_bpath.h
+++ b/source/blender/blenlib/BLI_bpath.h
@@ -48,6 +48,11 @@ void BLI_bpath_traverse_id_list(struct Main *bmain, struct ListBase *lb, BPathVi
void BLI_bpath_traverse_main(struct Main *bmain, BPathVisitor visit_cb, const int flag, void *userdata);
int BLI_bpath_relocate_visitor(void *oldbasepath, char *path_dst, const char *path_src);
+/* Functions for temp backup/restore of paths, path count must NOT change */
+void *BLI_bpath_list_backup(struct Main *bmain, const int flag);
+void BLI_bpath_list_restore(struct Main *bmain, const int flag, void *ls_handle);
+void BLI_bpath_list_free(void *ls_handle);
+
#define BLI_BPATH_TRAVERSE_ABS (1 << 0) /* convert paths to absolute */
#define BLI_BPATH_TRAVERSE_SKIP_LIBRARY (1 << 2) /* skip library paths */
#define BLI_BPATH_TRAVERSE_SKIP_PACKED (1 << 3) /* skip packed data */
diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h
index 9e34631d460..0783a7981ea 100644
--- a/source/blender/blenlib/BLI_math_matrix.h
+++ b/source/blender/blenlib/BLI_math_matrix.h
@@ -98,6 +98,9 @@ void mul_m3_fl(float R[3][3], float f);
void mul_m4_fl(float R[4][4], float f);
void mul_mat3_m4_fl(float R[4][4], float f);
+int invert_m3_ex(float m[3][3], const float epsilon);
+int invert_m3_m3_ex(float m1[3][3], float m2[3][3], const float epsilon);
+
int invert_m3(float R[3][3]);
int invert_m3_m3(float R[3][3], float A[3][3]);
int invert_m4(float R[4][4]);
diff --git a/source/blender/blenlib/BLI_quadric.h b/source/blender/blenlib/BLI_quadric.h
index aec11ec2b44..e71a6473852 100644
--- a/source/blender/blenlib/BLI_quadric.h
+++ b/source/blender/blenlib/BLI_quadric.h
@@ -51,6 +51,6 @@ void BLI_quadric_mul(Quadric *a, const float scalar);
/* solve */
float BLI_quadric_evaluate(const Quadric *q, const float v[3]);
-int BLI_quadric_optimize(const Quadric *q, float v[3]);
+int BLI_quadric_optimize(const Quadric *q, float v[3], const float epsilon);
#endif /* __BLI_QUADRIC_H__ */
diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c
index 70617453eff..7968fcabda6 100644
--- a/source/blender/blenlib/intern/BLI_kdopbvh.c
+++ b/source/blender/blenlib/intern/BLI_kdopbvh.c
@@ -1117,7 +1117,7 @@ BVHTreeOverlap *BLI_bvhtree_overlap(BVHTree *tree1, BVHTree *tree2, unsigned int
data[j]->overlap = (BVHTreeOverlap *)malloc(sizeof(BVHTreeOverlap) * max_ii(tree1->totleaf, tree2->totleaf));
data[j]->tree1 = tree1;
data[j]->tree2 = tree2;
- data[j]->max_overlap = MAX2(tree1->totleaf, tree2->totleaf);
+ data[j]->max_overlap = max_ii(tree1->totleaf, tree2->totleaf);
data[j]->i = 0;
data[j]->start_axis = min_axis(tree1->start_axis, tree2->start_axis);
data[j]->stop_axis = min_axis(tree1->stop_axis, tree2->stop_axis);
diff --git a/source/blender/blenlib/intern/bpath.c b/source/blender/blenlib/intern/bpath.c
index 2f335b557fe..d725a0a9417 100644
--- a/source/blender/blenlib/intern/bpath.c
+++ b/source/blender/blenlib/intern/bpath.c
@@ -626,3 +626,73 @@ int BLI_bpath_relocate_visitor(void *pathbase_v, char *path_dst, const char *pat
return FALSE;
}
}
+
+
+/* -------------------------------------------------------------------- */
+/**
+ * Backup/Restore/Free functions,
+ * \note These functions assume the data won't chane order.
+ */
+
+struct PathStore {
+ struct PathStore *next, *prev;
+} PathStore;
+
+static int bpath_list_append(void *userdata, char *UNUSED(path_dst), const char *path_src)
+{
+ /* store the path and string in a single alloc */
+ ListBase *ls = userdata;
+ size_t path_size = strlen(path_src) + 1;
+ struct PathStore *path_store = MEM_mallocN(sizeof(PathStore) + path_size, __func__);
+ char *filepath = (char *)(path_store + 1);
+
+ memcpy(filepath, path_src, path_size);
+ BLI_addtail(ls, path_store);
+ return FALSE;
+}
+
+static int bpath_list_restore(void *userdata, char *path_dst, const char *path_src)
+{
+ /* assume ls->first wont be NULL because the number of paths can't change!
+ * (if they do caller is wrong) */
+ ListBase *ls = userdata;
+ struct PathStore *path_store = ls->first;
+ const char *filepath = (char *)(path_store + 1);
+ int ret;
+
+ if (strcmp(path_src, filepath) == 0) {
+ ret = FALSE;
+ }
+ else {
+ BLI_strncpy(path_dst, filepath, FILE_MAX);
+ ret = TRUE;
+ }
+
+ BLI_freelinkN(ls, path_store);
+ return ret;
+}
+
+/* return ls_handle */
+void *BLI_bpath_list_backup(Main *bmain, const int flag)
+{
+ ListBase *ls = MEM_callocN(sizeof(ListBase), __func__);
+
+ BLI_bpath_traverse_main(bmain, bpath_list_append, flag, ls);
+
+ return ls;
+}
+
+void BLI_bpath_list_restore(Main *bmain, const int flag, void *ls_handle)
+{
+ ListBase *ls = ls_handle;
+
+ BLI_bpath_traverse_main(bmain, bpath_list_restore, flag, ls);
+}
+
+void BLI_bpath_list_free(void *ls_handle)
+{
+ ListBase *ls = ls_handle;
+ BLI_assert(ls->first == NULL); /* assumes we were used */
+ BLI_freelistN(ls);
+ MEM_freeN(ls);
+}
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index f622a5ace35..38214f9c6b0 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -504,6 +504,51 @@ void sub_m4_m4m4(float m1[][4], float m2[][4], float m3[][4])
m1[i][j] = m2[i][j] - m3[i][j];
}
+/* why not make this a standard part of the API? */
+static float determinant_m3_local(float m[3][3])
+{
+ return (m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1]) -
+ m[1][0] * (m[0][1] * m[2][2] - m[0][2] * m[2][1]) +
+ m[2][0] * (m[0][1] * m[1][2] - m[0][2] * m[1][1]));
+}
+
+int invert_m3_ex(float m[3][3], const float epsilon)
+{
+ float tmp[3][3];
+ int success;
+
+ success = invert_m3_m3_ex(tmp, m, epsilon);
+ copy_m3_m3(m, tmp);
+
+ return success;
+}
+
+int invert_m3_m3_ex(float m1[3][3], float m2[3][3], const float epsilon)
+{
+ float det;
+ int a, b, success;
+
+ BLI_assert(epsilon >= 0.0f);
+
+ /* calc adjoint */
+ adjoint_m3_m3(m1, m2);
+
+ /* then determinant old matrix! */
+ det = determinant_m3_local(m2);
+
+ success = (fabsf(det) > epsilon);
+
+ if (LIKELY(det != 0.0f)) {
+ det = 1.0f / det;
+ for (a = 0; a < 3; a++) {
+ for (b = 0; b < 3; b++) {
+ m1[a][b] *= det;
+ }
+ }
+ }
+ return success;
+}
+
int invert_m3(float m[3][3])
{
float tmp[3][3];
@@ -524,17 +569,16 @@ int invert_m3_m3(float m1[3][3], float m2[3][3])
adjoint_m3_m3(m1, m2);
/* then determinant old matrix! */
- det = (m2[0][0] * (m2[1][1] * m2[2][2] - m2[1][2] * m2[2][1]) -
- m2[1][0] * (m2[0][1] * m2[2][2] - m2[0][2] * m2[2][1]) +
- m2[2][0] * (m2[0][1] * m2[1][2] - m2[0][2] * m2[1][1]));
+ det = determinant_m3_local(m2);
- success = (det != 0);
+ success = (det != 0.0f);
- if (det == 0) det = 1;
- det = 1 / det;
- for (a = 0; a < 3; a++) {
- for (b = 0; b < 3; b++) {
- m1[a][b] *= det;
+ if (LIKELY(det != 0.0f)) {
+ det = 1.0f / det;
+ for (a = 0; a < 3; a++) {
+ for (b = 0; b < 3; b++) {
+ m1[a][b] *= det;
+ }
}
}
diff --git a/source/blender/blenlib/intern/quadric.c b/source/blender/blenlib/intern/quadric.c
index bb39cb61e78..b06534d282a 100644
--- a/source/blender/blenlib/intern/quadric.c
+++ b/source/blender/blenlib/intern/quadric.c
@@ -107,18 +107,13 @@ float BLI_quadric_evaluate(const Quadric *q, const float v[3])
q->d2);
}
-int BLI_quadric_optimize(const Quadric *q, float v[3])
+int BLI_quadric_optimize(const Quadric *q, float v[3], const float epsilon)
{
float m[3][3];
- float det;
BLI_quadric_to_tensor_m3(q, m);
- det = determinant_m3(m[0][0], m[0][1], m[0][2],
- m[1][0], m[1][1], m[1][2],
- m[2][0], m[2][1], m[2][2]);
- if (fabsf(det) > FLT_EPSILON) {
- invert_m3(m);
+ if (invert_m3_ex(m, epsilon)) {
BLI_quadric_to_vector_v3(q, v);
mul_m3_v3(m, v);
negate_v3(v);
diff --git a/source/blender/blenlib/intern/smallhash.c b/source/blender/blenlib/intern/smallhash.c
index 92125c6e988..64bb503fa3c 100644
--- a/source/blender/blenlib/intern/smallhash.c
+++ b/source/blender/blenlib/intern/smallhash.c
@@ -43,8 +43,22 @@
#define SMHASH_CELL_UNUSED ((void *)0x7FFFFFFF)
#define SMHASH_CELL_FREE ((void *)0x7FFFFFFD)
-#define SMHASH_NONZERO(n) ((n) + !(n))
-#define SMHASH_NEXT(h, hoff) ABS(((h) + ((hoff = SMHASH_NONZERO(hoff * 2) + 1), hoff)))
+BLI_INLINE int smhash_nonzero(const int n)
+{
+ return n + !n;
+}
+
+BLI_INLINE int smhash_abs_i(const int n)
+{
+ return (n > 0) ? n : -n;
+}
+
+/* typically this re-assigns 'h' */
+#define SMHASH_NEXT(h, hoff) ( \
+ CHECK_TYPE_INLINE(&(h), int), \
+ CHECK_TYPE_INLINE(&(hoff), int), \
+ smhash_abs_i((h) + (((hoff) = smhash_nonzero((hoff) * 2) + 1), (hoff))) \
+ )
extern unsigned int hashsizes[];
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 0b9421d2b12..bef97a4ab6a 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -7357,7 +7357,36 @@ static void do_version_logic_264(ListBase *regionbase)
}
-
+
+static void do_versions_affine_tracker_track(MovieTrackingTrack *track)
+{
+ int i;
+
+ for (i = 0; i < track->markersnr; i++) {
+ MovieTrackingMarker *marker = &track->markers[i];
+
+ if (is_zero_v2(marker->pattern_corners[0]) && is_zero_v2(marker->pattern_corners[1]) &&
+ is_zero_v2(marker->pattern_corners[2]) && is_zero_v2(marker->pattern_corners[3]))
+ {
+ marker->pattern_corners[0][0] = track->pat_min[0];
+ marker->pattern_corners[0][1] = track->pat_min[1];
+
+ marker->pattern_corners[1][0] = track->pat_max[0];
+ marker->pattern_corners[1][1] = track->pat_min[1];
+
+ marker->pattern_corners[2][0] = track->pat_max[0];
+ marker->pattern_corners[2][1] = track->pat_max[1];
+
+ marker->pattern_corners[3][0] = track->pat_min[0];
+ marker->pattern_corners[3][1] = track->pat_max[1];
+ }
+
+ if (is_zero_v2(marker->search_min) && is_zero_v2(marker->search_max)) {
+ copy_v2_v2(marker->search_min, track->search_min);
+ copy_v2_v2(marker->search_max, track->search_max);
+ }
+ }
+}
static void do_versions(FileData *fd, Library *lib, Main *main)
@@ -8128,32 +8157,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
track = clip->tracking.tracks.first;
while (track) {
- int i;
-
- for (i = 0; i < track->markersnr; i++) {
- MovieTrackingMarker *marker = &track->markers[i];
-
- if (is_zero_v2(marker->pattern_corners[0]) && is_zero_v2(marker->pattern_corners[1]) &&
- is_zero_v2(marker->pattern_corners[2]) && is_zero_v2(marker->pattern_corners[3]))
- {
- marker->pattern_corners[0][0] = track->pat_min[0];
- marker->pattern_corners[0][1] = track->pat_min[1];
-
- marker->pattern_corners[1][0] = track->pat_max[0];
- marker->pattern_corners[1][1] = track->pat_min[1];
-
- marker->pattern_corners[2][0] = track->pat_max[0];
- marker->pattern_corners[2][1] = track->pat_max[1];
-
- marker->pattern_corners[3][0] = track->pat_min[0];
- marker->pattern_corners[3][1] = track->pat_max[1];
- }
-
- if (is_zero_v2(marker->search_min) && is_zero_v2(marker->search_max)) {
- copy_v2_v2(marker->search_min, track->search_min);
- copy_v2_v2(marker->search_max, track->search_max);
- }
- }
+ do_versions_affine_tracker_track(track);
track = track->next;
}
@@ -8486,15 +8490,62 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
}
}
+ }
+
+ if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 7)) {
+ /* convert tiles size from resolution and number of tiles */
+ {
+ Scene *scene;
+
+ for (scene = main->scene.first; scene; scene = scene->id.next) {
+ if (scene->r.tilex == 0 || scene->r.tiley == 1) {
+ /* scene could be set for panoramic rendering, so clamp with the
+ * lowest possible tile size value
+ */
+ scene->r.tilex = max_ii(scene->r.xsch * scene->r.size / scene->r.xparts / 100, 8);
+ scene->r.tiley = max_ii(scene->r.ysch * scene->r.size / scene->r.yparts / 100, 8);
+ }
+ }
+ }
+
+ /* collision masks */
+ {
+ Object *ob;
+ for (ob = main->object.first; ob; ob = ob->id.next) {
+ if (ob->col_group == 0) {
+ ob->col_group = 0x01;
+ ob->col_mask = 0xff;
+ }
+ }
+ }
+
+ /* fallbck resection method settings */
+ {
+ MovieClip *clip;
+ for (clip = main->movieclip.first; clip; clip = clip->id.next) {
+ if (clip->tracking.settings.reconstruction_success_threshold == 0.0f) {
+ clip->tracking.settings.reconstruction_success_threshold = 1e-3;
+ }
+ }
+ }
}
-
- {
- Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
- if (ob->col_group == 0) {
- ob->col_group = 0x01;
- ob->col_mask = 0xff;
+
+ if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 7)) {
+ MovieClip *clip;
+
+ for (clip = main->movieclip.first; clip; clip = clip->id.next) {
+ MovieTrackingTrack *track;
+ MovieTrackingObject *object;
+
+ for (track = clip->tracking.tracks.first; track; track = track->next) {
+ do_versions_affine_tracker_track(track);
+ }
+
+ for (object = clip->tracking.objects.first; object; object = object->next) {
+ for (track = object->tracks.first; track; track = track->next) {
+ do_versions_affine_tracker_track(track);
+ }
}
}
}
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index d67f45cde10..7c022c6f45a 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -1831,13 +1831,13 @@ static void write_meshs(WriteData *wd, ListBase *idbase)
mesh->totloop = 0;
/* -- */
backup_mesh.fdata = mesh->fdata;
- memset(&mesh->fdata, 0, sizeof(CustomData));
+ CustomData_reset(&mesh->fdata);
/* -- */
backup_mesh.pdata = mesh->pdata;
- memset(&mesh->pdata, 0, sizeof(CustomData));
+ CustomData_reset(&mesh->pdata);
/* -- */
backup_mesh.ldata = mesh->ldata;
- memset(&mesh->ldata, 0, sizeof(CustomData));
+ CustomData_reset(&mesh->ldata);
/* -- */
backup_mesh.edit_btmesh = mesh->edit_btmesh;
mesh->edit_btmesh = NULL;
@@ -3102,7 +3102,7 @@ static void write_global(WriteData *wd, int fileflags, Main *mainvar)
fg.winpos= G.winpos;
/* prevent to save this, is not good convention, and feature with concerns... */
- fg.fileflags= (fileflags & ~(G_FILE_NO_UI|G_FILE_RELATIVE_REMAP|G_FILE_MESH_COMPAT));
+ fg.fileflags= (fileflags & ~G_FILE_FLAGS_RUNTIME);
fg.globalf= G.f;
BLI_strncpy(fg.filename, mainvar->name, sizeof(fg.filename));
@@ -3252,6 +3252,10 @@ int BLO_write_file(Main *mainvar, const char *filepath, int write_flags, ReportL
char tempname[FILE_MAX+1];
int file, err, write_user_block;
+ /* path backup/restore */
+ void *path_list_backup = NULL;
+ const int path_list_flag = (BLI_BPATH_TRAVERSE_SKIP_LIBRARY | BLI_BPATH_TRAVERSE_SKIP_MULTIFILE);
+
/* open temporary file, so we preserve the original in case we crash */
BLI_snprintf(tempname, sizeof(tempname), "%s@", filepath);
@@ -3261,6 +3265,11 @@ int BLO_write_file(Main *mainvar, const char *filepath, int write_flags, ReportL
return 0;
}
+ /* check if we need to backup and restore paths */
+ if (UNLIKELY((write_flags & G_FILE_RELATIVE_REMAP) && (G_FILE_SAVE_COPY & write_flags))) {
+ path_list_backup = BLI_bpath_list_backup(mainvar, path_list_flag);
+ }
+
/* remapping of relative paths to new file location */
if (write_flags & G_FILE_RELATIVE_REMAP) {
char dir1[FILE_MAX];
@@ -3296,6 +3305,11 @@ int BLO_write_file(Main *mainvar, const char *filepath, int write_flags, ReportL
err= write_file_handle(mainvar, file, NULL, NULL, write_user_block, write_flags, thumb);
close(file);
+ if (UNLIKELY(path_list_backup)) {
+ BLI_bpath_list_restore(mainvar, path_list_flag, path_list_backup);
+ BLI_bpath_list_free(path_list_backup);
+ }
+
if (err) {
BKE_report(reports, RPT_ERROR, strerror(errno));
remove(tempname);
diff --git a/source/blender/bmesh/intern/bmesh_decimate_collapse.c b/source/blender/bmesh/intern/bmesh_decimate_collapse.c
index feeb2a926f3..1f92a8f9227 100644
--- a/source/blender/bmesh/intern/bmesh_decimate_collapse.c
+++ b/source/blender/bmesh/intern/bmesh_decimate_collapse.c
@@ -45,11 +45,13 @@
/* defines for testing */
#define USE_CUSTOMDATA
#define USE_TRIANGULATE
+#define USE_VERT_NORMAL_INTERP /* has the advantage that flipped faces don't mess up vertex normals */
/* these checks are for rare cases that we can't avoid since they are valid meshes still */
#define USE_SAFETY_CHECKS
#define BOUNDARY_PRESERVE_WEIGHT 100.0f
+#define OPTIMIZE_EPS 0.01f /* FLT_EPSILON is too small, see [#33106] */
typedef enum CD_UseFlag {
CD_DO_VERT = (1 << 0),
@@ -96,7 +98,7 @@ static void bm_decim_build_quadrics(BMesh *bm, Quadric *vquadrics)
f = e->l->f;
cross_v3_v3v3(edge_cross, edge_vector, f->no);
- if (fabsf(normalize_v3(edge_cross)) > FLT_EPSILON) {
+ if (normalize_v3(edge_cross) > FLT_EPSILON) {
Quadric q;
BLI_quadric_from_v3_dist(&q, edge_cross, -dot_v3v3(edge_cross, e->v1->co));
BLI_quadric_mul(&q, BOUNDARY_PRESERVE_WEIGHT);
@@ -122,7 +124,7 @@ static void bm_decim_calc_target_co(BMEdge *e, float optimize_co[3],
&vquadrics[BM_elem_index_get(e->v2)]);
- if (BLI_quadric_optimize(&q, optimize_co)) {
+ if (BLI_quadric_optimize(&q, optimize_co, OPTIMIZE_EPS)) {
return; /* all is good */
}
else {
@@ -774,6 +776,11 @@ static void bm_decim_edge_collapse(BMesh *bm, BMEdge *e,
float optimize_co[3];
float customdata_fac;
+#ifdef USE_VERT_NORMAL_INTERP
+ float v_clear_no[3];
+ copy_v3_v3(v_clear_no, e->v2->no);
+#endif
+
bm_decim_calc_target_co(e, optimize_co, vquadrics);
/* use for customdata merging */
@@ -822,7 +829,13 @@ static void bm_decim_edge_collapse(BMesh *bm, BMEdge *e,
/* in fact face normals are not used for progressive updates, no need to update them */
// BM_vert_normal_update_all(v);
+#ifdef USE_VERT_NORMAL_INTERP
+ interp_v3_v3v3(v_other->no, v_other->no, v_clear_no, customdata_fac);
+ normalize_v3(v_other->no);
+#else
BM_vert_normal_update(v_other);
+#endif
+
/* update error costs and the eheap */
if (LIKELY(v_other->e)) {
diff --git a/source/blender/bmesh/intern/bmesh_operator_api.h b/source/blender/bmesh/intern/bmesh_operator_api.h
index a2f4cdc8c6a..671cfbbc55e 100644
--- a/source/blender/bmesh/intern/bmesh_operator_api.h
+++ b/source/blender/bmesh/intern/bmesh_operator_api.h
@@ -285,6 +285,8 @@ void BMO_slot_int_set(BMOperator *op, const char *slot_name, const int i);
int BMO_slot_int_get(BMOperator *op, const char *slot_name);
void BMO_slot_bool_set(BMOperator *op, const char *slot_name, const int i);
int BMO_slot_bool_get(BMOperator *op, const char *slot_name);
+void *BMO_slot_as_arrayN(BMOperator *op, const char *slot_name, int *len);
+
/* don't pass in arrays that are supposed to map to elements this way.
*
diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c
index 2413f3a7be0..4cc946a3a40 100644
--- a/source/blender/bmesh/intern/bmesh_operators.c
+++ b/source/blender/bmesh/intern/bmesh_operators.c
@@ -429,6 +429,20 @@ int BMO_slot_bool_get(BMOperator *op, const char *slot_name)
return slot->data.i;
}
+/* if you want a copy of the elem buffer */
+void *BMO_slot_as_arrayN(BMOperator *op, const char *slot_name, int *len)
+{
+ BMOpSlot *slot = BMO_slot_get(op, slot_name);
+ void *ret;
+
+ /* could add support for mapping type */
+ BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF);
+
+ ret = MEM_mallocN(sizeof(void *) * slot->len, __func__);
+ memcpy(ret, slot->data.buf, sizeof(void *) * slot->len);
+ *len = slot->len;
+ return ret;
+}
void *BMO_slot_ptr_get(BMOperator *op, const char *slot_name)
{
diff --git a/source/blender/bmesh/operators/bmo_mirror.c b/source/blender/bmesh/operators/bmo_mirror.c
index c6b228b988e..937601712b0 100644
--- a/source/blender/bmesh/operators/bmo_mirror.c
+++ b/source/blender/bmesh/operators/bmo_mirror.c
@@ -88,7 +88,7 @@ void bmo_mirror_exec(BMesh *bm, BMOperator *op)
v = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL);
for (i = 0; i < ototvert; i++) {
- if (ABS(v->co[axis]) <= dist) {
+ if (fabsf(v->co[axis]) <= dist) {
BMO_slot_map_ptr_insert(bm, &weldop, "targetmap", vmap[i], v);
}
v = BM_iter_step(&iter);
diff --git a/source/blender/bmesh/operators/bmo_removedoubles.c b/source/blender/bmesh/operators/bmo_removedoubles.c
index cd792f911a9..ea6cd747037 100644
--- a/source/blender/bmesh/operators/bmo_removedoubles.c
+++ b/source/blender/bmesh/operators/bmo_removedoubles.c
@@ -488,72 +488,71 @@ void bmo_collapse_uvs_exec(BMesh *bm, BMOperator *op)
static void bmesh_find_doubles_common(BMesh *bm, BMOperator *op, BMOperator *optarget, const char *targetmapname)
{
- BMOIter oiter;
- BMVert *v, *v2;
- BMVert **verts = NULL;
- BLI_array_declare(verts);
- float dist, dist3;
- int i, j, len, keepvert = 0;
-
- dist = BMO_slot_float_get(op, "dist");
- dist3 = dist * 3.0f;
-
- i = 0;
- BMO_ITER (v, &oiter, bm, op, "verts", BM_VERT) {
- BLI_array_grow_one(verts);
- verts[i++] = v;
- }
+ BMVert **verts;
+ int verts_len;
+
+ int i, j, keepvert = 0;
+
+ const float dist = BMO_slot_float_get(op, "dist");
+ const float dist3 = dist * 3.0f;
/* Test whether keep_verts arg exists and is non-empty */
if (BMO_slot_exists(op, "keep_verts")) {
+ BMOIter oiter;
keepvert = BMO_iter_new(&oiter, bm, op, "keep_verts", BM_VERT) != NULL;
}
+ /* get the verts as an array we can sort */
+ verts = BMO_slot_as_arrayN(op, "verts", &verts_len);
+
/* sort by vertex coordinates added together */
- qsort(verts, BLI_array_count(verts), sizeof(void *), vergaverco);
+ qsort(verts, verts_len, sizeof(BMVert *), vergaverco);
/* Flag keep_verts */
if (keepvert) {
BMO_slot_buffer_flag_enable(bm, op, "keep_verts", BM_VERT, VERT_KEEP);
}
- len = BLI_array_count(verts);
- for (i = 0; i < len; i++) {
- v = verts[i];
- if (BMO_elem_flag_test(bm, v, VERT_DOUBLE)) {
+ for (i = 0; i < verts_len; i++) {
+ BMVert *v_check = verts[i];
+
+ if (BMO_elem_flag_test(bm, v_check, VERT_DOUBLE)) {
continue;
}
- for (j = i + 1; j < len; j++) {
- v2 = verts[j];
+ for (j = i + 1; j < verts_len; j++) {
+ BMVert *v_other = verts[j];
/* Compare sort values of the verts using 3x tolerance (allowing for the tolerance
* on each of the three axes). This avoids the more expensive length comparison
* for most vertex pairs. */
- if ((v2->co[0] + v2->co[1] + v2->co[2]) - (v->co[0] + v->co[1] + v->co[2]) > dist3)
+ if ((v_other->co[0] + v_other->co[1] + v_other->co[2]) -
+ (v_check->co[0] + v_check->co[1] + v_check->co[2]) > dist3)
+ {
break;
+ }
if (keepvert) {
- if (BMO_elem_flag_test(bm, v2, VERT_KEEP) == BMO_elem_flag_test(bm, v, VERT_KEEP))
+ if (BMO_elem_flag_test(bm, v_other, VERT_KEEP) == BMO_elem_flag_test(bm, v_check, VERT_KEEP))
continue;
}
- if (compare_len_v3v3(v->co, v2->co, dist)) {
+ if (compare_len_v3v3(v_check->co, v_other->co, dist)) {
/* If one vert is marked as keep, make sure it will be the target */
- if (BMO_elem_flag_test(bm, v2, VERT_KEEP)) {
- SWAP(BMVert *, v, v2);
+ if (BMO_elem_flag_test(bm, v_other, VERT_KEEP)) {
+ SWAP(BMVert *, v_check, v_other);
}
- BMO_elem_flag_enable(bm, v2, VERT_DOUBLE);
- BMO_elem_flag_enable(bm, v, VERT_TARGET);
+ BMO_elem_flag_enable(bm, v_other, VERT_DOUBLE);
+ BMO_elem_flag_enable(bm, v_check, VERT_TARGET);
- BMO_slot_map_ptr_insert(bm, optarget, targetmapname, v2, v);
+ BMO_slot_map_ptr_insert(bm, optarget, targetmapname, v_other, v_check);
}
}
}
- BLI_array_free(verts);
+ MEM_freeN(verts);
}
void bmo_remove_doubles_exec(BMesh *bm, BMOperator *op)
diff --git a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp
index 1ad888e5989..0efead77cd4 100644
--- a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp
@@ -102,12 +102,12 @@ void GaussianAlphaXBlurOperation::executePixel(float output[4], int x, int y, vo
int bufferstarty = inputBuffer->getRect()->ymin;
int miny = y;
- int maxy = y;
+ // int maxy = y; // UNUSED
int minx = x - this->m_rad;
- int maxx = x + this->m_rad;
+ int maxx = x + this->m_rad; // UNUSED
miny = max(miny, inputBuffer->getRect()->ymin);
minx = max(minx, inputBuffer->getRect()->xmin);
- maxy = min(maxy, inputBuffer->getRect()->ymax);
+ // maxy = min(maxy, inputBuffer->getRect()->ymax);
maxx = min(maxx, inputBuffer->getRect()->xmax);
/* *** this is the main part which is different to 'GaussianXBlurOperation' *** */
diff --git a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
index 60a325c5f38..1f9cc8e461a 100644
--- a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
@@ -104,11 +104,11 @@ void GaussianAlphaYBlurOperation::executePixel(float output[4], int x, int y, vo
int miny = y - this->m_rad;
int maxy = y + this->m_rad;
int minx = x;
- int maxx = x;
+ // int maxx = x; // UNUSED
miny = max(miny, inputBuffer->getRect()->ymin);
minx = max(minx, inputBuffer->getRect()->xmin);
- maxy = min(maxy, inputBuffer->getRect()->ymax);
- maxx = min(maxx, inputBuffer->getRect()->xmax);
+ maxy = min(maxy, inputBuffer->getRect()->ymax - 1);
+ // maxx = min(maxx, inputBuffer->getRect()->xmax);
/* *** this is the main part which is different to 'GaussianYBlurOperation' *** */
int step = getStep();
diff --git a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
index f6c30f7097c..573a19466e8 100644
--- a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
@@ -85,13 +85,13 @@ void GaussianXBlurOperation::executePixel(float output[4], int x, int y, void *d
int bufferstarty = inputBuffer->getRect()->ymin;
int miny = y;
- int maxy = y;
+ // int maxy = y; // UNUSED
int minx = x - this->m_rad;
int maxx = x + this->m_rad;
miny = max(miny, inputBuffer->getRect()->ymin);
minx = max(minx, inputBuffer->getRect()->xmin);
- maxy = min(maxy, inputBuffer->getRect()->ymax);
- maxx = min(maxx, inputBuffer->getRect()->xmax);
+ // maxy = min(maxy, inputBuffer->getRect()->ymax);
+ maxx = min(maxx, inputBuffer->getRect()->xmax - 1);
int step = getStep();
int offsetadd = getOffsetAdd();
diff --git a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp
index 433771d2c0c..0c0a4d8aa4f 100644
--- a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp
@@ -87,11 +87,11 @@ void GaussianYBlurOperation::executePixel(float output[4], int x, int y, void *d
int miny = y - this->m_rad;
int maxy = y + this->m_rad;
int minx = x;
- int maxx = x;
+ // int maxx = x; // UNUSED
miny = max(miny, inputBuffer->getRect()->ymin);
minx = max(minx, inputBuffer->getRect()->xmin);
- maxy = min(maxy, inputBuffer->getRect()->ymax);
- maxx = min(maxx, inputBuffer->getRect()->xmax);
+ maxy = min(maxy, inputBuffer->getRect()->ymax - 1);
+ // maxx = min(maxx, inputBuffer->getRect()->xmax);
int index;
int step = getStep();
diff --git a/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp b/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp
index c9b129d8dcf..0874e2f59be 100644
--- a/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp
+++ b/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp
@@ -151,21 +151,24 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri
pattern_ibuf = BKE_tracking_get_pattern_imbuf(ibuf, track, marker, TRUE, FALSE);
zero_v3(site->color);
- for (j = 0; j < pattern_ibuf->x * pattern_ibuf->y; j++) {
- if (pattern_ibuf->rect_float) {
- add_v3_v3(site->color, &pattern_ibuf->rect_float[4 * j]);
- }
- else {
- unsigned char *rrgb = (unsigned char *)pattern_ibuf->rect;
- site->color[0] += srgb_to_linearrgb((float)rrgb[4 * j + 0] / 255.0f);
- site->color[1] += srgb_to_linearrgb((float)rrgb[4 * j + 1] / 255.0f);
- site->color[2] += srgb_to_linearrgb((float)rrgb[4 * j + 2] / 255.0f);
+ if (pattern_ibuf) {
+ for (j = 0; j < pattern_ibuf->x * pattern_ibuf->y; j++) {
+ if (pattern_ibuf->rect_float) {
+ add_v3_v3(site->color, &pattern_ibuf->rect_float[4 * j]);
+ }
+ else {
+ unsigned char *rrgb = (unsigned char *)pattern_ibuf->rect;
+
+ site->color[0] += srgb_to_linearrgb((float)rrgb[4 * j + 0] / 255.0f);
+ site->color[1] += srgb_to_linearrgb((float)rrgb[4 * j + 1] / 255.0f);
+ site->color[2] += srgb_to_linearrgb((float)rrgb[4 * j + 2] / 255.0f);
+ }
}
- }
- mul_v3_fl(site->color, 1.0f / (pattern_ibuf->x * pattern_ibuf->y));
- IMB_freeImBuf(pattern_ibuf);
+ mul_v3_fl(site->color, 1.0f / (pattern_ibuf->x * pattern_ibuf->y));
+ IMB_freeImBuf(pattern_ibuf);
+ }
site->co[0] = pos[0] * width;
site->co[1] = pos[1] * height;
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c
index ae7abd82600..28db7bf572d 100644
--- a/source/blender/editors/animation/keyingsets.c
+++ b/source/blender/editors/animation/keyingsets.c
@@ -325,8 +325,9 @@ static int add_keyingset_button_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "Cannot add property to built in keying set");
return OPERATOR_CANCELLED;
}
- else
+ else {
ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1);
+ }
/* try to add to keyingset using property retrieved from UI */
uiContextActiveProperty(C, &ptr, &prop, &index);
@@ -360,9 +361,10 @@ static int add_keyingset_button_exec(bContext *C, wmOperator *op)
if (success) {
/* send updates */
DAG_ids_flush_update(bmain, 0);
-
- /* for now, only send ND_KEYS for KeyingSets */
WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL);
+
+ /* show notification/report header, so that users notice that something changed */
+ BKE_reportf(op->reports, RPT_INFO, "Property added to Keying Set: '%s'", ks->name);
}
return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
@@ -411,8 +413,9 @@ static int remove_keyingset_button_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "Cannot remove property from built in keying set");
return OPERATOR_CANCELLED;
}
- else
+ else {
ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1);
+ }
/* try to add to keyingset using property retrieved from UI */
uiContextActiveProperty(C, &ptr, &prop, &index);
@@ -425,7 +428,7 @@ static int remove_keyingset_button_exec(bContext *C, wmOperator *op)
/* try to find a path matching this description */
ksp = BKE_keyingset_find_path(ks, ptr.id.data, ks->name, path, index, KSP_GROUP_KSNAME);
-
+
if (ksp) {
BKE_keyingset_free_path(ks, ksp);
success = 1;
@@ -440,9 +443,10 @@ static int remove_keyingset_button_exec(bContext *C, wmOperator *op)
if (success) {
/* send updates */
DAG_ids_flush_update(bmain, 0);
-
- /* for now, only send ND_KEYS for KeyingSets */
WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL);
+
+ /* show warning */
+ BKE_report(op->reports, RPT_INFO, "Property removed from Keying Set");
}
return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
@@ -891,11 +895,13 @@ short ANIM_validate_keyingset(bContext *C, ListBase *dsources, KeyingSet *ks)
ksi->iter(ksi, C, ks);
/* if we don't have any paths now, then this still qualifies as invalid context */
+ // FIXME: we need some error conditions (to be retrieved from the iterator why this failed!)
if (ks->paths.first == NULL)
return MODIFYKEY_INVALID_CONTEXT;
}
else {
/* poll callback tells us that KeyingSet is useless in current context */
+ // FIXME: the poll callback needs to give us more info why
return MODIFYKEY_INVALID_CONTEXT;
}
}
diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c
index d92c20a1265..fd87e6752f2 100644
--- a/source/blender/editors/curve/editfont.c
+++ b/source/blender/editors/curve/editfont.c
@@ -1289,32 +1289,6 @@ static int insert_text_invoke(bContext *C, wmOperator *op, wmEvent *evt)
insert_into_textbuf(obedit, ascii);
accentcode = 0;
}
- else if (cu->len < MAXTEXT - 1) {
- if (alt) {
- /* might become obsolete, apple has default values for this, other OS's too? */
- if (ascii == 't') ascii = 137;
- else if (ascii == 'c') ascii = 169;
- else if (ascii == 'f') ascii = 164;
- else if (ascii == 'g') ascii = 176;
- else if (ascii == 'l') ascii = 163;
- else if (ascii == 'r') ascii = 174;
- else if (ascii == 's') ascii = 223;
- else if (ascii == 'y') ascii = 165;
- else if (ascii == '.') ascii = 138;
- else if (ascii == '1') ascii = 185;
- else if (ascii == '2') ascii = 178;
- else if (ascii == '3') ascii = 179;
- else if (ascii == '%') ascii = 139;
- else if (ascii == '?') ascii = 191;
- else if (ascii == '!') ascii = 161;
- else if (ascii == 'x') ascii = 215;
- else if (ascii == '>') ascii = 187;
- else if (ascii == '<') ascii = 171;
- }
-
- inserted_text[0] = ascii;
- insert_into_textbuf(obedit, ascii);
- }
kill_selection(obedit, 1);
text_update_edited(C, scene, obedit, 1, FO_EDIT);
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index b8e4fec1259..c6e25ab9a34 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -1902,8 +1902,9 @@ void ui_set_but_default(bContext *C, short all)
static double soft_range_round_up(double value, double max)
{
- /* round up to .., 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, .. */
- double newmax = pow(10.0, ceil(log(value) / M_LN10));
+ /* round up to .., 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, ..
+ * checking for 0.0 prevents floating point exceptions */
+ double newmax = (value != 0.0) ? pow(10.0, ceil(log(value) / M_LN10)) : 0.0;
if (newmax * 0.2 >= max && newmax * 0.2 >= value)
return newmax * 0.2;
@@ -1915,8 +1916,9 @@ static double soft_range_round_up(double value, double max)
static double soft_range_round_down(double value, double max)
{
- /* round down to .., 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, .. */
- double newmax = pow(10.0, floor(log(value) / M_LN10));
+ /* round down to .., 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, ..
+ * checking for 0.0 prevents floating point exceptions */
+ double newmax = (value != 0.0) ? pow(10.0, floor(log(value) / M_LN10)) : 0.0;
if (newmax * 5.0 <= max && newmax * 5.0 <= value)
return newmax * 5.0;
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 469bd11215e..4d96ad810d4 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -1597,17 +1597,15 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
&scopes->undist_marker, scopes->use_track_mask,
width, height, scopes->track_pos);
- if (tmpibuf->rect_float)
- IMB_rect_from_float(tmpibuf);
+ if (tmpibuf) {
+ if (tmpibuf->rect_float)
+ IMB_rect_from_float(tmpibuf);
- /* XXX: for debug only
- * tmpibuf->ftype = PNG;
- * IMB_saveiff(tmpibuf, "sample.png", IB_rect); */
-
- if (tmpibuf->rect)
- scopes->track_preview = tmpibuf;
- else
- IMB_freeImBuf(tmpibuf);
+ if (tmpibuf->rect)
+ scopes->track_preview = tmpibuf;
+ else
+ IMB_freeImBuf(tmpibuf);
+ }
}
if (!ok && scopes->track_preview) {
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 6d262daab12..ecb161714ee 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -3306,7 +3306,7 @@ static int ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx,
ui_get_but_vectorf(but, rgb);
- if (color_profile && (int)but->a1)
+ if (color_profile && (int)but->a1 != UI_GRAD_SV)
ui_block_to_display_space_v3(but->block, rgb);
rgb_to_hsv_compat_v(rgb, hsv);
@@ -3352,7 +3352,7 @@ static int ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx,
hsv_to_rgb_v(hsv, rgb);
- if (color_profile && (int)but->a1)
+ if (color_profile && ((int)but->a1 != UI_GRAD_SV))
ui_block_to_scene_linear_v3(but->block, rgb);
copy_v3_v3(data->vec, rgb);
@@ -3378,7 +3378,7 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, wmNDOF
ui_get_but_vectorf(but, rgb);
- if (color_profile && (int)but->a1)
+ if (color_profile && (int)but->a1 != UI_GRAD_SV)
ui_block_to_display_space_v3(but->block, rgb);
rgb_to_hsv_compat_v(rgb, hsv);
@@ -3418,7 +3418,7 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, wmNDOF
hsv_to_rgb_v(hsv, rgb);
- if (color_profile && (int)but->a1)
+ if (color_profile && (int)but->a1 != UI_GRAD_SV)
ui_block_to_scene_linear_v3(but->block, rgb);
copy_v3_v3(data->vec, rgb);
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 16159e0f73a..540a9cc752b 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -176,7 +176,25 @@ struct uiBut {
char *poin;
float hardmin, hardmax, softmin, softmax;
- float a1, a2;
+
+ /* both these values use depends on the button type
+ * (polymorphic struct or union would be nicer for this stuff) */
+
+ /* (type == COLOR), Use UI_GRAD_* values.
+ * (type == NUM), Use to store RNA 'step' value, for dragging and click-step.
+ * (type == LABEL), Use (a1 == 1.0f) to use a2 as a blending factor (wow, this is imaginative!).
+ * (type == SCROLL) Use as scroll size.
+ * (type == SEARCH_MENU) Use as number or rows.
+ */
+ float a1;
+
+ /* (type == HSVCIRCLE ), Use to store the luminosity.
+ * (type == NUM), Use to store RNA 'precision' value, for dragging and click-step.
+ * (type == LABEL), If (a1 == 1.0f) use a2 as a blending factor.
+ * (type == SEARCH_MENU) Use as number or columns.
+ */
+ float a2;
+
float aspect;
unsigned char col[4];
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 5170fc7d51b..52d909a34c0 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -1780,7 +1780,7 @@ static void ui_litem_layout_row(uiLayout *litem)
if (item->flag) {
/* fixed minimum size items */
- itemw = ui_item_fit(minw, fixedx, fixedw, MIN2(w, fixedw), !item->next, litem->alignment, NULL);
+ itemw = ui_item_fit(minw, fixedx, fixedw, min_ii(w, fixedw), !item->next, litem->alignment, NULL);
fixedx += itemw;
}
else {
@@ -1959,9 +1959,9 @@ static void ui_litem_estimate_column_flow(uiLayout *litem)
ui_item_size(item, &itemw, &itemh);
y -= itemh + style->buttonspacey;
- miny = MIN2(miny, y);
+ miny = min_ii(miny, y);
emy -= itemh;
- maxw = MAX2(itemw, maxw);
+ maxw = max_ii(itemw, maxw);
/* decide to go to next one */
if (col < flow->totcol - 1 && emy <= -emh) {
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c
index 4476296866e..900bf57b509 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -903,11 +903,16 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
/* offset other selected objects */
if (do_inverse_offset && (centermode != GEOMETRY_TO_ORIGIN)) {
CollectionPointerLink *ctx_link_other;
+ float obmat[4][4];
/* was the object data modified
* note: the functions above must set 'cent' */
+
+ /* convert the offset to parent space */
+ BKE_object_to_mat4(ob, obmat);
copy_v3_v3(centn, cent);
- mul_mat3_m4_v3(ob->obmat, centn); /* ommit translation part */
+ mul_mat3_m4_v3(obmat, centn); /* omit translation part */
+
add_v3_v3(ob->loc, centn);
BKE_object_where_is_calc(scene, ob);
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c
index 218af8f0f33..7cd153d9564 100644
--- a/source/blender/editors/physics/physics_fluid.c
+++ b/source/blender/editors/physics/physics_fluid.c
@@ -574,7 +574,8 @@ static void export_fluid_objects(ListBase *fobjects, Scene *scene, int length)
fsmesh.channelScale = NULL;
/* Override user settings, only noslip is supported here! */
- fsmesh.obstacleType = FLUIDSIM_OBSTACLE_NOSLIP;
+ if (fsmesh.type != OB_FLUIDSIM_CONTROL)
+ fsmesh.obstacleType = FLUIDSIM_OBSTACLE_NOSLIP;
}
elbeemAddMesh(&fsmesh);
diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c
index fe802abc3a9..4b177629f72 100644
--- a/source/blender/editors/render/render_internal.c
+++ b/source/blender/editors/render/render_internal.c
@@ -295,7 +295,11 @@ static void make_renderinfo_string(RenderStats *rs, Scene *scene, char *str)
if (rs->tothalo) spos += sprintf(spos, "Ha:%d ", rs->tothalo);
if (rs->totstrand) spos += sprintf(spos, "St:%d ", rs->totstrand);
if (rs->totlamp) spos += sprintf(spos, "La:%d ", rs->totlamp);
- spos += sprintf(spos, "Mem:%.2fM (%.2fM, peak %.2fM) ", megs_used_memory, mmap_used_memory, megs_peak_memory);
+
+ if (rs->mem_peak == 0.0f)
+ spos += sprintf(spos, "Mem:%.2fM (%.2fM, peak %.2fM) ", megs_used_memory, mmap_used_memory, megs_peak_memory);
+ else
+ spos += sprintf(spos, "Mem:%.2fM, Peak: %.2fM ", rs->mem_used, rs->mem_peak);
if (rs->curfield)
spos += sprintf(spos, "Field %d ", rs->curfield);
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index a2f31b35246..b119165fbd0 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -237,6 +237,14 @@ static int preview_mat_has_sss(Material *mat, bNodeTree *ntree)
return 0;
}
+static Scene *preview_get_scene(void)
+{
+ if (pr_main == NULL) return NULL;
+
+ return pr_main->scene.first;
+}
+
+
/* call this with a pointer to initialize preview scene */
/* call this with NULL to restore assigned ID pointers in preview scene */
static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPreview *sp)
@@ -244,9 +252,7 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre
Scene *sce;
Base *base;
- if (pr_main == NULL) return NULL;
-
- sce = pr_main->scene.first;
+ sce = preview_get_scene();
if (sce) {
/* this flag tells render to not execute depsgraph or ipos etc */
@@ -266,10 +272,13 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre
BKE_color_managed_view_settings_copy(&sce->view_settings, &scene->view_settings);
/* prevent overhead for small renders and icons (32) */
- if (id && sp->sizex < 40)
- sce->r.xparts = sce->r.yparts = 1;
- else
- sce->r.xparts = sce->r.yparts = 4;
+ if (id && sp->sizex < 40) {
+ sce->r.tilex = sce->r.tiley = 64;
+ }
+ else {
+ sce->r.tilex = sce->r.xsch / 4;
+ sce->r.tiley = sce->r.ysch / 4;
+ }
/* exception: don't apply render part of display transform for texture previews or icons */
if ((id && sp->pr_method == PR_ICON_RENDER) || id_type == ID_TE) {
@@ -662,8 +671,23 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
char name[32];
int sizex;
+ /* in case of split preview, use border render */
+ if (split) {
+ if (first) sizex = sp->sizex / 2;
+ else sizex = sp->sizex - sp->sizex / 2;
+ }
+ else sizex = sp->sizex;
+
+ /* we have to set preview variables first */
+ sce = preview_get_scene();
+ if (sce) {
+ sce->r.xsch = sizex;
+ sce->r.ysch = sp->sizey;
+ sce->r.size = 100;
+ }
+
/* get the stuff from the builtin preview dbase */
- sce = preview_prepare_scene(sp->scene, id, idtype, sp); // XXX sizex
+ sce = preview_prepare_scene(sp->scene, id, idtype, sp);
if (sce == NULL) return;
if (!split || first) sprintf(name, "Preview %p", sp->owner);
@@ -691,17 +715,6 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
sce->r.mode |= R_OSA;
}
- /* in case of split preview, use border render */
- if (split) {
- if (first) sizex = sp->sizex / 2;
- else sizex = sp->sizex - sp->sizex / 2;
- }
- else sizex = sp->sizex;
-
- /* allocates or re-uses render result */
- sce->r.xsch = sizex;
- sce->r.ysch = sp->sizey;
- sce->r.size = 100;
/* callbacs are cleared on GetRender() */
if (ELEM(sp->pr_method, PR_BUTS_RENDER, PR_NODE_RENDER)) {
diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c
index c5320fde0ff..0a2ca379518 100644
--- a/source/blender/editors/render/render_update.c
+++ b/source/blender/editors/render/render_update.c
@@ -378,6 +378,12 @@ static void scene_changed(Main *bmain, Scene *UNUSED(scene))
void ED_render_id_flush_update(Main *bmain, ID *id)
{
+ /* this can be called from render or baking thread when a python script makes
+ * changes, in that case we don't want to do any editor updates, and making
+ * GPU changes is not possible because OpenGL only works in the main thread */
+ if (!BLI_thread_is_main())
+ return;
+
switch (GS(id->name)) {
case ID_MA:
material_changed(bmain, (Material *)id);
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index e00a8776bea..bd6852c4344 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -288,9 +288,11 @@ typedef struct ProjPaintState {
char *vertFlags; /* store options per vert, now only store if the vert is pointing away from the view */
int buckets_x; /* The size of the bucket grid, the grid span's screenMin/screenMax so you can paint outsize the screen or with 2 brushes at once */
int buckets_y;
-
+
ProjPaintImage *projImages;
+ int pixel_sizeof; /* result of project_paint_pixel_sizeof(), constant per stroke */
+
int image_tot; /* size of projectImages array */
float (*screenCoords)[4]; /* verts projected into floating point screen space */
@@ -379,6 +381,18 @@ typedef struct ProjPixelClone {
PixelStore clonepx;
} ProjPixelClone;
+/* blur, store surrounding colors */
+#define PROJ_PIXEL_SOFTEN_TOT 4
+/* blur picking offset (in screenspace) */
+#define PROJ_PIXEL_SOFTEN_OFS_PX 1.0f
+
+static const float proj_pixel_soften_v2[PROJ_PIXEL_SOFTEN_TOT][2] = {
+ {-PROJ_PIXEL_SOFTEN_OFS_PX, 0.0f},
+ { 0.0f, -PROJ_PIXEL_SOFTEN_OFS_PX},
+ { 0.0f, PROJ_PIXEL_SOFTEN_OFS_PX},
+ { PROJ_PIXEL_SOFTEN_OFS_PX, 0.0f},
+};
+
/* Finish projection painting structs */
typedef struct UndoImageTile {
@@ -1491,6 +1505,16 @@ static float project_paint_uvpixel_mask(
return mask;
}
+static int project_paint_pixel_sizeof(const short tool)
+{
+ if ((tool == PAINT_TOOL_CLONE) || (tool == PAINT_TOOL_SMEAR)) {
+ return sizeof(ProjPixelClone);
+ }
+ else {
+ return sizeof(ProjPixel);
+ }
+}
+
/* run this function when we know a bucket's, face's pixel can be initialized,
* return the ProjPixel which is added to 'ps->bucketRect[bucket_index]' */
static ProjPixel *project_paint_uvpixel_init(
@@ -1506,33 +1530,23 @@ static ProjPixel *project_paint_uvpixel_init(
const float w[3])
{
ProjPixel *projPixel;
- short size;
-
+
/* wrap pixel location */
x_px = x_px % ibuf->x;
if (x_px < 0) x_px += ibuf->x;
y_px = y_px % ibuf->y;
if (y_px < 0) y_px += ibuf->y;
-
- if (ps->tool == PAINT_TOOL_CLONE) {
- size = sizeof(ProjPixelClone);
- }
- else if (ps->tool == PAINT_TOOL_SMEAR) {
- size = sizeof(ProjPixelClone);
- }
- else {
- size = sizeof(ProjPixel);
- }
-
- projPixel = (ProjPixel *)BLI_memarena_alloc(arena, size);
+
+ BLI_assert(ps->pixel_sizeof == project_paint_pixel_sizeof(ps->tool));
+ projPixel = (ProjPixel *)BLI_memarena_alloc(arena, ps->pixel_sizeof);
//memset(projPixel, 0, size);
if (ibuf->rect_float) {
projPixel->pixel.f_pt = ibuf->rect_float + ((x_px + y_px * ibuf->x) * 4);
- projPixel->origColor.f[0] = projPixel->newColor.f[0] = projPixel->pixel.f_pt[0];
- projPixel->origColor.f[1] = projPixel->newColor.f[1] = projPixel->pixel.f_pt[1];
- projPixel->origColor.f[2] = projPixel->newColor.f[2] = projPixel->pixel.f_pt[2];
- projPixel->origColor.f[3] = projPixel->newColor.f[3] = projPixel->pixel.f_pt[3];
+ projPixel->origColor.f[0] = projPixel->newColor.f[0] = projPixel->pixel.f_pt[0];
+ projPixel->origColor.f[1] = projPixel->newColor.f[1] = projPixel->pixel.f_pt[1];
+ projPixel->origColor.f[2] = projPixel->newColor.f[2] = projPixel->pixel.f_pt[2];
+ projPixel->origColor.f[3] = projPixel->newColor.f[3] = projPixel->pixel.f_pt[3];
}
else {
projPixel->pixel.ch_pt = ((unsigned char *)ibuf->rect + ((x_px + y_px * ibuf->x) * 4));
@@ -3814,6 +3828,84 @@ static void do_projectpaint_smear_f(ProjPaintState *ps, ProjPixel *projPixel, fl
BLI_linklist_prepend_arena(smearPixels_f, (void *)projPixel, smearArena);
}
+/* do_projectpaint_soften for float & byte
+ */
+static float inv_pow2(float f)
+{
+ f = 1.0f - f;
+ f = f * f;
+ return 1.0f - f;
+}
+
+static void do_projectpaint_soften_f(ProjPaintState *ps, ProjPixel *projPixel, float alpha, float mask, MemArena *softenArena, LinkNode **softenPixels)
+{
+ unsigned int accum_tot = 0;
+ unsigned int i;
+
+ float *rgba = projPixel->newColor.f;
+
+ /* sigh, alpha values tend to need to be a _lot_ stronger with blur */
+ mask = inv_pow2(mask);
+ alpha = inv_pow2(alpha);
+
+ /* rather then painting, accumulate surrounding colors */
+ zero_v4(rgba);
+
+ for (i = 0; i < PROJ_PIXEL_SOFTEN_TOT; i++) {
+ float co_ofs[2];
+ float rgba_tmp[4];
+ sub_v2_v2v2(co_ofs, projPixel->projCoSS, proj_pixel_soften_v2[i]);
+ if (project_paint_PickColor(ps, co_ofs, rgba_tmp, NULL, TRUE)) {
+ add_v4_v4(rgba, rgba_tmp);
+ accum_tot++;
+ }
+ }
+
+ if (LIKELY(accum_tot != 0)) {
+ mul_v4_fl(rgba, 1.0f / (float)accum_tot);
+ blend_color_mix_float(rgba, projPixel->pixel.f_pt, rgba, alpha);
+ if (mask < 1.0f) blend_color_mix_float(rgba, projPixel->origColor.f, rgba, mask);
+ BLI_linklist_prepend_arena(softenPixels, (void *)projPixel, softenArena);
+ }
+}
+
+static void do_projectpaint_soften(ProjPaintState *ps, ProjPixel *projPixel, float alpha, float mask, MemArena *softenArena, LinkNode **softenPixels)
+{
+ unsigned int accum_tot = 0;
+ unsigned int i;
+
+ float rgba[4]; /* convert to byte after */
+
+ /* sigh, alpha values tend to need to be a _lot_ stronger with blur */
+ mask = inv_pow2(mask);
+ alpha = inv_pow2(alpha);
+
+ /* rather then painting, accumulate surrounding colors */
+ zero_v4(rgba);
+
+ for (i = 0; i < PROJ_PIXEL_SOFTEN_TOT; i++) {
+ float co_ofs[2];
+ float rgba_tmp[4];
+ sub_v2_v2v2(co_ofs, projPixel->projCoSS, proj_pixel_soften_v2[i]);
+ if (project_paint_PickColor(ps, co_ofs, rgba_tmp, NULL, TRUE)) {
+ add_v4_v4(rgba, rgba_tmp);
+ accum_tot++;
+ }
+ }
+
+ if (LIKELY(accum_tot != 0)) {
+ unsigned char *rgba_ub = projPixel->newColor.ch;
+
+ mul_v4_fl(rgba, 1.0f / (float)accum_tot);
+ IMAPAINT_FLOAT_RGBA_TO_CHAR(rgba_ub, rgba);
+
+ blend_color_mix(rgba_ub, projPixel->pixel.ch_pt, rgba_ub, (int)(alpha * 255));
+ if (mask != 1.0f) blend_color_mix(rgba_ub, projPixel->origColor.ch, rgba_ub, (int)(mask * 255));
+ BLI_linklist_prepend_arena(softenPixels, (void *)projPixel, softenArena);
+ }
+}
+
+
static void do_projectpaint_draw(ProjPaintState *ps, ProjPixel *projPixel, const float rgba[4], float alpha, float mask)
{
unsigned char rgba_ub[4];
@@ -3912,6 +4004,10 @@ static void *do_projectpaint_thread(void *ph_v)
LinkNode *smearPixels = NULL;
LinkNode *smearPixels_f = NULL;
MemArena *smearArena = NULL; /* mem arena for this brush projection only */
+
+ LinkNode *softenPixels = NULL;
+ LinkNode *softenPixels_f = NULL;
+ MemArena *softenArena = NULL; /* mem arena for this brush projection only */
if (tool == PAINT_TOOL_SMEAR) {
pos_ofs[0] = pos[0] - lastpos[0];
@@ -3919,6 +4015,9 @@ static void *do_projectpaint_thread(void *ph_v)
smearArena = BLI_memarena_new(1 << 16, "paint smear arena");
}
+ else if (tool == PAINT_TOOL_SOFTEN) {
+ softenArena = BLI_memarena_new(1 << 16, "paint soften arena");
+ }
/* printf("brush bounds %d %d %d %d\n", bucketMin[0], bucketMin[1], bucketMax[0], bucketMax[1]); */
@@ -4058,6 +4157,10 @@ static void *do_projectpaint_thread(void *ph_v)
if (is_floatbuf) do_projectpaint_smear_f(ps, projPixel, alpha, mask, smearArena, &smearPixels_f, co);
else do_projectpaint_smear(ps, projPixel, alpha, mask, smearArena, &smearPixels, co);
break;
+ case PAINT_TOOL_SOFTEN:
+ if (is_floatbuf) do_projectpaint_soften_f(ps, projPixel, alpha, mask, softenArena, &softenPixels_f);
+ else do_projectpaint_soften(ps, projPixel, alpha, mask, softenArena, &softenPixels);
+ break;
default:
if (is_floatbuf) do_projectpaint_draw_f(ps, projPixel, rgba, alpha, mask, use_color_correction);
else do_projectpaint_draw(ps, projPixel, rgba, alpha, mask);
@@ -4092,7 +4195,21 @@ static void *do_projectpaint_thread(void *ph_v)
BLI_memarena_free(smearArena);
}
-
+ else if (tool == PAINT_TOOL_SOFTEN) {
+
+ for (node = softenPixels; node; node = node->next) { /* this wont run for a float image */
+ projPixel = node->link;
+ *projPixel->pixel.uint_pt = projPixel->newColor.uint;
+ }
+
+ for (node = softenPixels_f; node; node = node->next) {
+ projPixel = node->link;
+ copy_v4_v4(projPixel->pixel.f_pt, projPixel->newColor.f);
+ }
+
+ BLI_memarena_free(softenArena);
+ }
+
return NULL;
}
@@ -4842,6 +4959,10 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps)
ps->tool = brush->imagepaint_tool;
ps->blend = brush->blend;
+ /* sizeof ProjPixel, since we alloc this a _lot_ */
+ ps->pixel_sizeof = project_paint_pixel_sizeof(ps->tool);
+ BLI_assert(ps->pixel_sizeof >= sizeof(ProjPixel));
+
ps->is_airbrush = (brush->flag & BRUSH_AIRBRUSH) ? 1 : 0;
ps->is_texbrush = (brush->mtex.tex) ? 1 : 0;
@@ -4907,13 +5028,6 @@ static int texture_paint_init(bContext *C, wmOperator *op)
pop->first = 1;
op->customdata = pop;
-
- /* XXX: Soften tool does not support projection painting atm, so just disable
- * projection for this brush */
- if (brush->imagepaint_tool == PAINT_TOOL_SOFTEN) {
- settings->imapaint.flag |= IMAGEPAINT_PROJECT_DISABLE;
- pop->restore_projection = 1;
- }
/* initialize from context */
if (CTX_wm_region_view3d(C)) {
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c
index fc9c040852f..a2e4da719e9 100644
--- a/source/blender/editors/space_clip/clip_draw.c
+++ b/source/blender/editors/space_clip/clip_draw.c
@@ -213,7 +213,7 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc
x = (sc->user.framenr - sfra) / (efra - sfra + 1) * ar->winx;
UI_ThemeColor(TH_CFRAME);
- glRecti(x, 0, x + framelen, 8);
+ glRecti(x, 0, x + ceilf(framelen), 8);
clip_draw_curfra_label(sc->user.framenr, x, 8.0f);
diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c
index dd939d57cbe..d97b112e95d 100644
--- a/source/blender/editors/space_clip/tracking_ops.c
+++ b/source/blender/editors/space_clip/tracking_ops.c
@@ -2944,6 +2944,19 @@ void CLIP_OT_track_copy_color(wmOperatorType *ot)
/********************** add 2d stabilization tracks operator *********************/
+static int stabilize_2d_poll(bContext *C)
+{
+ if (ED_space_clip_tracking_poll(C)) {
+ SpaceClip *sc = CTX_wm_space_clip(C);
+ MovieClip *clip = ED_space_clip_get_clip(sc);
+ MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(&clip->tracking);
+
+ return tracking_object->flag & TRACKING_OBJECT_CAMERA;
+ }
+
+ return FALSE;
+}
+
static int stabilize_2d_add_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceClip *sc = CTX_wm_space_clip(C);
@@ -2985,7 +2998,7 @@ void CLIP_OT_stabilize_2d_add(wmOperatorType *ot)
/* api callbacks */
ot->exec = stabilize_2d_add_exec;
- ot->poll = ED_space_clip_tracking_poll;
+ ot->poll = stabilize_2d_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -3045,7 +3058,7 @@ void CLIP_OT_stabilize_2d_remove(wmOperatorType *ot)
/* api callbacks */
ot->exec = stabilize_2d_remove_exec;
- ot->poll = ED_space_clip_tracking_poll;
+ ot->poll = stabilize_2d_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -3088,7 +3101,7 @@ void CLIP_OT_stabilize_2d_select(wmOperatorType *ot)
/* api callbacks */
ot->exec = stabilize_2d_select_exec;
- ot->poll = ED_space_clip_tracking_poll;
+ ot->poll = stabilize_2d_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -3125,7 +3138,7 @@ void CLIP_OT_stabilize_2d_set_rotation(wmOperatorType *ot)
/* api callbacks */
ot->exec = stabilize_2d_set_rotation_exec;
- ot->poll = ED_space_clip_tracking_poll;
+ ot->poll = stabilize_2d_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index c24447f16c3..2fc312b6205 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -744,6 +744,7 @@ void filelist_setfilter_types(struct FileList *filelist, const char *filter_glob
BLI_strncpy(filelist->filter_glob, filter_glob, sizeof(filelist->filter_glob));
}
+/* would recognize .blend as well */
static int file_is_blend_backup(const char *str)
{
short a, b;
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index 49562958f82..778a3f4df3e 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -164,6 +164,8 @@ short ED_fileselect_set_params(SpaceFile *sfile)
params->filter = 0;
if (RNA_struct_find_property(op->ptr, "filter_blender"))
params->filter |= RNA_boolean_get(op->ptr, "filter_blender") ? BLENDERFILE : 0;
+ if (RNA_struct_find_property(op->ptr, "filter_backup"))
+ params->filter |= RNA_boolean_get(op->ptr, "filter_backup") ? BLENDERFILE_BACKUP : 0;
if (RNA_struct_find_property(op->ptr, "filter_image"))
params->filter |= RNA_boolean_get(op->ptr, "filter_image") ? IMAGEFILE : 0;
if (RNA_struct_find_property(op->ptr, "filter_movie"))
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index c7f9bd87a1b..ce3c6e1fd26 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -618,7 +618,7 @@ void IMAGE_OT_view_all(wmOperatorType *ot)
/* identifiers */
ot->name = "View All";
ot->idname = "IMAGE_OT_view_all";
- ot->description = "View the whole picture";
+ ot->description = "View the entire image";
/* api callbacks */
ot->exec = image_view_all_exec;
@@ -805,7 +805,7 @@ void IMAGE_OT_view_zoom_ratio(wmOperatorType *ot)
/* identifiers */
ot->name = "View Zoom Ratio";
ot->idname = "IMAGE_OT_view_zoom_ratio";
- ot->description = "Set zoom ration of the view";
+ ot->description = "Set zoom ratio of the view";
/* api callbacks */
ot->exec = image_view_zoom_ratio_exec;
diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c
index f108881091a..cba0a808d63 100644
--- a/source/blender/editors/space_info/space_info.c
+++ b/source/blender/editors/space_info/space_info.c
@@ -58,6 +58,7 @@
#include "UI_view2d.h"
#include "info_intern.h" /* own include */
+#include "BLO_readfile.h"
/* ******************** default callbacks for info space ***************** */
@@ -271,11 +272,16 @@ static void info_header_listener(ARegion *ar, wmNotifier *wmn)
static void recent_files_menu_draw(const bContext *UNUSED(C), Menu *menu)
{
struct RecentFile *recent;
+ char file [FILE_MAX];
uiLayout *layout = menu->layout;
uiLayoutSetOperatorContext(layout, WM_OP_EXEC_REGION_WIN);
if (G.recent_files.first) {
for (recent = G.recent_files.first; (recent); recent = recent->next) {
- uiItemStringO(layout, BLI_path_basename(recent->filepath), ICON_FILE_BLEND, "WM_OT_open_mainfile", "filepath", recent->filepath);
+ BLI_split_file_part(recent->filepath, file, sizeof(file));
+ if (BLO_has_bfile_extension(file))
+ uiItemStringO(layout, BLI_path_basename(recent->filepath), ICON_FILE_BLEND, "WM_OT_open_mainfile", "filepath", recent->filepath);
+ else
+ uiItemStringO(layout, BLI_path_basename(recent->filepath), ICON_FILE_BACKUP, "WM_OT_open_mainfile", "filepath", recent->filepath);
}
}
else {
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 0938562857b..aafd4abb25e 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -108,6 +108,43 @@ static void node_socket_button_default(const bContext *C, uiBlock *block,
}
}
+static void node_socket_button_string(const bContext *C, uiBlock *block,
+ bNodeTree *ntree, bNode *node, bNodeSocket *sock,
+ const char *name, int x, int y, int width)
+{
+ if (sock->link || (sock->flag & SOCK_HIDE_VALUE))
+ node_socket_button_label(C, block, ntree, node, sock, name, x, y, width);
+ else {
+ PointerRNA ptr;
+ uiBut *bt;
+
+ SpaceNode *snode = CTX_wm_space_node(C);
+ const char *ui_name = IFACE_(name);
+ float slen;
+
+ UI_ThemeColor(TH_TEXT);
+ slen = (UI_GetStringWidth(ui_name) + NODE_MARGIN_X) * snode->aspect_sqrt;
+ while (slen > (width * 0.5f) && *ui_name) {
+ ui_name = BLI_str_find_next_char_utf8(ui_name, NULL);
+ slen = (UI_GetStringWidth(ui_name) + NODE_MARGIN_X) * snode->aspect_sqrt;
+ }
+
+ RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
+
+ if (name[0] == '\0')
+ slen = 0.0;
+
+ bt = uiDefButR(block, TEX, B_NODE_EXEC, "",
+ x, y + 1, width - slen, NODE_DY - 2,
+ &ptr, "default_value", 0, 0, 0, -1, -1, "");
+ if (node)
+ uiButSetFunc(bt, node_sync_cb, CTX_wm_space_node(C), node);
+
+ if (slen > 0.0f)
+ uiDefBut(block, LABEL, 0, IFACE_(name), x + (width - slen), y + 2, slen, NODE_DY - 2, NULL, 0, 0, 0, 0, "");
+ }
+}
+
typedef struct SocketComponentMenuArgs {
PointerRNA ptr;
int x, y, width;
@@ -209,9 +246,9 @@ static void node_draw_output_default(const bContext *C, uiBlock *block,
if (*ui_name) {
uiDefBut(block, LABEL, 0, ui_name,
- (int)(sock->locx - slen), (int)(sock->locy - 9.0f),
- (short)slen, (short)NODE_DY,
- NULL, 0, 0, 0, 0, "");
+ (int)(sock->locx - slen), (int)(sock->locy - 9.0f),
+ (short)slen, (short)NODE_DY,
+ NULL, 0, 0, 0, 0, "");
}
}
@@ -486,8 +523,9 @@ static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode)
bNodeSocket *sock, *gsock;
float locx, locy;
rctf *rect = &gnode->totr;
- float node_group_frame = U.dpi * NODE_GROUP_FRAME / 72;
- float group_header = 26 * U.dpi / 72;
+ const float dpi_fac = UI_DPI_ICON_FAC;
+ const float node_group_frame = NODE_GROUP_FRAME * dpi_fac;
+ const float group_header = 26 * dpi_fac;
int counter;
int dy;
@@ -664,7 +702,7 @@ static void draw_group_socket_name(SpaceNode *snode, bNode *gnode, bNodeSocket *
static void draw_group_socket(const bContext *C, SpaceNode *snode, bNodeTree *ntree, bNode *gnode,
bNodeSocket *sock, bNodeSocket *gsock, int index, int in_out)
{
- const float dpi_fac = U.dpi / 72.0f;
+ const float dpi_fac = UI_DPI_ICON_FAC;
bNodeTree *ngroup = (bNodeTree *)gnode->id;
bNodeSocketType *stype = ntreeGetSocketType(gsock ? gsock->type : sock->type);
uiBut *bt;
@@ -776,9 +814,9 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN
uiLayout *layout;
PointerRNA ptr;
rctf rect = gnode->totr;
- const float dpi_fac = U.dpi / 72.0f;
- float node_group_frame = NODE_GROUP_FRAME * dpi_fac;
- float group_header = 26 * dpi_fac;
+ const float dpi_fac = UI_DPI_ICON_FAC;
+ const float node_group_frame = NODE_GROUP_FRAME * dpi_fac;
+ const float group_header = 26 * dpi_fac;
int index;
@@ -1379,6 +1417,46 @@ static void node_shader_buts_tex_coord(uiLayout *layout, bContext *UNUSED(C), Po
uiItemR(layout, ptr, "from_dupli", 0, NULL, 0);
}
+static void node_shader_buts_normal_map(uiLayout *layout, bContext *C, PointerRNA *ptr)
+{
+ uiItemR(layout, ptr, "space", 0, "", 0);
+
+ if (RNA_enum_get(ptr, "space") == SHD_NORMAL_MAP_TANGENT) {
+ PointerRNA obptr = CTX_data_pointer_get(C, "active_object");
+
+ if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) {
+ PointerRNA dataptr = RNA_pointer_get(&obptr, "data");
+ uiItemPointerR(layout, ptr, "uv_map", &dataptr, "uv_textures", "", ICON_NONE);
+ }
+ else
+ uiItemR(layout, ptr, "uv_map", 0, "", 0);
+ }
+}
+
+static void node_shader_buts_tangent(uiLayout *layout, bContext *C, PointerRNA *ptr)
+{
+ uiLayout *split, *row;
+
+ split = uiLayoutSplit(layout, 0.0f, FALSE);
+
+ uiItemR(split, ptr, "direction_type", 0, "", 0);
+
+ row = uiLayoutRow(split, FALSE);
+
+ if (RNA_enum_get(ptr, "direction_type") == SHD_TANGENT_UVMAP) {
+ PointerRNA obptr = CTX_data_pointer_get(C, "active_object");
+
+ if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) {
+ PointerRNA dataptr = RNA_pointer_get(&obptr, "data");
+ uiItemPointerR(row, ptr, "uv_map", &dataptr, "uv_textures", "", ICON_NONE);
+ }
+ else
+ uiItemR(row, ptr, "uv_map", 0, "", 0);
+ }
+ else
+ uiItemR(row, ptr, "axis", UI_ITEM_R_EXPAND, NULL, 0);
+}
+
static void node_shader_buts_glossy(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiItemR(layout, ptr, "distribution", 0, "", ICON_NONE);
@@ -1408,7 +1486,7 @@ static void node_shader_buts_script_details(uiLayout *layout, bContext *C, Point
node_shader_buts_script(layout, C, ptr);
/* not implemented yet
- if(RNA_enum_get(ptr, "mode") == NODE_SCRIPT_EXTERNAL)
+ if (RNA_enum_get(ptr, "mode") == NODE_SCRIPT_EXTERNAL)
uiItemR(layout, ptr, "use_auto_update", 0, NULL, ICON_NONE);*/
}
@@ -1491,8 +1569,15 @@ static void node_shader_set_butfunc(bNodeType *ntype)
case SH_NODE_TEX_COORD:
ntype->uifunc = node_shader_buts_tex_coord;
break;
+ case SH_NODE_NORMAL_MAP:
+ ntype->uifunc = node_shader_buts_normal_map;
+ break;
+ case SH_NODE_TANGENT:
+ ntype->uifunc = node_shader_buts_tangent;
+ break;
case SH_NODE_BSDF_GLOSSY:
case SH_NODE_BSDF_GLASS:
+ case SH_NODE_BSDF_REFRACTION:
ntype->uifunc = node_shader_buts_glossy;
break;
case SH_NODE_SCRIPT:
@@ -3089,6 +3174,9 @@ void ED_node_init_butfuncs(void)
case SOCK_BOOLEAN:
stype->buttonfunc = node_socket_button_default;
break;
+ case SOCK_STRING:
+ stype->buttonfunc = node_socket_button_string;
+ break;
case SOCK_VECTOR:
stype->buttonfunc = node_socket_button_components;
break;
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index 1d3b21fe2d6..72461cfb2a8 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -843,7 +843,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
rctf *rct = &node->totr;
float dx, centy = BLI_rctf_cent_y(rct);
float hiddenrad = BLI_rctf_size_y(rct) / 2.0f;
- float socket_size = NODE_SOCKSIZE * U.dpi / 72;
+ float socket_size = NODE_SOCKSIZE * UI_DPI_ICON_FAC;
int color_id = node_get_colorid(node);
char showname[128]; /* 128 is used below */
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index 6bf0e9f73e3..5dd005e9ddf 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -2232,7 +2232,7 @@ static int node_shader_script_update_exec(bContext *C, wmOperator *op)
ntreetype->foreach_nodetree(bmain, &data, node_shader_script_update_text);
if (!data.found)
- BKE_report(op->reports, RPT_INFO, "Text not used by any node, no update done.");
+ BKE_report(op->reports, RPT_INFO, "Text not used by any node, no update done");
}
}
diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c
index 19a678a9c6e..5f8b5db7766 100644
--- a/source/blender/editors/space_node/node_group.c
+++ b/source/blender/editors/space_node/node_group.c
@@ -875,7 +875,7 @@ static int node_group_make_insert_selected(bNodeTree *ntree, bNode *gnode)
bNodeTree *ngroup = (bNodeTree *)gnode->id;
bNodeLink *link, *linkn;
bNode *node, *nextn;
- bNodeSocket *gsock;
+ bNodeSocket *gsock, *sock;
ListBase anim_basepaths = {NULL, NULL};
float min[2], max[2];
@@ -982,8 +982,42 @@ static int node_group_make_insert_selected(bNodeTree *ntree, bNode *gnode)
}
}
+ /* auto-add interface for "solo" nodes */
+ node = ((bNodeTree *)gnode->id)->nodes.first;
+ if (node && !node->next) {
+ for (sock = node->inputs.first; sock; sock = sock->next) {
+ int skip = FALSE;
+
+ for (link = ((bNodeTree *)gnode->id)->links.first; link; link = link->next)
+ if (link->tosock == sock)
+ skip = TRUE;
+
+ if (skip == TRUE)
+ continue;
+
+ gsock = node_group_expose_socket(ngroup, sock, SOCK_IN);
+ node_group_add_extern_socket(ntree, &gnode->inputs, SOCK_IN, gsock);
+ nodeAddLink(ngroup, NULL, gsock, node, sock);
+ }
+
+ for (sock = node->outputs.first; sock; sock = sock->next) {
+ int skip = FALSE;
+
+ for (link = ((bNodeTree *)gnode->id)->links.first; link; link = link->next)
+ if (link->fromsock == sock)
+ skip = TRUE;
+
+ if (skip == TRUE)
+ continue;
+
+ gsock = node_group_expose_socket(ngroup, sock, SOCK_OUT);
+ node_group_add_extern_socket(ntree, &gnode->outputs, SOCK_OUT, gsock);
+ nodeAddLink(ngroup, NULL, gsock, node, sock);
+ }
+ }
+
/* update of the group tree */
- ngroup->update |= NTREE_UPDATE;
+ ngroup->update |= NTREE_UPDATE | NTREE_UPDATE_LINKS;
/* update of the tree containing the group instance node */
ntree->update |= NTREE_UPDATE_NODES | NTREE_UPDATE_LINKS;
diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c
index fd46f69da83..8155f9d645e 100644
--- a/source/blender/editors/space_sequencer/sequencer_add.c
+++ b/source/blender/editors/space_sequencer/sequencer_add.c
@@ -719,7 +719,9 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op)
seq->endstill = seq_load.end_frame - seq_load.start_frame;
}
}
-
+
+ BKE_sequence_init_colorspace(seq);
+
BKE_sequence_calc_disp(scene, seq);
BKE_sequencer_sort(scene);
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 29babd355ad..a8103fe2630 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -285,8 +285,8 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1,
drawmeta_stipple(1);
for (seq = seqm->seqbase.first; seq; seq = seq->next) {
- chan_min = MIN2(chan_min, seq->machine);
- chan_max = MAX2(chan_max, seq->machine);
+ chan_min = min_ii(chan_min, seq->machine);
+ chan_max = max_ii(chan_max, seq->machine);
}
chan_range = (chan_max - chan_min) + 1;
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 0a282a17f74..4d4fad47698 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -2857,14 +2857,8 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw
engine = RE_engine_create(type);
- engine->tile_x = ceil(ar->winx / (float)scene->r.xparts);
- engine->tile_y = ceil(ar->winy / (float)scene->r.yparts);
-
- /* clamp small tile sizes to prevent inefficient threading utilization
- * the same happens for final renders as well
- */
- engine->tile_x = max_ii(engine->tile_x, 64);
- engine->tile_y = max_ii(engine->tile_x, 64);
+ engine->tile_x = scene->r.tilex;
+ engine->tile_y = scene->r.tiley;
type->view_update(engine, C);
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 36d7341f2f2..c7ba3378073 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -992,8 +992,10 @@ void ndof_to_quat(struct wmNDOFMotionData *ndof, float q[4])
* -- zooming
* -- panning in rotationally-locked views
*/
-static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
+static int ndof_orbit_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
+ ViewOpsData *vod = op->customdata;
+
if (event->type != NDOF_MOTION)
return OPERATOR_CANCELLED;
else {
@@ -1074,6 +1076,7 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event
rot[1] = rot[2] = 0.0;
rot[3] = sin(angle);
mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot);
+
}
else {
float rot[4];
@@ -1088,6 +1091,7 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event
if (U.ndof_flag & NDOF_ROTATE_INVERT_AXIS)
axis[1] = -axis[1];
+
/* transform rotation axis from view to world coordinates */
mul_qt_v3(view_inv, axis);
@@ -1100,7 +1104,22 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event
/* apply rotation */
mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot);
-
+
+ }
+
+ /* rotate around custom center */
+ if (vod && vod->use_dyn_ofs) {
+ float q1[4];
+
+ /* compute the post multiplication quat, to rotate the offset correctly */
+ conjugate_qt_qt(q1, vod->oldquat);
+ mul_qt_qtqt(q1, q1, rv3d->viewquat);
+
+ conjugate_qt(q1); /* conj == inv for unit quat */
+ copy_v3_v3(rv3d->ofs, vod->ofs);
+ sub_v3_v3(rv3d->ofs, vod->dyn_ofs);
+ mul_qt_v3(q1, rv3d->ofs);
+ add_v3_v3(rv3d->ofs, vod->dyn_ofs);
}
}
}
@@ -1267,6 +1286,9 @@ static int ndof_all_invoke(bContext *C, wmOperator *op, wmEvent *event)
float axis[3];
#endif
+ /* inverse view */
+ invert_qt_qt(view_inv, rv3d->viewquat);
+
if (U.ndof_flag & NDOF_PANX_INVERT_AXIS)
pan_vec[0] = -lateral_sensitivity * ndof->tvec[0];
else
@@ -1285,12 +1307,11 @@ static int ndof_all_invoke(bContext *C, wmOperator *op, wmEvent *event)
mul_v3_fl(pan_vec, speed * dt);
/* transform motion from view to world coordinates */
- invert_qt_qt(view_inv, rv3d->viewquat);
mul_qt_v3(view_inv, pan_vec);
/* move center of view opposite of hand motion (this is camera mode, not object mode) */
sub_v3_v3(rv3d->ofs, pan_vec);
-
+
if (U.ndof_flag & NDOF_TURNTABLE) {
/* turntable view code by John Aughey, adapted for 3D mouse by [mce] */
float angle, rot[4];
@@ -1350,8 +1371,24 @@ static int ndof_all_invoke(bContext *C, wmOperator *op, wmEvent *event)
/* apply rotation */
mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot);
-
+
+ }
+
+ /* rotate around custom center */
+ if (vod && vod->use_dyn_ofs) {
+ float q1[4];
+
+ /* compute the post multiplication quat, to rotate the offset correctly */
+ conjugate_qt_qt(q1, vod->oldquat);
+ mul_qt_qtqt(q1, q1, rv3d->viewquat);
+
+ conjugate_qt(q1); /* conj == inv for unit quat */
+ copy_v3_v3(rv3d->ofs, vod->ofs);
+ sub_v3_v3(rv3d->ofs, vod->dyn_ofs);
+ mul_qt_v3(q1, rv3d->ofs);
+ add_v3_v3(rv3d->ofs, vod->dyn_ofs);
}
+
}
ED_view3d_camera_lock_sync(v3d, rv3d);
diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c
index 9517bc87721..7f1bbb22f24 100644
--- a/source/blender/editors/space_view3d/view3d_snap.c
+++ b/source/blender/editors/space_view3d/view3d_snap.c
@@ -82,10 +82,9 @@ extern float originmat[3][3]; /* XXX object.c */
typedef struct TransVert {
float *loc;
- float oldloc[3], maploc[3], fac;
+ float oldloc[3], maploc[3];
float *val, oldval;
int flag;
- float *nor;
} TransVert;
/* SELECT == (1 << 0) */
@@ -193,6 +192,20 @@ static void special_transvert_update(Object *obedit)
}
}
+/* currently only used for bmesh index values */
+enum {
+ TM_INDEX_ON = 1, /* tag to make trans verts */
+ TM_INDEX_OFF = 0, /* don't make verts */
+ TM_INDEX_SKIP = -1 /* dont make verts (when the index values point to trans-verts) */
+};
+
+/* copied from editobject.c, needs to be replaced with new transform code still */
+/* mode flags: */
+enum {
+ TM_ALL_JOINTS = 1, /* all joints (for bones only) */
+ TM_SKIP_HANDLES = 2 /* skip handles when control point is selected (for curves only) */
+};
+
static void set_mapped_co(void *vuserdata, int index, const float co[3],
const float UNUSED(no[3]), const short UNUSED(no_s[3]))
{
@@ -201,16 +214,25 @@ static void set_mapped_co(void *vuserdata, int index, const float co[3],
TransVert *tv = userdata[1];
BMVert *eve = EDBM_vert_at_index(em, index);
- if (BM_elem_index_get(eve) != -1 && !(tv[BM_elem_index_get(eve)].flag & TX_VERT_USE_MAPLOC)) {
- copy_v3_v3(tv[BM_elem_index_get(eve)].maploc, co);
- tv[BM_elem_index_get(eve)].flag |= TX_VERT_USE_MAPLOC;
+ if (BM_elem_index_get(eve) != TM_INDEX_SKIP) {
+ tv = &tv[BM_elem_index_get(eve)];
+
+ /* be clever, get the closest vertex to the original,
+ * behaves most logically when the mirror modifier is used for eg [#33051]*/
+ if ((tv->flag & TX_VERT_USE_MAPLOC) == 0) {
+ /* first time */
+ copy_v3_v3(tv->maploc, co);
+ tv->flag |= TX_VERT_USE_MAPLOC;
+ }
+ else {
+ /* find best location to use */
+ if (len_squared_v3v3(eve->co, co) < len_squared_v3v3(eve->co, tv->maploc)) {
+ copy_v3_v3(tv->maploc, co);
+ }
+ }
}
}
-/* copied from editobject.c, needs to be replaced with new transform code still */
-/* mode flags: */
-#define TM_ALL_JOINTS 1 /* all joints (for bones only) */
-#define TM_SKIP_HANDLES 2 /* skip handles when control point is selected (for curves only) */
static void make_trans_verts(Object *obedit, float min[3], float max[3], int mode)
{
Nurb *nu;
@@ -243,35 +265,37 @@ static void make_trans_verts(Object *obedit, float min[3], float max[3], int mod
if (em->selectmode & SCE_SELECT_VERTEX) {
BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN) && BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
- BM_elem_index_set(eve, 1); /* set_dirty! */
+ BM_elem_index_set(eve, TM_INDEX_ON); /* set_dirty! */
tottrans++;
}
- else BM_elem_index_set(eve, 0); /* set_dirty! */
+ else {
+ BM_elem_index_set(eve, TM_INDEX_OFF); /* set_dirty! */
+ }
}
}
else if (em->selectmode & SCE_SELECT_EDGE) {
BMEdge *eed;
BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
- BM_elem_index_set(eve, 0); /* set_dirty! */
+ BM_elem_index_set(eve, TM_INDEX_OFF); /* set_dirty! */
}
BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) {
if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
- BM_elem_index_set(eed->v1, 1); /* set_dirty! */
- BM_elem_index_set(eed->v2, 1); /* set_dirty! */
+ BM_elem_index_set(eed->v1, TM_INDEX_ON); /* set_dirty! */
+ BM_elem_index_set(eed->v2, TM_INDEX_ON); /* set_dirty! */
}
}
BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
- if (BM_elem_index_get(eve)) tottrans++;
+ if (BM_elem_index_get(eve) == TM_INDEX_ON) tottrans++;
}
}
else {
BMFace *efa;
BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
- BM_elem_index_set(eve, 0); /* set_dirty! */
+ BM_elem_index_set(eve, TM_INDEX_OFF); /* set_dirty! */
}
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
@@ -280,13 +304,13 @@ static void make_trans_verts(Object *obedit, float min[3], float max[3], int mod
BMLoop *l;
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
- BM_elem_index_set(l->v, 1); /* set_dirty! */
+ BM_elem_index_set(l->v, TM_INDEX_ON); /* set_dirty! */
}
}
}
BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
- if (BM_elem_index_get(eve)) tottrans++;
+ if (BM_elem_index_get(eve) == TM_INDEX_ON) tottrans++;
}
}
/* for any of the 3 loops above which all dirty the indices */
@@ -299,17 +323,15 @@ static void make_trans_verts(Object *obedit, float min[3], float max[3], int mod
a = 0;
BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_index_get(eve)) {
- BM_elem_index_set(eve, a); /* set_dirty! */
+ BM_elem_index_set(eve, a); /* set_dirty! */
copy_v3_v3(tv->oldloc, eve->co);
tv->loc = eve->co;
- if (eve->no[0] != 0.0f || eve->no[1] != 0.0f || eve->no[2] != 0.0f)
- tv->nor = eve->no; /* note this is a hackish signal (ton) */
- tv->flag = BM_elem_index_get(eve) & SELECT;
+ tv->flag = (BM_elem_index_get(eve) == TM_INDEX_ON) ? SELECT : 0;
tv++;
a++;
}
else {
- BM_elem_index_set(eve, -1); /* set_dirty! */
+ BM_elem_index_set(eve, TM_INDEX_SKIP); /* set_dirty! */
}
}
/* set dirty already, above */
@@ -345,8 +367,7 @@ static void make_trans_verts(Object *obedit, float min[3], float max[3], int mod
if (rootok) {
copy_v3_v3(tv->oldloc, ebo->head);
tv->loc = ebo->head;
- tv->nor = NULL;
- tv->flag = 1;
+ tv->flag = SELECT;
tv++;
tottrans++;
}
@@ -354,8 +375,7 @@ static void make_trans_verts(Object *obedit, float min[3], float max[3], int mod
if ((mode & TM_ALL_JOINTS) && (tipsel)) {
copy_v3_v3(tv->oldloc, ebo->tail);
tv->loc = ebo->tail;
- tv->nor = NULL;
- tv->flag = 1;
+ tv->flag = SELECT;
tv++;
tottrans++;
}
@@ -363,8 +383,7 @@ static void make_trans_verts(Object *obedit, float min[3], float max[3], int mod
else if (tipsel) {
copy_v3_v3(tv->oldloc, ebo->tail);
tv->loc = ebo->tail;
- tv->nor = NULL;
- tv->flag = 1;
+ tv->flag = SELECT;
tv++;
tottrans++;
}
@@ -456,7 +475,7 @@ static void make_trans_verts(Object *obedit, float min[3], float max[3], int mod
copy_v3_v3(tv->oldloc, tv->loc);
tv->val = &(ml->rad);
tv->oldval = ml->rad;
- tv->flag = 1;
+ tv->flag = SELECT;
tv++;
tottrans++;
}
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index c90913a6ace..3b9fe22d6a1 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -1218,6 +1218,12 @@ int transformEvent(TransInfo *t, wmEvent *event)
else view_editmove(event->type);
t->redraw = 1;
break;
+ case LEFTALTKEY:
+ case RIGHTALTKEY:
+ if (t->spacetype == SPACE_SEQ)
+ t->flag |= T_ALT_TRANSFORM;
+
+ break;
default:
handled = 0;
break;
@@ -1251,6 +1257,12 @@ int transformEvent(TransInfo *t, wmEvent *event)
//// if (t->options & CTX_TWEAK)
// t->state = TRANS_CONFIRM;
// break;
+ case LEFTALTKEY:
+ case RIGHTALTKEY:
+ if (t->spacetype == SPACE_SEQ)
+ t->flag &= ~T_ALT_TRANSFORM;
+
+ break;
default:
handled = 0;
break;
@@ -4835,14 +4847,9 @@ static void calcNonProportionalEdgeSlide(TransInfo *t, SlideData *sld, const flo
float dist = 0;
float min_dist = FLT_MAX;
- float up_p[3];
- float dw_p[3];
-
for (i = 0; i < sld->totsv; i++, sv++) {
/* Set length */
- add_v3_v3v3(up_p, sv->origvert.co, sv->upvec);
- add_v3_v3v3(dw_p, sv->origvert.co, sv->downvec);
- sv->edge_len = len_v3v3(dw_p, up_p);
+ sv->edge_len = len_v3v3(sv->upvec, sv->downvec);
mul_v3_m4v3(v_proj, t->obedit->obmat, sv->v->co);
if (ED_view3d_project_float_global(t->ar, v_proj, v_proj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
@@ -5583,7 +5590,6 @@ static int doEdgeSlide(TransInfo *t, float perc)
{
SlideData *sld = t->customData;
TransDataSlideVert *svlist = sld->sv, *sv;
- float vec[3];
int i;
sld->perc = perc;
@@ -5591,6 +5597,7 @@ static int doEdgeSlide(TransInfo *t, float perc)
if (sld->is_proportional == TRUE) {
for (i = 0; i < sld->totsv; i++, sv++) {
+ float vec[3];
if (perc > 0.0f) {
copy_v3_v3(vec, sv->upvec);
mul_v3_fl(vec, perc);
@@ -5608,20 +5615,29 @@ static int doEdgeSlide(TransInfo *t, float perc)
* Implementation note, non proportional mode ignores the starting positions and uses only the
* up/down verts, this could be changed/improved so the distance is still met but the verts are moved along
* their original path (which may not be straight), however how it works now is OK and matches 2.4x - Campbell
+ *
+ * \note len_v3v3(curr_sv->upvec, curr_sv->downvec)
+ * is the same as the distance between the original vert locations, same goes for the lines below.
*/
TransDataSlideVert *curr_sv = &sld->sv[sld->curr_sv_index];
- const float curr_length_perc = len_v3v3(curr_sv->up->co, curr_sv->down->co) *
- (((sld->flipped_vtx ? perc : -perc) + 1.0f) / 2.0f);
+ const float curr_length_perc = curr_sv->edge_len * (((sld->flipped_vtx ? perc : -perc) + 1.0f) / 2.0f);
+
+ float down_co[3];
+ float up_co[3];
for (i = 0; i < sld->totsv; i++, sv++) {
- const float sv_length = len_v3v3(sv->up->co, sv->down->co);
- const float fac = min_ff(sv_length, curr_length_perc) / sv_length;
+ if (sv->edge_len > FLT_EPSILON) {
+ const float fac = min_ff(sv->edge_len, curr_length_perc) / sv->edge_len;
- if (sld->flipped_vtx) {
- interp_v3_v3v3(sv->v->co, sv->down->co, sv->up->co, fac);
- }
- else {
- interp_v3_v3v3(sv->v->co, sv->up->co, sv->down->co, fac);
+ add_v3_v3v3(up_co, sv->origvert.co, sv->upvec);
+ add_v3_v3v3(down_co, sv->origvert.co, sv->downvec);
+
+ if (sld->flipped_vtx) {
+ interp_v3_v3v3(sv->v->co, down_co, up_co, fac);
+ }
+ else {
+ interp_v3_v3v3(sv->v->co, up_co, down_co, fac);
+ }
}
}
}
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index 1f9775821d1..bc959a772d6 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -197,6 +197,7 @@ typedef struct TransDataSlideVert {
float edge_len;
+ /* add origvert.co to get the original locations */
float upvec[3], downvec[3];
int loop_nr;
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 2a01b03ec14..f6b888d4881 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -4275,8 +4275,7 @@ static void freeSeqData(TransInfo *t)
}
}
-#if 1 /* (mango hack! - for Ian) this is truely bad - should _never_ be in a release :| */
- if (CTX_wm_window(t->context)->eventstate->alt) {
+ if (t->flag & T_ALT_TRANSFORM) {
int minframe = MAXFRAME;
td = t->data;
seq_prev = NULL;
@@ -4313,9 +4312,6 @@ static void freeSeqData(TransInfo *t)
else {
BKE_sequence_base_shuffle_time(seqbasep, t->scene);
}
-#else
- BKE_sequence_base_shuffle_time(seqbasep, t->scene);
-#endif
if (has_effect) {
/* update effects strips based on strips just moved in time */
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index 393c119b347..f615902eedf 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -60,6 +60,7 @@
#include "BKE_main.h"
#include "BKE_mesh.h"
#include "BKE_report.h"
+#include "BKE_scene.h"
#include "BKE_tessmesh.h"
#include "BLI_math.h"
@@ -177,7 +178,33 @@ static int uvedit_have_selection(Scene *scene, BMEditMesh *em, short implicit)
return 0;
}
-static ParamHandle *construct_param_handle(Scene *scene, BMEditMesh *em,
+static void ED_uvedit_get_aspect(Scene *scene, Object *ob, BMEditMesh *em, float *aspx, float *aspy)
+{
+ int sloppy = TRUE;
+ int selected = FALSE;
+ BMFace *efa;
+ Image *ima;
+
+ efa = BM_active_face_get(em->bm, sloppy, selected);
+
+ if (efa) {
+ if (BKE_scene_use_new_shading_nodes(scene)) {
+ ED_object_get_active_image(ob, efa->mat_nr + 1, &ima, NULL, NULL);
+ }
+ else {
+ MTexPoly *tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
+ ima = tf->tpage;
+ }
+
+ ED_image_get_uv_aspect(ima, NULL, aspx, aspy);
+ }
+ else {
+ *aspx = 1.0f;
+ *aspy = 1.0f;
+ }
+}
+
+static ParamHandle *construct_param_handle(Scene *scene, Object *ob, BMEditMesh *em,
short implicit, short fill, short sel,
short correct_aspect)
{
@@ -187,27 +214,16 @@ static ParamHandle *construct_param_handle(Scene *scene, BMEditMesh *em,
BMLoop *l;
BMEdge *eed;
BMIter iter, liter;
- MTexPoly *tf;
handle = param_construct_begin();
if (correct_aspect) {
- int sloppy = TRUE;
- int selected = FALSE;
+ float aspx, aspy;
- efa = BM_active_face_get(em->bm, sloppy, selected);
+ ED_uvedit_get_aspect(scene, ob, em, &aspx, &aspy);
- if (efa) {
- float aspx, aspy;
- tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
-
- ED_image_get_uv_aspect(tf->tpage, NULL, &aspx, &aspy);
-
- if (aspx != aspy)
- param_aspect_ratio(handle, aspx, aspy);
- else
- param_aspect_ratio(handle, 1.0, 1.0);
- }
+ if (aspx != aspy)
+ param_aspect_ratio(handle, aspx, aspy);
}
/* we need the vert indices */
@@ -355,13 +371,12 @@ static void texface_from_original_index(BMFace *efa, int index, float **uv, Para
/* unwrap handle initialization for subsurf aware-unwrapper. The many modifications required to make the original function(see above)
* work justified the existence of a new function. */
-static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *em, short fill, short sel, short correct_aspect)
+static ParamHandle *construct_param_handle_subsurfed(Scene *scene, Object *ob, BMEditMesh *em, short fill, short sel, short correct_aspect)
{
ParamHandle *handle;
/* index pointers */
MFace *face;
MEdge *edge;
- BMFace *editFace;
int i;
/* modifier initialization data, will control what type of subdivision will happen*/
@@ -385,23 +400,12 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e
handle = param_construct_begin();
if (correct_aspect) {
- int sloppy = TRUE;
- int selected = FALSE;
-
- editFace = BM_active_face_get(em->bm, sloppy, selected);
+ float aspx, aspy;
- if (editFace) {
- MTexPoly *tf;
- float aspx, aspy;
- tf = CustomData_bmesh_get(&em->bm->pdata, editFace->head.data, CD_MTEXPOLY);
+ ED_uvedit_get_aspect(scene, ob, em, &aspx, &aspy);
- ED_image_get_uv_aspect(tf->tpage, NULL, &aspx, &aspy);
-
- if (aspx != aspy)
- param_aspect_ratio(handle, aspx, aspy);
- else
- param_aspect_ratio(handle, 1.0, 1.0);
- }
+ if (aspx != aspy)
+ param_aspect_ratio(handle, aspx, aspy);
}
/* number of subdivisions to perform */
@@ -541,7 +545,7 @@ static int minimize_stretch_init(bContext *C, wmOperator *op)
ms->blend = RNA_float_get(op->ptr, "blend");
ms->iterations = RNA_int_get(op->ptr, "iterations");
ms->i = 0;
- ms->handle = construct_param_handle(scene, em, implicit, fill_holes, 1, 1);
+ ms->handle = construct_param_handle(scene, obedit, em, implicit, fill_holes, 1, 1);
ms->lasttime = PIL_check_seconds_timer();
param_stretch_begin(ms->handle);
@@ -735,7 +739,7 @@ static int pack_islands_exec(bContext *C, wmOperator *op)
else
RNA_float_set(op->ptr, "margin", scene->toolsettings->uvcalc_margin);
- handle = construct_param_handle(scene, em, implicit, 0, 1, 1);
+ handle = construct_param_handle(scene, obedit, em, implicit, 0, 1, 1);
param_pack(handle, scene->toolsettings->uvcalc_margin);
param_flush(handle);
param_delete(handle);
@@ -777,7 +781,7 @@ static int average_islands_scale_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
}
- handle = construct_param_handle(scene, em, implicit, 0, 1, 1);
+ handle = construct_param_handle(scene, obedit, em, implicit, 0, 1, 1);
param_average(handle);
param_flush(handle);
param_delete(handle);
@@ -818,9 +822,9 @@ void ED_uvedit_live_unwrap_begin(Scene *scene, Object *obedit)
}
if (use_subsurf)
- liveHandle = construct_param_handle_subsurfed(scene, em, fillholes, 0, 1);
+ liveHandle = construct_param_handle_subsurfed(scene, obedit, em, fillholes, 0, 1);
else
- liveHandle = construct_param_handle(scene, em, 0, fillholes, 0, 1);
+ liveHandle = construct_param_handle(scene, obedit, em, 0, fillholes, 0, 1);
param_lscm_begin(liveHandle, PARAM_TRUE, abf);
}
@@ -1008,22 +1012,15 @@ static void uv_transform_properties(wmOperatorType *ot, int radius)
"Radius of the sphere or cylinder", 0.0001f, 100.0f);
}
-static void correct_uv_aspect(BMEditMesh *em)
+static void correct_uv_aspect(Scene *scene, Object *ob, BMEditMesh *em)
{
- int sloppy = TRUE;
- int selected = FALSE;
- BMFace *efa = BM_active_face_get(em->bm, sloppy, selected);
BMLoop *l;
BMIter iter, liter;
MLoopUV *luv;
- float scale, aspx = 1.0f, aspy = 1.0f;
+ BMFace *efa;
+ float scale, aspx, aspy;
- if (efa) {
- MTexPoly *tf;
-
- tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- ED_image_get_uv_aspect(tf->tpage, NULL, &aspx, &aspy);
- }
+ ED_uvedit_get_aspect(scene, ob, em, &aspx, &aspy);
if (aspx == aspy)
return;
@@ -1068,7 +1065,7 @@ static void uv_map_clip_correct_properties(wmOperatorType *ot)
"Scale UV coordinates to bounds after unwrapping");
}
-static void uv_map_clip_correct(BMEditMesh *em, wmOperator *op)
+static void uv_map_clip_correct(Scene *scene, Object *ob, BMEditMesh *em, wmOperator *op)
{
BMFace *efa;
BMLoop *l;
@@ -1081,7 +1078,7 @@ static void uv_map_clip_correct(BMEditMesh *em, wmOperator *op)
/* correct for image aspect ratio */
if (correct_aspect)
- correct_uv_aspect(em);
+ correct_uv_aspect(scene, ob, em);
if (scale_to_bounds) {
INIT_MINMAX2(min, max);
@@ -1145,9 +1142,9 @@ void ED_unwrap_lscm(Scene *scene, Object *obedit, const short sel)
const short use_subsurf = scene->toolsettings->uvcalc_flag & UVCALC_USESUBSURF;
if (use_subsurf)
- handle = construct_param_handle_subsurfed(scene, em, fill_holes, sel, correct_aspect);
+ handle = construct_param_handle_subsurfed(scene, obedit, em, fill_holes, sel, correct_aspect);
else
- handle = construct_param_handle(scene, em, 0, fill_holes, sel, correct_aspect);
+ handle = construct_param_handle(scene, obedit, em, 0, fill_holes, sel, correct_aspect);
param_lscm_begin(handle, PARAM_FALSE, scene->toolsettings->unwrapper == 0);
param_lscm_solve(handle);
@@ -1322,7 +1319,7 @@ static int uv_from_view_exec(bContext *C, wmOperator *op)
}
}
- uv_map_clip_correct(em, op);
+ uv_map_clip_correct(scene, obedit, em, op);
DAG_id_tag_update(obedit->data, 0);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
@@ -1476,7 +1473,7 @@ static int sphere_project_exec(bContext *C, wmOperator *op)
uv_map_mirror(em, efa, tf);
}
- uv_map_clip_correct(em, op);
+ uv_map_clip_correct(scene, obedit, em, op);
DAG_id_tag_update(obedit->data, 0);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
@@ -1551,7 +1548,7 @@ static int cylinder_project_exec(bContext *C, wmOperator *op)
uv_map_mirror(em, efa, tf);
}
- uv_map_clip_correct(em, op);
+ uv_map_clip_correct(scene, obedit, em, op);
DAG_id_tag_update(obedit->data, 0);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
@@ -1631,7 +1628,7 @@ static int cube_project_exec(bContext *C, wmOperator *op)
}
}
- uv_map_clip_correct(em, op);
+ uv_map_clip_correct(scene, obedit, em, op);
DAG_id_tag_update(obedit->data, 0);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h
index 97e8b756d08..c46230de8bf 100644
--- a/source/blender/gpu/GPU_material.h
+++ b/source/blender/gpu/GPU_material.h
@@ -110,7 +110,6 @@ GPUNodeLink *GPU_dynamic_uniform(float *num, int dynamictype, void *data);
GPUNodeLink *GPU_image(struct Image *ima, struct ImageUser *iuser, int isdata);
GPUNodeLink *GPU_texture(int size, float *pixels);
GPUNodeLink *GPU_dynamic_texture(struct GPUTexture *tex, int dynamictype, void *data);
-GPUNodeLink *GPU_socket(GPUNodeStack *sock);
GPUNodeLink *GPU_builtin(GPUBuiltin builtin);
int GPU_link(GPUMaterial *mat, const char *name, ...);
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index b4490e656f3..4432627ee7e 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -1148,15 +1148,6 @@ GPUNodeLink *GPU_dynamic_texture(GPUTexture *tex, int dynamictype, void *data)
return link;
}
-GPUNodeLink *GPU_socket(GPUNodeStack *sock)
-{
- GPUNodeLink *link = GPU_node_link_create(0);
-
- link->socket= sock;
-
- return link;
-}
-
GPUNodeLink *GPU_builtin(GPUBuiltin builtin)
{
GPUNodeLink *link = GPU_node_link_create(0);
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl
index 5713c5e88a2..9a238e979fa 100644
--- a/source/blender/gpu/shaders/gpu_shader_material.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_material.glsl
@@ -4,6 +4,21 @@ float exp_blender(float f)
return pow(2.71828182846, f);
}
+float compatible_pow(float x, float y)
+{
+ /* glsl pow doesn't accept negative x */
+ if(x < 0.0) {
+ if(mod(-y, 2.0) == 0.0)
+ return pow(-x, y);
+ else
+ return -pow(-x, y);
+ }
+ else if(x == 0.0)
+ return 0.0;
+
+ return pow(x, y);
+}
+
void rgb_to_hsv(vec4 rgb, out vec4 outcol)
{
float cmax, cmin, h, s, v, cdelta;
@@ -212,10 +227,17 @@ void math_atan(float val, out float outval)
void math_pow(float val1, float val2, out float outval)
{
- if (val1 >= 0.0)
- outval = pow(val1, val2);
- else
- outval = 0.0;
+ if (val1 >= 0.0) {
+ outval = compatible_pow(val1, val2);
+ }
+ else {
+ float val2_mod_1 = mod(abs(val2), 1.0);
+
+ if (val2_mod_1 > 0.999 || val2_mod_1 < 0.001)
+ outval = compatible_pow(val1, floor(val2 + 0.5));
+ else
+ outval = 0.0;
+ }
}
void math_log(float val1, float val2, out float outval)
@@ -2013,7 +2035,7 @@ void node_bsdf_glossy(vec4 color, float roughness, vec3 N, out vec4 result)
result = vec4(L*color.rgb, 1.0);
}
-void node_bsdf_anisotropic(vec4 color, float roughnessU, float roughnessV, vec3 N, vec3 T, out vec4 result)
+void node_bsdf_anisotropic(vec4 color, float roughness, float anisotropy, float rotation, vec3 N, vec3 T, out vec4 result)
{
node_bsdf_diffuse(color, 0.0, N, result);
}
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index e297ebe3980..d0ac71a7131 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -103,7 +103,7 @@ struct ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags,
*
* \attention Defined in readimage.c
*/
-struct ImBuf *IMB_testiffname(const char *filepath, int flags, char colorspace[IM_MAX_SPACE]);
+struct ImBuf *IMB_testiffname(const char *filepath, int flags);
/**
*
diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c
index 6581987aed7..aadf547260d 100644
--- a/source/blender/imbuf/intern/colormanagement.c
+++ b/source/blender/imbuf/intern/colormanagement.c
@@ -2385,7 +2385,7 @@ void IMB_partial_display_buffer_update(ImBuf *ibuf, const float *linear_buffer,
const ColorManagedDisplaySettings *display_settings,
int xmin, int ymin, int xmax, int ymax, int update_orig_byte_buffer)
{
- if ((ibuf->rect && ibuf->rect_float) || update_orig_byte_buffer) {
+ if ((ibuf->rect && ibuf->rect_float) || update_orig_byte_buffer) {
/* update byte buffer created by legacy color management */
unsigned char *rect = (unsigned char *) ibuf->rect;
diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c
index 6310d8e105f..dcfebb95b87 100644
--- a/source/blender/imbuf/intern/png.c
+++ b/source/blender/imbuf/intern/png.c
@@ -558,7 +558,8 @@ ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags, char colorspace[I
MEM_freeN(pixels);
if (pixels16)
MEM_freeN(pixels16);
- MEM_freeN(row_pointers);
+ if (row_pointers)
+ MEM_freeN(row_pointers);
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
return(ibuf);
diff --git a/source/blender/imbuf/intern/readimage.c b/source/blender/imbuf/intern/readimage.c
index a1fa05d1098..be20c80bdec 100644
--- a/source/blender/imbuf/intern/readimage.c
+++ b/source/blender/imbuf/intern/readimage.c
@@ -100,7 +100,8 @@ ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags, char co
}
}
- fprintf(stderr, "%s: unknown fileformat (%s)\n", __func__, descr);
+ if ((flags & IB_test) == 0)
+ fprintf(stderr, "%s: unknown fileformat (%s)\n", __func__, descr);
return NULL;
}
@@ -170,11 +171,12 @@ ImBuf *IMB_loadiffname(const char *filepath, int flags, char colorspace[IM_MAX_S
return ibuf;
}
-ImBuf *IMB_testiffname(const char *filepath, int flags, char colorspace[IM_MAX_SPACE])
+ImBuf *IMB_testiffname(const char *filepath, int flags)
{
ImBuf *ibuf;
int file;
char filepath_tx[IB_FILENAME_SIZE];
+ char colorspace[IM_MAX_SPACE] = "\0";
imb_cache_filename(filepath_tx, filepath, flags);
diff --git a/source/blender/imbuf/intern/thumbs.c b/source/blender/imbuf/intern/thumbs.c
index a3ce332b609..94bb85b49ea 100644
--- a/source/blender/imbuf/intern/thumbs.c
+++ b/source/blender/imbuf/intern/thumbs.c
@@ -436,7 +436,7 @@ ImBuf *IMB_thumb_manage(const char *path, ThumbSize size, ThumbSource source)
struct stat st;
ImBuf *img = NULL;
- if (stat(path, &st)) {
+ if (BLI_stat(path, &st)) {
return NULL;
}
if (!uri_from_filename(path, uri)) {
diff --git a/source/blender/makesdna/DNA_movieclip_types.h b/source/blender/makesdna/DNA_movieclip_types.h
index cda51779528..499f1c50155 100644
--- a/source/blender/makesdna/DNA_movieclip_types.h
+++ b/source/blender/makesdna/DNA_movieclip_types.h
@@ -118,38 +118,50 @@ typedef struct MovieClipScopes {
} MovieClipScopes;
/* MovieClipProxy->build_size_flag */
-#define MCLIP_PROXY_SIZE_25 (1 << 0)
-#define MCLIP_PROXY_SIZE_50 (1 << 1)
-#define MCLIP_PROXY_SIZE_75 (1 << 2)
-#define MCLIP_PROXY_SIZE_100 (1 << 3)
-#define MCLIP_PROXY_UNDISTORTED_SIZE_25 (1 << 4)
-#define MCLIP_PROXY_UNDISTORTED_SIZE_50 (1 << 5)
-#define MCLIP_PROXY_UNDISTORTED_SIZE_75 (1 << 6)
-#define MCLIP_PROXY_UNDISTORTED_SIZE_100 (1 << 7)
+enum {
+ MCLIP_PROXY_SIZE_25 = (1 << 0),
+ MCLIP_PROXY_SIZE_50 = (1 << 1),
+ MCLIP_PROXY_SIZE_75 = (1 << 2),
+ MCLIP_PROXY_SIZE_100 = (1 << 3),
+ MCLIP_PROXY_UNDISTORTED_SIZE_25 = (1 << 4),
+ MCLIP_PROXY_UNDISTORTED_SIZE_50 = (1 << 5),
+ MCLIP_PROXY_UNDISTORTED_SIZE_75 = (1 << 6),
+ MCLIP_PROXY_UNDISTORTED_SIZE_100 = (1 << 7)
+};
/* MovieClip->source */
-#define MCLIP_SRC_SEQUENCE 1
-#define MCLIP_SRC_MOVIE 2
+enum {
+ MCLIP_SRC_SEQUENCE = 1,
+ MCLIP_SRC_MOVIE = 2
+};
/* MovieClip->selection types */
-#define MCLIP_SEL_NONE 0
-#define MCLIP_SEL_TRACK 1
+enum {
+ MCLIP_SEL_NONE = 0,
+ MCLIP_SEL_TRACK = 1
+};
/* MovieClip->flag */
-#define MCLIP_USE_PROXY (1 << 0)
-#define MCLIP_USE_PROXY_CUSTOM_DIR (1 << 1)
-/*#define MCLIP_CUSTOM_START_FRAME (1<<2)*/ /* UNUSED */
+enum {
+ MCLIP_USE_PROXY = (1 << 0),
+ MCLIP_USE_PROXY_CUSTOM_DIR = (1 << 1),
+ /* MCLIP_CUSTOM_START_FRAME = (1<<2), */ /* UNUSED */
-#define MCLIP_TIMECODE_FLAGS (MCLIP_USE_PROXY | MCLIP_USE_PROXY_CUSTOM_DIR)
+ MCLIP_TIMECODE_FLAGS = (MCLIP_USE_PROXY | MCLIP_USE_PROXY_CUSTOM_DIR)
+};
/* MovieClip->render_size */
-#define MCLIP_PROXY_RENDER_SIZE_FULL 0
-#define MCLIP_PROXY_RENDER_SIZE_25 1
-#define MCLIP_PROXY_RENDER_SIZE_50 2
-#define MCLIP_PROXY_RENDER_SIZE_75 3
-#define MCLIP_PROXY_RENDER_SIZE_100 4
+enum {
+ MCLIP_PROXY_RENDER_SIZE_FULL = 0,
+ MCLIP_PROXY_RENDER_SIZE_25 = 1,
+ MCLIP_PROXY_RENDER_SIZE_50 = 2,
+ MCLIP_PROXY_RENDER_SIZE_75 = 3,
+ MCLIP_PROXY_RENDER_SIZE_100 = 4
+};
/* MovieClip->render_flag */
-#define MCLIP_PROXY_RENDER_UNDISTORT 1
+enum {
+ MCLIP_PROXY_RENDER_UNDISTORT = 1
+};
#endif
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index c73ba87754f..1684cf28b3c 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -118,7 +118,8 @@ typedef struct bNodeSocket {
#define SOCK_BOOLEAN 4
#define SOCK_MESH 5
#define SOCK_INT 6
-#define NUM_SOCKET_TYPES 7 /* must be last! */
+#define SOCK_STRING 7
+#define NUM_SOCKET_TYPES 8 /* must be last! */
/* socket side (input/output) */
#define SOCK_IN 1
@@ -353,6 +354,11 @@ typedef struct bNodeSocketValueRGBA {
float value[4];
} bNodeSocketValueRGBA;
+typedef struct bNodeSocketValueString {
+ int subtype;
+ int pad;
+ char value[1024]; /* 1024 = FILEMAX */
+} bNodeSocketValueString;
/* data structs, for node->storage */
enum {
@@ -716,6 +722,17 @@ typedef struct NodeShaderScript {
IDProperty *prop;
} NodeShaderScript;
+typedef struct NodeShaderTangent {
+ int direction_type;
+ int axis;
+ char uv_map[64];
+} NodeShaderTangent;
+
+typedef struct NodeShaderNormalMap {
+ int space;
+ char uv_map[64];
+} NodeShaderNormalMap;
+
/* script node mode */
#define NODE_SCRIPT_INTERNAL 0
#define NODE_SCRIPT_EXTERNAL 1
@@ -800,6 +817,20 @@ typedef struct NodeShaderScript {
#define SHD_PROJ_FLAT 0
#define SHD_PROJ_BOX 1
+/* tangent */
+#define SHD_TANGENT_RADIAL 0
+#define SHD_TANGENT_UVMAP 1
+
+/* tangent */
+#define SHD_TANGENT_AXIS_X 0
+#define SHD_TANGENT_AXIS_Y 1
+#define SHD_TANGENT_AXIS_Z 2
+
+/* normal map space */
+#define SHD_NORMAL_MAP_TANGENT 0
+#define SHD_NORMAL_MAP_OBJECT 1
+#define SHD_NORMAL_MAP_WORLD 2
+
/* blur node */
#define CMP_NODE_BLUR_ASPECT_NONE 0
#define CMP_NODE_BLUR_ASPECT_Y 1
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 9bfa0e7fdf7..facddd8c718 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -401,11 +401,16 @@ typedef struct RenderData {
/**
* The number of part to use in the x direction
*/
- short xparts;
+ short xparts DNA_DEPRECATED;
/**
* The number of part to use in the y direction
*/
- short yparts;
+ short yparts DNA_DEPRECATED;
+
+ /**
+ * render tile dimensions
+ */
+ short tilex, tiley;
short planes DNA_DEPRECATED, imtype DNA_DEPRECATED, subimtype DNA_DEPRECATED, quality DNA_DEPRECATED; /*deprecated!*/
@@ -453,6 +458,8 @@ typedef struct RenderData {
short frs_sec, edgeint;
+ int pad;
+
/* safety, border and display rect */
rctf safety, border;
diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h
index 4d259fad246..f106c8f918a 100644
--- a/source/blender/makesdna/DNA_sequence_types.h
+++ b/source/blender/makesdna/DNA_sequence_types.h
@@ -100,6 +100,9 @@ typedef struct Strip {
StripCrop *crop;
StripTransform *transform;
StripColorBalance *color_balance DNA_DEPRECATED;
+
+ /* color management */
+ ColorManagedColorspaceSettings colorspace_settings;
} Strip;
/**
diff --git a/source/blender/makesdna/DNA_tracking_types.h b/source/blender/makesdna/DNA_tracking_types.h
index c6cefce2994..9c80d30bca4 100644
--- a/source/blender/makesdna/DNA_tracking_types.h
+++ b/source/blender/makesdna/DNA_tracking_types.h
@@ -167,6 +167,9 @@ typedef struct MovieTrackingSettings {
* were moved to per-tracking object settings
*/
+ float reconstruction_success_threshold;
+ int reconstruction_flag;
+
/* which camera intrinsics to refine. uses on the REFINE_* flags */
short refine_camera_intrinsics, pad2;
@@ -224,6 +227,7 @@ typedef struct MovieTrackingObject {
ListBase tracks; /* list of tracks use to tracking this object */
MovieTrackingReconstruction reconstruction; /* reconstruction data for this object */
+ /* reconstruction options */
int keyframe1, keyframe2; /* two keyframes for reconstrution initialization */
} MovieTrackingObject;
@@ -280,92 +284,129 @@ enum {
};
/* MovieTrackingMarker->flag */
-#define MARKER_DISABLED (1 << 0)
-#define MARKER_TRACKED (1 << 1)
-#define MARKER_GRAPH_SEL_X (1 << 2)
-#define MARKER_GRAPH_SEL_Y (1 << 3)
-#define MARKER_GRAPH_SEL (MARKER_GRAPH_SEL_X | MARKER_GRAPH_SEL_Y)
+enum {
+ MARKER_DISABLED = (1 << 0),
+ MARKER_TRACKED = (1 << 1),
+ MARKER_GRAPH_SEL_X = (1 << 2),
+ MARKER_GRAPH_SEL_Y = (1 << 3),
+ MARKER_GRAPH_SEL = (MARKER_GRAPH_SEL_X | MARKER_GRAPH_SEL_Y)
+};
/* MovieTrackingTrack->flag */
-#define TRACK_HAS_BUNDLE (1 << 1)
-#define TRACK_DISABLE_RED (1 << 2)
-#define TRACK_DISABLE_GREEN (1 << 3)
-#define TRACK_DISABLE_BLUE (1 << 4)
-#define TRACK_HIDDEN (1 << 5)
-#define TRACK_LOCKED (1 << 6)
-#define TRACK_CUSTOMCOLOR (1 << 7)
-#define TRACK_USE_2D_STAB (1 << 8)
-#define TRACK_PREVIEW_GRAYSCALE (1 << 9)
-#define TRACK_DOPE_SEL (1 << 10)
-#define TRACK_PREVIEW_ALPHA (1 << 11)
+enum {
+ TRACK_HAS_BUNDLE = (1 << 1),
+ TRACK_DISABLE_RED = (1 << 2),
+ TRACK_DISABLE_GREEN = (1 << 3),
+ TRACK_DISABLE_BLUE = (1 << 4),
+ TRACK_HIDDEN = (1 << 5),
+ TRACK_LOCKED = (1 << 6),
+ TRACK_CUSTOMCOLOR = (1 << 7),
+ TRACK_USE_2D_STAB = (1 << 8),
+ TRACK_PREVIEW_GRAYSCALE = (1 << 9),
+ TRACK_DOPE_SEL = (1 << 10),
+ TRACK_PREVIEW_ALPHA = (1 << 11)
+};
/* MovieTrackingTrack->motion_model */
-#define TRACK_MOTION_MODEL_TRANSLATION 0
-#define TRACK_MOTION_MODEL_TRANSLATION_ROTATION 1
-#define TRACK_MOTION_MODEL_TRANSLATION_SCALE 2
-#define TRACK_MOTION_MODEL_TRANSLATION_ROTATION_SCALE 3
-#define TRACK_MOTION_MODEL_AFFINE 4
-#define TRACK_MOTION_MODEL_HOMOGRAPHY 5
+enum {
+ TRACK_MOTION_MODEL_TRANSLATION = 0,
+ TRACK_MOTION_MODEL_TRANSLATION_ROTATION = 1,
+ TRACK_MOTION_MODEL_TRANSLATION_SCALE = 2,
+ TRACK_MOTION_MODEL_TRANSLATION_ROTATION_SCALE = 3,
+ TRACK_MOTION_MODEL_AFFINE = 4,
+ TRACK_MOTION_MODEL_HOMOGRAPHY = 5
+};
/* MovieTrackingTrack->algorithm_flag */
-#define TRACK_ALGORITHM_FLAG_USE_BRUTE (1 << 0)
-#define TRACK_ALGORITHM_FLAG_USE_NORMALIZATION (1 << 2)
-#define TRACK_ALGORITHM_FLAG_USE_MASK (1 << 3)
+enum {
+ TRACK_ALGORITHM_FLAG_USE_BRUTE = (1 << 0),
+ TRACK_ALGORITHM_FLAG_USE_NORMALIZATION = (1 << 2),
+ TRACK_ALGORITHM_FLAG_USE_MASK = (1 << 3)
+};
/* MovieTrackingTrack->adjframes */
-#define TRACK_MATCH_KEYFRAME 0
-#define TRACK_MATCH_PREVFRAME 1
+enum {
+ TRACK_MATCH_KEYFRAME = 0,
+ TRACK_MATCH_PREVFRAME = 1
+};
/* MovieTrackingSettings->flag */
-#define TRACKING_SETTINGS_SHOW_DEFAULT_EXPANDED (1 << 0)
+enum {
+ TRACKING_SETTINGS_SHOW_DEFAULT_EXPANDED = (1 << 0)
+};
/* MovieTrackingSettings->motion_flag */
-#define TRACKING_MOTION_TRIPOD (1 << 0)
+enum {
+ TRACKING_MOTION_TRIPOD = (1 << 0),
-#define TRACKING_MOTION_MODAL (TRACKING_MOTION_TRIPOD)
+ TRACKING_MOTION_MODAL = (TRACKING_MOTION_TRIPOD)
+};
/* MovieTrackingSettings->speed */
-#define TRACKING_SPEED_FASTEST 0
-#define TRACKING_SPEED_REALTIME 1
-#define TRACKING_SPEED_HALF 2
-#define TRACKING_SPEED_QUARTER 4
-#define TRACKING_SPEED_DOUBLE 5
+enum {
+ TRACKING_SPEED_FASTEST = 0,
+ TRACKING_SPEED_REALTIME = 1,
+ TRACKING_SPEED_HALF = 2,
+ TRACKING_SPEED_QUARTER = 4,
+ TRACKING_SPEED_DOUBLE = 5
+};
+
+/* MovieTrackingObject->reconstruction_flag */
+enum {
+ TRACKING_USE_FALLBACK_RECONSTRUCTION = (1 << 0)
+};
/* MovieTrackingSettings->refine_camera_intrinsics */
-#define REFINE_FOCAL_LENGTH (1 << 0)
-#define REFINE_PRINCIPAL_POINT (1 << 1)
-#define REFINE_RADIAL_DISTORTION_K1 (1 << 2)
-#define REFINE_RADIAL_DISTORTION_K2 (1 << 4)
+enum {
+ REFINE_FOCAL_LENGTH = (1 << 0),
+ REFINE_PRINCIPAL_POINT = (1 << 1),
+ REFINE_RADIAL_DISTORTION_K1 = (1 << 2),
+ REFINE_RADIAL_DISTORTION_K2 = (1 << 4)
+};
/* MovieTrackingStrabilization->flag */
-#define TRACKING_2D_STABILIZATION (1 << 0)
-#define TRACKING_AUTOSCALE (1 << 1)
-#define TRACKING_STABILIZE_ROTATION (1 << 2)
+enum {
+ TRACKING_2D_STABILIZATION = (1 << 0),
+ TRACKING_AUTOSCALE = (1 << 1),
+ TRACKING_STABILIZE_ROTATION = (1 << 2)
+};
/* MovieTrackingStrabilization->filter */
-#define TRACKING_FILTER_NEAREAST 0
-#define TRACKING_FILTER_BILINEAR 1
-#define TRACKING_FILTER_BICUBIC 2
+enum {
+ TRACKING_FILTER_NEAREAST = 0,
+ TRACKING_FILTER_BILINEAR = 1,
+ TRACKING_FILTER_BICUBIC = 2
+};
/* MovieTrackingReconstruction->flag */
-#define TRACKING_RECONSTRUCTED (1 << 0)
+enum {
+ TRACKING_RECONSTRUCTED = (1 << 0)
+};
/* MovieTrackingObject->flag */
-#define TRACKING_OBJECT_CAMERA (1 << 0)
+enum {
+ TRACKING_OBJECT_CAMERA = (1 << 0)
+};
-#define TRACKING_CLEAN_SELECT 0
-#define TRACKING_CLEAN_DELETE_TRACK 1
-#define TRACKING_CLEAN_DELETE_SEGMENT 2
+enum {
+ TRACKING_CLEAN_SELECT = 0,
+ TRACKING_CLEAN_DELETE_TRACK = 1,
+ TRACKING_CLEAN_DELETE_SEGMENT = 2
+};
/* MovieTrackingDopesheet->sort_method */
-#define TRACKING_DOPE_SORT_NAME 0
-#define TRACKING_DOPE_SORT_LONGEST 1
-#define TRACKING_DOPE_SORT_TOTAL 2
-#define TRACKING_DOPE_SORT_AVERAGE_ERROR 3
+enum {
+ TRACKING_DOPE_SORT_NAME = 0,
+ TRACKING_DOPE_SORT_LONGEST = 1,
+ TRACKING_DOPE_SORT_TOTAL = 2,
+ TRACKING_DOPE_SORT_AVERAGE_ERROR = 3
+};
/* MovieTrackingDopesheet->flag */
-#define TRACKING_DOPE_SORT_INVERSE (1 << 0)
-#define TRACKING_DOPE_SELECTED_ONLY (1 << 1)
-#define TRACKING_DOPE_SHOW_HIDDEN (1 << 2)
+enum {
+ TRACKING_DOPE_SORT_INVERSE = (1 << 0),
+ TRACKING_DOPE_SELECTED_ONLY = (1 << 1),
+ TRACKING_DOPE_SHOW_HIDDEN = (1 << 2)
+};
#endif
diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c
index 07b8072076e..247e024f8a3 100644
--- a/source/blender/makesrna/intern/rna_action.c
+++ b/source/blender/makesrna/intern/rna_action.c
@@ -46,9 +46,13 @@
#ifdef RNA_RUNTIME
-#include "ED_keyframing.h"
+#include "BLI_math_base.h"
+
#include "BKE_fcurve.h"
+#include "ED_keyframing.h"
+
+
static void rna_ActionGroup_channels_next(CollectionPropertyIterator *iter)
{
ListBaseIterator *internal = iter->internal;
@@ -191,8 +195,7 @@ static void rna_Action_active_pose_marker_index_range(PointerRNA *ptr, int *min,
bAction *act = (bAction *)ptr->data;
*min = 0;
- *max = BLI_countlist(&act->markers) - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, BLI_countlist(&act->markers) - 1);
}
diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c
index ce884fa4ecc..7229dddf6d6 100644
--- a/source/blender/makesrna/intern/rna_animation.c
+++ b/source/blender/makesrna/intern/rna_animation.c
@@ -54,6 +54,8 @@ EnumPropertyItem keyingset_path_grouping_items[] = {
#ifdef RNA_RUNTIME
+#include "BLI_math_base.h"
+
#include "BKE_animsys.h"
#include "BKE_fcurve.h"
#include "BKE_nla.h"
@@ -296,6 +298,43 @@ static void rna_ksPath_RnaPath_set(PointerRNA *ptr, const char *value)
/* ****************************** */
+static void rna_KeyingSet_name_set(PointerRNA *ptr, const char *value)
+{
+ KeyingSet *ks = (KeyingSet *)ptr->data;
+
+ /* update names of corresponding groups if name changes */
+ if (strcmp(ks->name, value)) {
+ KS_Path *ksp;
+
+ for (ksp = ks->paths.first; ksp; ksp = ksp->next) {
+ if ((ksp->groupmode == KSP_GROUP_KSNAME) && (ksp->id)) {
+ AnimData *adt = BKE_animdata_from_id(ksp->id);
+
+ /* TODO: NLA strips? */
+ if (adt && adt->action) {
+ bActionGroup *agrp;
+
+ /* lazy check - should really find the F-Curve for the affected path and check its group
+ * but this way should be faster and work well for most cases, as long as there are no
+ * conflicts
+ */
+ for (agrp = adt->action->groups.first; agrp; agrp = agrp->next) {
+ if (strcmp(ks->name, agrp->name) == 0) {
+ /* there should only be one of these in the action, so can stop... */
+ BLI_strncpy(agrp->name, value, sizeof(agrp->name));
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /* finally, update name to new value */
+ BLI_strncpy(ks->name, value, sizeof(ks->name));
+}
+
+
static int rna_KeyingSet_active_ksPath_editable(PointerRNA *ptr)
{
KeyingSet *ks = (KeyingSet *)ptr->data;
@@ -334,8 +373,7 @@ static void rna_KeyingSet_active_ksPath_index_range(PointerRNA *ptr, int *min, i
KeyingSet *ks = (KeyingSet *)ptr->data;
*min = 0;
- *max = BLI_countlist(&ks->paths) - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, BLI_countlist(&ks->paths) - 1);
}
static PointerRNA rna_KeyingSet_typeinfo_get(PointerRNA *ptr)
@@ -430,7 +468,7 @@ static void rna_NlaTrack_remove(AnimData *adt, bContext *C, ReportList *reports,
NlaTrack *track = track_ptr->data;
if (BLI_findindex(&adt->nla_tracks, track) == -1) {
- BKE_reportf(reports, RPT_ERROR, "NlaTrack '%s' can't be removed", track->name);
+ BKE_reportf(reports, RPT_ERROR, "NlaTrack '%s' cannot be removed", track->name);
return;
}
@@ -721,19 +759,20 @@ static void rna_def_keyingset(BlenderRNA *brna)
srna = RNA_def_struct(brna, "KeyingSet", NULL);
RNA_def_struct_ui_text(srna, "Keying Set", "Settings that should be keyframed together");
- /* Id/Label. */
+ /* Id/Label */
prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "idname");
RNA_def_property_flag(prop, PROP_REGISTER | PROP_NEVER_CLAMP);
RNA_def_property_ui_text(prop, "ID Name", KEYINGSET_IDNAME_DOC);
- RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET | NA_RENAME, NULL);
+/* RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET | NA_RENAME, NULL); */ /* NOTE: disabled, as ID name shouldn't be editable */
prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "name");
+ RNA_def_property_string_funcs(prop, NULL, NULL, "rna_KeyingSet_name_set");
RNA_def_property_ui_text(prop, "UI Name", "");
RNA_def_struct_ui_icon(srna, ICON_KEYINGSET);
RNA_def_struct_name_property(srna, prop);
-/* RNA_def_property_update(prop, NC_SCENE|ND_KEYINGSET|NA_RENAME, NULL);*/
+ RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET | NA_RENAME, NULL);
prop = RNA_def_property(srna, "bl_description", PROP_STRING, PROP_TRANSLATE);
RNA_def_property_string_sdna(prop, NULL, "description");
diff --git a/source/blender/makesrna/intern/rna_boid.c b/source/blender/makesrna/intern/rna_boid.c
index 8e45da50e9b..3da718afd1c 100644
--- a/source/blender/makesrna/intern/rna_boid.c
+++ b/source/blender/makesrna/intern/rna_boid.c
@@ -80,6 +80,8 @@ EnumPropertyItem boidruleset_type_items[] = {
#ifdef RNA_RUNTIME
+#include "BLI_math_base.h"
+
#include "BKE_context.h"
#include "BKE_depsgraph.h"
#include "BKE_particle.h"
@@ -157,8 +159,7 @@ static void rna_BoidState_active_boid_rule_index_range(PointerRNA *ptr, int *min
{
BoidState *state = (BoidState *)ptr->data;
*min = 0;
- *max = BLI_countlist(&state->rules) - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, BLI_countlist(&state->rules) - 1);
}
static int rna_BoidState_active_boid_rule_index_get(PointerRNA *ptr)
@@ -224,8 +225,7 @@ static void rna_BoidSettings_active_boid_state_index_range(PointerRNA *ptr, int
{
BoidSettings *boids = (BoidSettings *)ptr->data;
*min = 0;
- *max = BLI_countlist(&boids->states) - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, BLI_countlist(&boids->states) - 1);
}
static int rna_BoidSettings_active_boid_state_index_get(PointerRNA *ptr)
diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c
index f3a3b5c43f8..fdb6c0afa4e 100644
--- a/source/blender/makesrna/intern/rna_color.c
+++ b/source/blender/makesrna/intern/rna_color.c
@@ -45,6 +45,7 @@
#include "DNA_material_types.h"
#include "DNA_movieclip_types.h"
#include "DNA_node_types.h"
+#include "DNA_sequence_types.h"
#include "MEM_guardedalloc.h"
@@ -53,6 +54,7 @@
#include "BKE_image.h"
#include "BKE_movieclip.h"
#include "BKE_node.h"
+#include "BKE_sequencer.h"
#include "BKE_texture.h"
#include "BKE_linestyle.h"
@@ -531,9 +533,44 @@ static void rna_ColorManagedColorspaceSettings_reload_update(Main *UNUSED(bmain)
BKE_movieclip_reload(clip);
+ /* all sequencers for now, we don't know which scenes are using this clip as a strip */
+ BKE_sequencer_cache_cleanup();
+ BKE_sequencer_preprocessed_cache_cleanup();
+
WM_main_add_notifier(NC_MOVIECLIP | ND_DISPLAY, &clip->id);
WM_main_add_notifier(NC_MOVIECLIP | NA_EDITED, &clip->id);
}
+ else if (GS(id->name) == ID_SCE) {
+ Scene *scene = (Scene *) id;
+
+ if (scene->ed) {
+ ColorManagedColorspaceSettings *colorspace_settings = (ColorManagedColorspaceSettings *) ptr->data;
+ Sequence *seq;
+ int seq_found = FALSE;
+
+ if (&scene->sequencer_colorspace_settings != colorspace_settings) {
+ SEQ_BEGIN(scene->ed, seq);
+ {
+ if (seq->strip && &seq->strip->colorspace_settings == colorspace_settings) {
+ seq_found = TRUE;
+ break;
+ }
+ }
+ SEQ_END;
+ }
+
+ if (seq_found) {
+ BKE_sequence_invalidate_cache(scene, seq);
+ BKE_sequencer_preprocessed_cache_cleanup_sequence(seq);
+ }
+ else {
+ BKE_sequencer_cache_cleanup();
+ BKE_sequencer_preprocessed_cache_cleanup();
+ }
+
+ WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, NULL);
+ }
+ }
}
static void rna_ColorManagement_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c
index 35699c6ef3f..a3cff99ddc8 100644
--- a/source/blender/makesrna/intern/rna_curve.c
+++ b/source/blender/makesrna/intern/rna_curve.c
@@ -242,16 +242,14 @@ static void rna_Curve_material_index_range(PointerRNA *ptr, int *min, int *max,
{
Curve *cu = (Curve *)ptr->id.data;
*min = 0;
- *max = cu->totcol - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, cu->totcol - 1);
}
static void rna_Curve_active_textbox_index_range(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
{
Curve *cu = (Curve *)ptr->id.data;
*min = 0;
- *max = cu->totbox - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, cu->totbox - 1);
}
diff --git a/source/blender/makesrna/intern/rna_mask.c b/source/blender/makesrna/intern/rna_mask.c
index 56caa254a59..3f23a376ea3 100644
--- a/source/blender/makesrna/intern/rna_mask.c
+++ b/source/blender/makesrna/intern/rna_mask.c
@@ -158,8 +158,7 @@ static void rna_Mask_layer_active_index_range(PointerRNA *ptr, int *min, int *ma
Mask *mask = (Mask *)ptr->id.data;
*min = 0;
- *max = mask->masklay_tot - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, mask->masklay_tot - 1);
*softmin = *min;
*softmax = *max;
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c
index ec7f92374a7..a6f4a88e6c3 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -1010,8 +1010,7 @@ static void rna_MeshPoly_material_index_range(PointerRNA *ptr, int *min, int *ma
{
Mesh *me = rna_mesh(ptr);
*min = 0;
- *max = me->totcol - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, me->totcol - 1);
}
static int rna_MeshVertex_index_get(PointerRNA *ptr)
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 8eca7162d39..d421eb697a3 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -481,8 +481,7 @@ static void rna_MultiresModifier_level_range(PointerRNA *ptr, int *min, int *max
MultiresModifierData *mmd = (MultiresModifierData *)ptr->data;
*min = 0;
- *max = mmd->totlvl; /* intentionally _not_ -1 */
- *max = MAX2(0, *max);
+ *max = max_ii(0, mmd->totlvl); /* intentionally _not_ -1 */
}
static int rna_MultiresModifier_external_get(PointerRNA *ptr)
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index ece5c82f747..d241f697be0 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -92,6 +92,7 @@ EnumPropertyItem node_socket_type_items[] = {
{SOCK_BOOLEAN, "BOOLEAN", 0, "Boolean", ""},
{SOCK_MESH, "MESH", 0, "Mesh", ""},
{SOCK_INT, "INT", 0, "Int", ""},
+ {SOCK_STRING, "STRING", 0, "String", ""},
{0, NULL, 0, NULL, NULL}
};
@@ -192,6 +193,10 @@ EnumPropertyItem prop_wave_items[] = {
SUBTYPE(FLOAT, Float, TIME, Time) \
SUBTYPE(FLOAT, Float, DISTANCE, Distance)
+#define NODE_DEFINE_SUBTYPES_STRING \
+ SUBTYPE(STRING, String, NONE, None) \
+ SUBTYPE(STRING, String, FILEPATH, Filepath)
+
#define NODE_DEFINE_SUBTYPES_VECTOR \
SUBTYPE(VECTOR, Vector, NONE, None) \
SUBTYPE(VECTOR, Vector, TRANSLATION, Translation) \
@@ -204,7 +209,8 @@ EnumPropertyItem prop_wave_items[] = {
#define NODE_DEFINE_SUBTYPES \
NODE_DEFINE_SUBTYPES_INT \
NODE_DEFINE_SUBTYPES_FLOAT \
- NODE_DEFINE_SUBTYPES_VECTOR
+ NODE_DEFINE_SUBTYPES_STRING \
+ NODE_DEFINE_SUBTYPES_VECTOR \
#ifdef RNA_RUNTIME
@@ -292,6 +298,9 @@ static StructRNA *rna_NodeSocket_refine(PointerRNA *ptr)
case SOCK_VECTOR:
NODE_DEFINE_SUBTYPES_VECTOR
break;
+ case SOCK_STRING:
+ NODE_DEFINE_SUBTYPES_STRING
+ break;
case SOCK_RGBA:
return &RNA_NodeSocketRGBA;
case SOCK_SHADER:
@@ -1166,7 +1175,7 @@ static EnumPropertyItem node_glossy_items[] = {
static EnumPropertyItem node_script_mode_items[] = {
{NODE_SCRIPT_INTERNAL, "INTERNAL", 0, "Internal", "Use internal text datablock"},
- {NODE_SCRIPT_EXTERNAL, "EXTERNAL", 0, "External", "Use external .osl or oso file"},
+ {NODE_SCRIPT_EXTERNAL, "EXTERNAL", 0, "External", "Use external .osl or .oso file"},
{0, NULL, 0, NULL, NULL}
};
@@ -1275,6 +1284,14 @@ static void alloc_node_type_items(EnumPropertyItem *items, int category)
item++;
+ item->value = NODE_FRAME;
+ item->identifier = "FRAME";
+ item->icon = 0;
+ item->name = "Frame";
+ item->description = "";
+
+ item++;
+
/* NOTE!, increase 'count' when adding items here */
memset(item, 0, sizeof(EnumPropertyItem));
@@ -1842,6 +1859,67 @@ static void def_glossy(StructRNA *srna)
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
}
+static void def_sh_normal_map(StructRNA *srna)
+{
+ static EnumPropertyItem prop_space_items[] = {
+ {SHD_NORMAL_MAP_TANGENT, "TANGENT", 0, "Tangent Space", "Tangent space normal mapping"},
+ {SHD_NORMAL_MAP_OBJECT, "OBJECT", 0, "Object Space", "Object space normal mapping"},
+ {SHD_NORMAL_MAP_WORLD, "WORLD", 0, "World Space", "World space normal mapping"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ PropertyRNA *prop;
+
+ RNA_def_struct_sdna_from(srna, "NodeShaderNormalMap", "storage");
+
+ prop = RNA_def_property(srna, "space", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, prop_space_items);
+ RNA_def_property_ui_text(prop, "Space", "Space of the input normal");
+ RNA_def_property_update(prop, 0, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "uv_map", PROP_STRING, PROP_NONE);
+ RNA_def_property_ui_text(prop, "UV Map", "UV Map for tangent space maps");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+
+ RNA_def_struct_sdna_from(srna, "bNode", NULL);
+}
+
+static void def_sh_tangent(StructRNA *srna)
+{
+ static EnumPropertyItem prop_direction_type_items[] = {
+ {SHD_TANGENT_RADIAL, "RADIAL", 0, "Radial", "Radial tangent around the X, Y or Z axis"},
+ {SHD_TANGENT_UVMAP, "UV_MAP", 0, "UV Map", "Tangent from UV map"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ static EnumPropertyItem prop_axis_items[] = {
+ {SHD_TANGENT_AXIS_X, "X", 0, "X", "X axis"},
+ {SHD_TANGENT_AXIS_Y, "Y", 0, "Y", "Y axis"},
+ {SHD_TANGENT_AXIS_Z, "Z", 0, "Z", "Z axis"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ PropertyRNA *prop;
+
+ RNA_def_struct_sdna_from(srna, "NodeShaderTangent", "storage");
+
+ prop = RNA_def_property(srna, "direction_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, prop_direction_type_items);
+ RNA_def_property_ui_text(prop, "Direction", "Method to use for the tangent");
+ RNA_def_property_update(prop, 0, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, prop_axis_items);
+ RNA_def_property_ui_text(prop, "Axis", "Axis for radial tangents");
+ RNA_def_property_update(prop, 0, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "uv_map", PROP_STRING, PROP_NONE);
+ RNA_def_property_ui_text(prop, "UV Map", "UV Map for tangent generated from UV");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+
+ RNA_def_struct_sdna_from(srna, "bNode", NULL);
+}
+
static void def_sh_script(StructRNA *srna)
{
FunctionRNA *func;
@@ -1869,11 +1947,12 @@ static void def_sh_script(StructRNA *srna)
prop = RNA_def_property(srna, "use_auto_update", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", NODE_SCRIPT_AUTO_UPDATE);
- RNA_def_property_ui_text(prop, "Auto Update", "Automatically updates the shader when the .osl file changes - external scripts only");
+ RNA_def_property_ui_text(prop, "Auto Update",
+ "Automatically update the shader when the .osl file changes (external scripts only)");
prop = RNA_def_property(srna, "bytecode", PROP_STRING, PROP_NONE);
- RNA_def_property_string_funcs(prop, "rna_ShaderNodeScript_bytecode_get",
- "rna_ShaderNodeScript_bytecode_length", "rna_ShaderNodeScript_bytecode_set");
+ RNA_def_property_string_funcs(prop, "rna_ShaderNodeScript_bytecode_get", "rna_ShaderNodeScript_bytecode_length",
+ "rna_ShaderNodeScript_bytecode_set");
RNA_def_property_ui_text(prop, "Bytecode", "Compile bytecode for shader script node");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
@@ -4464,6 +4543,20 @@ static void rna_def_node_socket_subtype(BlenderRNA *brna, int type, int subtype,
RNA_def_property_ui_text(prop, "Default Value", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocket_update");
break;
+ case SOCK_STRING:
+ RNA_def_struct_sdna_from(srna, "bNodeSocketValueString", "default_value");
+
+ prop = RNA_def_property(srna, "subtype", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "subtype");
+ RNA_def_property_enum_items(prop, subtype_items);
+ RNA_def_property_ui_text(prop, "Subtype", "Subtype defining the socket value details");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocket_update");
+
+ prop = RNA_def_property(srna, "default_value", PROP_STRING, PROP_FILEPATH);
+ RNA_def_property_string_sdna(prop, NULL, "value");
+ RNA_def_property_ui_text(prop, "Default Value", "");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocket_update");
+ break;
}
/* XXX need to reset the from-type here, so subtype subclasses cast correctly! (RNA bug) */
diff --git a/source/blender/makesrna/intern/rna_nodetree_types.h b/source/blender/makesrna/intern/rna_nodetree_types.h
index c45c9b71442..fbbcbae6c12 100644
--- a/source/blender/makesrna/intern/rna_nodetree_types.h
+++ b/source/blender/makesrna/intern/rna_nodetree_types.h
@@ -65,12 +65,14 @@ DefNode( ShaderNode, SH_NODE_LAYER_WEIGHT, 0, "LA
DefNode( ShaderNode, SH_NODE_MIX_SHADER, 0, "MIX_SHADER", MixShader, "Mix Shader", "" )
DefNode( ShaderNode, SH_NODE_ADD_SHADER, 0, "ADD_SHADER", AddShader, "Add Shader", "" )
DefNode( ShaderNode, SH_NODE_ATTRIBUTE, def_sh_attribute, "ATTRIBUTE", Attribute, "Attribute", "" )
+DefNode( ShaderNode, SH_NODE_AMBIENT_OCCLUSION, 0, "AMBIENT_OCCLUSION", AmbientOcclusion, "Ambient Occlusion", "" )
DefNode( ShaderNode, SH_NODE_BACKGROUND, 0, "BACKGROUND", Background, "Background", "" )
DefNode( ShaderNode, SH_NODE_HOLDOUT, 0, "HOLDOUT", Holdout, "Holdout", "" )
DefNode( ShaderNode, SH_NODE_BSDF_ANISOTROPIC, 0, "BSDF_ANISOTROPIC", BsdfAnisotropic, "Anisotropic Bsdf", "" )
DefNode( ShaderNode, SH_NODE_BSDF_DIFFUSE, 0, "BSDF_DIFFUSE", BsdfDiffuse, "Diffuse Bsdf", "" )
DefNode( ShaderNode, SH_NODE_BSDF_GLOSSY, def_glossy, "BSDF_GLOSSY", BsdfGlossy, "Glossy Bsdf", "" )
DefNode( ShaderNode, SH_NODE_BSDF_GLASS, def_glossy, "BSDF_GLASS", BsdfGlass, "Glass Bsdf", "" )
+DefNode( ShaderNode, SH_NODE_BSDF_REFRACTION, def_glossy, "BSDF_REFRACTION", BsdfRefraction, "Refraction Bsdf", "" )
DefNode( ShaderNode, SH_NODE_BSDF_TRANSLUCENT, 0, "BSDF_TRANSLUCENT", BsdfTranslucent, "Translucent Bsdf", "" )
DefNode( ShaderNode, SH_NODE_BSDF_TRANSPARENT, 0, "BSDF_TRANSPARENT", BsdfTransparent, "Transparent Bsdf", "" )
DefNode( ShaderNode, SH_NODE_BSDF_VELVET, 0, "BSDF_VELVET", BsdfVelvet, "Velvet Bsdf", "" )
@@ -82,7 +84,9 @@ DefNode( ShaderNode, SH_NODE_LIGHT_PATH, 0, "LI
DefNode( ShaderNode, SH_NODE_LIGHT_FALLOFF, 0, "LIGHT_FALLOFF", LightFalloff, "Light Falloff", "" )
DefNode( ShaderNode, SH_NODE_OBJECT_INFO, 0, "OBJECT_INFO", ObjectInfo, "Object Info", "" )
DefNode( ShaderNode, SH_NODE_PARTICLE_INFO, 0, "PARTICLE_INFO", ParticleInfo, "Particle Info", "" )
-DefNode( ShaderNode, SH_NODE_BUMP, 0, "BUMP", BumpNode, "Bump", "" )
+DefNode( ShaderNode, SH_NODE_BUMP, 0, "BUMP", Bump, "Bump", "" )
+DefNode( ShaderNode, SH_NODE_NORMAL_MAP, def_sh_normal_map, "NORMAL_MAP", NormalMap, "Normal Map", "" )
+DefNode( ShaderNode, SH_NODE_TANGENT, def_sh_tangent, "TANGENT", Tangent, "Tangent", "" )
DefNode( ShaderNode, SH_NODE_SCRIPT, def_sh_script, "SCRIPT", Script, "Script", "" )
DefNode( ShaderNode, SH_NODE_TEX_IMAGE, def_sh_tex_image, "TEX_IMAGE", TexImage, "Image Texture", "" )
DefNode( ShaderNode, SH_NODE_TEX_ENVIRONMENT, def_sh_tex_environment, "TEX_ENVIRONMENT", TexEnvironment, "Environment Texture","" )
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 10f361ef1bd..82f27b953cf 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -547,8 +547,7 @@ static void rna_Object_active_vertex_group_index_range(PointerRNA *ptr, int *min
Object *ob = (Object *)ptr->id.data;
*min = 0;
- *max = BLI_countlist(&ob->defbase) - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, BLI_countlist(&ob->defbase) - 1);
}
void rna_object_vgroup_name_index_get(PointerRNA *ptr, char *value, int index)
@@ -658,7 +657,7 @@ static void rna_Object_active_material_index_range(PointerRNA *ptr, int *min, in
{
Object *ob = (Object *)ptr->id.data;
*min = 0;
- *max = MAX2(ob->totcol - 1, 0);
+ *max = max_ii(ob->totcol - 1, 0);
}
/* returns active base material */
@@ -684,8 +683,7 @@ static void rna_Object_active_particle_system_index_range(PointerRNA *ptr, int *
{
Object *ob = (Object *)ptr->id.data;
*min = 0;
- *max = BLI_countlist(&ob->particlesystem) - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, BLI_countlist(&ob->particlesystem) - 1);
}
static int rna_Object_active_particle_system_index_get(PointerRNA *ptr)
diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c
index f47b864d25a..6d7187da7d9 100644
--- a/source/blender/makesrna/intern/rna_object_force.c
+++ b/source/blender/makesrna/intern/rna_object_force.c
@@ -51,6 +51,9 @@ static EnumPropertyItem effector_shape_items[] = {
#ifdef RNA_RUNTIME
+#include "BLI_math_base.h"
+
+
/* type specific return values only used from functions */
static EnumPropertyItem curve_shape_items[] = {
{PFIELD_SHAPE_POINT, "POINT", 0, "Point", ""},
@@ -239,8 +242,7 @@ static void rna_Cache_active_point_cache_index_range(PointerRNA *ptr, int *min,
for (pid = pidlist.first; pid; pid = pid->next) {
if (pid->cache == cache) {
- *max = BLI_countlist(pid->ptcaches) - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, BLI_countlist(pid->ptcaches) - 1);
break;
}
}
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index 9ba2a062791..6825d3d781d 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -530,8 +530,7 @@ static void rna_ParticleSystem_active_particle_target_index_range(PointerRNA *pt
{
ParticleSystem *psys = (ParticleSystem *)ptr->data;
*min = 0;
- *max = BLI_countlist(&psys->targets) - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, BLI_countlist(&psys->targets) - 1);
}
static int rna_ParticleSystem_active_particle_target_index_get(PointerRNA *ptr)
@@ -670,8 +669,7 @@ static void rna_ParticleDupliWeight_active_index_range(PointerRNA *ptr, int *min
{
ParticleSettings *part = (ParticleSettings *)ptr->id.data;
*min = 0;
- *max = BLI_countlist(&part->dupliweights) - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, BLI_countlist(&part->dupliweights) - 1);
}
static int rna_ParticleDupliWeight_active_index_get(PointerRNA *ptr)
diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c
index c29537378dd..412aad20a41 100644
--- a/source/blender/makesrna/intern/rna_pose.c
+++ b/source/blender/makesrna/intern/rna_pose.c
@@ -381,13 +381,7 @@ static void rna_PoseChannel_bone_group_index_range(PointerRNA *ptr, int *min, in
bPose *pose = (ob) ? ob->pose : NULL;
*min = 0;
-
- if (pose) {
- *max = BLI_countlist(&pose->agroups) - 1;
- *max = MAX2(0, *max);
- }
- else
- *max = 0;
+ *max = pose ? max_ii(0, BLI_countlist(&pose->agroups) - 1) : 0;
}
static PointerRNA rna_Pose_active_bone_group_get(PointerRNA *ptr)
@@ -419,8 +413,7 @@ static void rna_Pose_active_bone_group_index_range(PointerRNA *ptr, int *min, in
bPose *pose = (bPose *)ptr->data;
*min = 0;
- *max = BLI_countlist(&pose->agroups) - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, BLI_countlist(&pose->agroups) - 1);
}
#if 0
diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c
index 56497e96c67..46b22cd0963 100644
--- a/source/blender/makesrna/intern/rna_render.c
+++ b/source/blender/makesrna/intern/rna_render.c
@@ -370,6 +370,11 @@ static void rna_def_render_engine(BlenderRNA *brna)
prop = RNA_def_float(func, "progress", 0, 0.0f, 1.0f, "", "Percentage of render that's done", 0.0f, 1.0f);
RNA_def_property_flag(prop, PROP_REQUIRED);
+ func = RNA_def_function(srna, "update_memory_stats", "RE_engine_update_memory_stats");
+ RNA_def_float(func, "memory_used", 0, 0.0f, FLT_MAX, "", "Current memory usage in megabytes", 0.0f, FLT_MAX);
+ RNA_def_float(func, "memory_peak", 0, 0.0f, FLT_MAX, "", "Peak memory usage in megabytes", 0.0f, FLT_MAX);
+ RNA_def_property_flag(prop, PROP_REQUIRED);
+
func = RNA_def_function(srna, "report", "RE_engine_report");
prop = RNA_def_enum_flag(func, "type", wm_report_items, 0, "Type", "");
RNA_def_property_flag(prop, PROP_REQUIRED);
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 42fb712786c..516f619d910 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -1005,8 +1005,7 @@ static void rna_RenderSettings_active_layer_index_range(PointerRNA *ptr, int *mi
RenderData *rd = (RenderData *)ptr->data;
*min = 0;
- *max = BLI_countlist(&rd->layers) - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, BLI_countlist(&rd->layers) - 1);
}
static PointerRNA rna_RenderSettings_active_layer_get(PointerRNA *ptr)
@@ -3837,16 +3836,16 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Resolution %", "Percentage scale for render resolution");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
- prop = RNA_def_property(srna, "parts_x", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "xparts");
- RNA_def_property_range(prop, 1, 512);
- RNA_def_property_ui_text(prop, "Parts X", "Number of horizontal tiles to use while rendering");
+ prop = RNA_def_property(srna, "tile_x", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "tilex");
+ RNA_def_property_range(prop, 8, 10000);
+ RNA_def_property_ui_text(prop, "Tile X", "Horizontal tile size to use while rendering");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
- prop = RNA_def_property(srna, "parts_y", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "yparts");
- RNA_def_property_range(prop, 1, 512);
- RNA_def_property_ui_text(prop, "Parts Y", "Number of vertical tiles to use while rendering");
+ prop = RNA_def_property(srna, "tile_y", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "tiley");
+ RNA_def_property_range(prop, 8, 10000);
+ RNA_def_property_ui_text(prop, "Tile Y", "Vertical tile size to use while rendering");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "pixel_aspect_x", PROP_FLOAT, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c
index 054d0cc82c6..c2fa64698e4 100644
--- a/source/blender/makesrna/intern/rna_sequencer.c
+++ b/source/blender/makesrna/intern/rna_sequencer.c
@@ -1688,6 +1688,16 @@ static void rna_def_effect_inputs(StructRNA *srna, int count)
#endif
}
+static void rna_def_color_management(StructRNA *srna)
+{
+ PropertyRNA *prop;
+
+ prop = RNA_def_property(srna, "colorspace_settings", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "strip->colorspace_settings");
+ RNA_def_property_struct_type(prop, "ColorManagedColorspaceSettings");
+ RNA_def_property_ui_text(prop, "Color Space Settings", "Input color space settings");
+}
+
static void rna_def_image(BlenderRNA *brna)
{
StructRNA *srna;
@@ -1714,6 +1724,7 @@ static void rna_def_image(BlenderRNA *brna)
rna_def_filter_video(srna);
rna_def_proxy(srna);
rna_def_input(srna);
+ rna_def_color_management(srna);
}
static void rna_def_meta(BlenderRNA *brna)
@@ -1799,6 +1810,7 @@ static void rna_def_movie(BlenderRNA *brna)
rna_def_filter_video(srna);
rna_def_proxy(srna);
rna_def_input(srna);
+ rna_def_color_management(srna);
}
static void rna_def_movieclip(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_sequencer_api.c b/source/blender/makesrna/intern/rna_sequencer_api.c
index 8ddb9d0a7e7..7602ec99c2b 100644
--- a/source/blender/makesrna/intern/rna_sequencer_api.c
+++ b/source/blender/makesrna/intern/rna_sequencer_api.c
@@ -89,6 +89,8 @@ static Sequence *alloc_generic_sequence(Editing *ed, const char *name, int start
if (file) {
strip->stripdata = se = MEM_callocN(sizeof(StripElem), "stripelem");
BLI_split_dirfile(file, strip->dir, se->name, sizeof(strip->dir), sizeof(se->name));
+
+ BKE_sequence_init_colorspace(seq);
}
else {
strip->stripdata = NULL;
diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c
index 365b80b6d7c..4aefaf991d2 100644
--- a/source/blender/makesrna/intern/rna_tracking.c
+++ b/source/blender/makesrna/intern/rna_tracking.c
@@ -120,8 +120,7 @@ static void rna_tracking_active_object_index_range(PointerRNA *ptr, int *min, in
MovieClip *clip = (MovieClip *)ptr->id.data;
*min = 0;
- *max = clip->tracking.tot_object - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, clip->tracking.tot_object - 1);
}
static PointerRNA rna_tracking_active_track_get(PointerRNA *ptr)
@@ -263,8 +262,7 @@ static void rna_tracking_stabTracks_active_index_range(PointerRNA *ptr, int *min
MovieClip *clip = (MovieClip *)ptr->id.data;
*min = 0;
- *max = clip->tracking.stabilization.tot_track - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, clip->tracking.stabilization.tot_track - 1);
}
static void rna_tracking_flushUpdate(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
@@ -452,7 +450,7 @@ static void rna_trackingObject_remove(MovieTracking *tracking, ReportList *repor
{
MovieTrackingObject *object = object_ptr->data;
if (BKE_tracking_object_delete(tracking, object) == FALSE) {
- BKE_reportf(reports, RPT_ERROR, "MovieTracking '%s' can't be removed", object->name);
+ BKE_reportf(reports, RPT_ERROR, "MovieTracking '%s' cannot be removed", object->name);
return;
}
@@ -574,6 +572,22 @@ static void rna_def_trackingSettings(BlenderRNA *brna)
"Limit speed of tracking to make visual feedback easier "
"(this does not affect the tracking quality)");
+ /* reconstruction success_threshold */
+ prop = RNA_def_property(srna, "reconstruction_success_threshold", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_float_default(prop, 0.001f);
+ RNA_def_property_range(prop, 0, FLT_MAX);
+ RNA_def_property_ui_text(prop, "Success Threshold",
+ "Threshold value of reconstruction error which is still considered successful");
+
+ /* use fallback reconstruction */
+ prop = RNA_def_property(srna, "use_fallback_reconstruction", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_boolean_sdna(prop, NULL, "reconstruction_flag", TRACKING_USE_FALLBACK_RECONSTRUCTION);
+ RNA_def_property_ui_text(prop, "Use Fallback",
+ "Use fallback reconstruction algorithm in cases main reconstruction algorithm failed "
+ "(could give better solution with bad tracks)");
+
/* intrinsics refinement during bundle adjustment */
prop = RNA_def_property(srna, "refine_intrinsics", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "refine_camera_intrinsics");
@@ -623,7 +637,8 @@ static void rna_def_trackingSettings(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_tripod_solver", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_boolean_sdna(prop, NULL, "motion_flag", TRACKING_MOTION_TRIPOD);
- RNA_def_property_ui_text(prop, "Tripod Motion", "Use special solver to track a stable camera position, such as a tripod");
+ RNA_def_property_ui_text(prop, "Tripod Motion",
+ "Use special solver to track a stable camera position, such as a tripod");
/* default_limit_frames */
prop = RNA_def_property(srna, "default_frames_limit", PROP_INT, PROP_NONE);
@@ -663,7 +678,9 @@ static void rna_def_trackingSettings(BlenderRNA *brna)
/* default_use_brute */
prop = RNA_def_property(srna, "use_default_mask", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "default_algorithm_flag", TRACK_ALGORITHM_FLAG_USE_MASK);
- RNA_def_property_ui_text(prop, "Use Mask", "Use a grease pencil datablock as a mask to use only specified areas of pattern when tracking");
+ RNA_def_property_ui_text(prop, "Use Mask",
+ "Use a grease pencil datablock as a mask to use only specified areas of pattern "
+ "when tracking");
RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
/* default_use_normalization */
@@ -1000,7 +1017,9 @@ static void rna_def_trackingTrack(BlenderRNA *brna)
/* use_brute */
prop = RNA_def_property(srna, "use_mask", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "algorithm_flag", TRACK_ALGORITHM_FLAG_USE_MASK);
- RNA_def_property_ui_text(prop, "Use Mask", "Use a grease pencil datablock as a mask to use only specified areas of pattern when tracking");
+ RNA_def_property_ui_text(prop, "Use Mask",
+ "Use a grease pencil datablock as a mask to use only specified areas of pattern "
+ "when tracking");
RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
/* use_normalization */
@@ -1447,7 +1466,8 @@ static void rna_def_trackingDopesheet(BlenderRNA *brna)
{TRACKING_DOPE_SORT_NAME, "NAME", 0, "Name", "Sort channels by their names"},
{TRACKING_DOPE_SORT_LONGEST, "LONGEST", 0, "Longest", "Sort channels by longest tracked segment"},
{TRACKING_DOPE_SORT_TOTAL, "TOTAL", 0, "Total", "Sort channels by overall amount of tracked segments"},
- {TRACKING_DOPE_SORT_AVERAGE_ERROR, "AVERAGE_ERROR", 0, "Average Error", "Sort channels by average reprojection error of tracks after solve"},
+ {TRACKING_DOPE_SORT_AVERAGE_ERROR, "AVERAGE_ERROR", 0, "Average Error",
+ "Sort channels by average reprojection error of tracks after solve"},
{0, NULL, 0, NULL, NULL}
};
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index c49f67d49fe..52953144261 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -3434,7 +3434,7 @@ static void rna_def_userdef_input(BlenderRNA *brna)
/* 3D view */
prop = RNA_def_property(srna, "ndof_view_rotate_method", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
+ RNA_def_property_enum_bitflag_sdna(prop, NULL, "ndof_flag");
RNA_def_property_enum_items(prop, ndof_view_rotation_items);
RNA_def_property_ui_text(prop, "NDOF View Rotation", "Rotation style in the viewport");
diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c
index 116e07073cd..b7895cc0e2d 100644
--- a/source/blender/makesrna/intern/rna_wm_api.c
+++ b/source/blender/makesrna/intern/rna_wm_api.c
@@ -158,7 +158,7 @@ static void rna_KeyMap_item_remove(wmKeyMap *km, ReportList *reports, PointerRNA
wmKeyMapItem *kmi = kmi_ptr->data;
if (WM_keymap_remove_item(km, kmi) == FALSE) {
- BKE_reportf(reports, RPT_ERROR, "KeyMapItem '%s' can't be removed from '%s'", kmi->idname, km->idname);
+ BKE_reportf(reports, RPT_ERROR, "KeyMapItem '%s' cannot be removed from '%s'", kmi->idname, km->idname);
return;
}
@@ -195,7 +195,7 @@ static void rna_KeyConfig_remove(wmWindowManager *wm, ReportList *reports, Point
wmKeyConfig *keyconf = keyconf_ptr->data;
if (WM_keyconfig_remove(wm, keyconf) == FALSE) {
- BKE_reportf(reports, RPT_ERROR, "KeyConfig '%s' can't be removed", keyconf->idname);
+ BKE_reportf(reports, RPT_ERROR, "KeyConfig '%s' cannot be removed", keyconf->idname);
return;
}
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index 323a534c989..7dca4d07b24 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -145,36 +145,40 @@ set(SRC
shader/nodes/node_shader_valToRgb.c
shader/nodes/node_shader_value.c
shader/nodes/node_shader_vectMath.c
+ shader/nodes/node_shader_add_shader.c
+ shader/nodes/node_shader_ambient_occlusion.c
shader/nodes/node_shader_attribute.c
shader/nodes/node_shader_background.c
shader/nodes/node_shader_bsdf_anisotropic.c
shader/nodes/node_shader_bsdf_diffuse.c
- shader/nodes/node_shader_bsdf_glossy.c
shader/nodes/node_shader_bsdf_glass.c
+ shader/nodes/node_shader_bsdf_glossy.c
+ shader/nodes/node_shader_bsdf_refraction.c
shader/nodes/node_shader_bsdf_translucent.c
shader/nodes/node_shader_bsdf_transparent.c
shader/nodes/node_shader_bsdf_velvet.c
shader/nodes/node_shader_bump.c
shader/nodes/node_shader_emission.c
shader/nodes/node_shader_fresnel.c
- shader/nodes/node_shader_layer_weight.c
shader/nodes/node_shader_geometry.c
shader/nodes/node_shader_holdout.c
- shader/nodes/node_shader_volume_transparent.c
- shader/nodes/node_shader_volume_isotropic.c
- shader/nodes/node_shader_light_path.c
+ shader/nodes/node_shader_layer_weight.c
shader/nodes/node_shader_light_falloff.c
- shader/nodes/node_shader_object_info.c
- shader/nodes/node_shader_script.c
- shader/nodes/node_shader_particle_info.c
+ shader/nodes/node_shader_light_path.c
shader/nodes/node_shader_mix_shader.c
- shader/nodes/node_shader_add_shader.c
+ shader/nodes/node_shader_normal_map.c
+ shader/nodes/node_shader_object_info.c
shader/nodes/node_shader_output_lamp.c
shader/nodes/node_shader_output_material.c
shader/nodes/node_shader_output_world.c
- shader/nodes/node_shader_tex_gradient.c
+ shader/nodes/node_shader_particle_info.c
+ shader/nodes/node_shader_script.c
+ shader/nodes/node_shader_tangent.c
+ shader/nodes/node_shader_tex_brick.c
+ shader/nodes/node_shader_tex_checker.c
shader/nodes/node_shader_tex_coord.c
shader/nodes/node_shader_tex_environment.c
+ shader/nodes/node_shader_tex_gradient.c
shader/nodes/node_shader_tex_image.c
shader/nodes/node_shader_tex_magic.c
shader/nodes/node_shader_tex_musgrave.c
@@ -182,8 +186,8 @@ set(SRC
shader/nodes/node_shader_tex_sky.c
shader/nodes/node_shader_tex_voronoi.c
shader/nodes/node_shader_tex_wave.c
- shader/nodes/node_shader_tex_checker.c
- shader/nodes/node_shader_tex_brick.c
+ shader/nodes/node_shader_volume_isotropic.c
+ shader/nodes/node_shader_volume_transparent.c
shader/node_shader_tree.c
shader/node_shader_util.c
diff --git a/source/blender/nodes/NOD_shader.h b/source/blender/nodes/NOD_shader.h
index 66ab15ce29f..e402924c04f 100644
--- a/source/blender/nodes/NOD_shader.h
+++ b/source/blender/nodes/NOD_shader.h
@@ -81,11 +81,15 @@ void register_node_type_sh_layer_weight(struct bNodeTreeType *ttype);
void register_node_type_sh_tex_coord(struct bNodeTreeType *ttype);
void register_node_type_sh_particle_info(struct bNodeTreeType *ttype);
void register_node_type_sh_script(struct bNodeTreeType *ttype);
+void register_node_type_sh_normal_map(struct bNodeTreeType *ttype);
+void register_node_type_sh_tangent(struct bNodeTreeType *ttype);
+void register_node_type_sh_ambient_occlusion(struct bNodeTreeType *ttype);
void register_node_type_sh_background(struct bNodeTreeType *ttype);
void register_node_type_sh_bsdf_diffuse(struct bNodeTreeType *ttype);
void register_node_type_sh_bsdf_glossy(struct bNodeTreeType *ttype);
void register_node_type_sh_bsdf_glass(struct bNodeTreeType *ttype);
+void register_node_type_sh_bsdf_refraction(struct bNodeTreeType *ttype);
void register_node_type_sh_bsdf_translucent(struct bNodeTreeType *ttype);
void register_node_type_sh_bsdf_transparent(struct bNodeTreeType *ttype);
void register_node_type_sh_bsdf_velvet(struct bNodeTreeType *ttype);
diff --git a/source/blender/nodes/NOD_socket.h b/source/blender/nodes/NOD_socket.h
index f41be2bb7d9..b14f7c4e884 100644
--- a/source/blender/nodes/NOD_socket.h
+++ b/source/blender/nodes/NOD_socket.h
@@ -60,6 +60,7 @@ void node_socket_set_default_value_vector(void *default_value, PropertySubType s
void node_socket_set_default_value_rgba(void *default_value, float r, float g, float b, float a);
void node_socket_set_default_value_shader(void *default_value);
void node_socket_set_default_value_mesh(void *default_value);
+void node_socket_set_default_value_string(void *default_value, PropertySubType subtype, const char *value);
struct bNodeSocket *node_add_input_from_template(struct bNodeTree *ntree, struct bNode *node, struct bNodeSocketTemplate *stemp);
struct bNodeSocket *node_add_output_from_template(struct bNodeTree *ntree, struct bNode *node, struct bNodeSocketTemplate *stemp);
diff --git a/source/blender/nodes/composite/nodes/node_composite_keyingscreen.c b/source/blender/nodes/composite/nodes/node_composite_keyingscreen.c
index e16b7e5d885..96e905827cb 100644
--- a/source/blender/nodes/composite/nodes/node_composite_keyingscreen.c
+++ b/source/blender/nodes/composite/nodes/node_composite_keyingscreen.c
@@ -96,21 +96,24 @@ static void compute_gradient_screen(RenderData *rd, NodeKeyingScreenData *keying
int j;
zero_v3(site->color);
- for (j = 0; j < pattern_ibuf->x * pattern_ibuf->y; j++) {
- if (pattern_ibuf->rect_float) {
- add_v3_v3(site->color, &pattern_ibuf->rect_float[4 * j]);
- }
- else {
- unsigned char *rrgb = (unsigned char *)pattern_ibuf->rect;
- site->color[0] += srgb_to_linearrgb((float)rrgb[4 * j + 0] / 255.0f);
- site->color[1] += srgb_to_linearrgb((float)rrgb[4 * j + 1] / 255.0f);
- site->color[2] += srgb_to_linearrgb((float)rrgb[4 * j + 2] / 255.0f);
+ if (pattern_ibuf) {
+ for (j = 0; j < pattern_ibuf->x * pattern_ibuf->y; j++) {
+ if (pattern_ibuf->rect_float) {
+ add_v3_v3(site->color, &pattern_ibuf->rect_float[4 * j]);
+ }
+ else {
+ unsigned char *rrgb = (unsigned char *)pattern_ibuf->rect;
+
+ site->color[0] += srgb_to_linearrgb((float)rrgb[4 * j + 0] / 255.0f);
+ site->color[1] += srgb_to_linearrgb((float)rrgb[4 * j + 1] / 255.0f);
+ site->color[2] += srgb_to_linearrgb((float)rrgb[4 * j + 2] / 255.0f);
+ }
}
- }
- mul_v3_fl(site->color, 1.0f / (pattern_ibuf->x * pattern_ibuf->y));
- IMB_freeImBuf(pattern_ibuf);
+ mul_v3_fl(site->color, 1.0f / (pattern_ibuf->x * pattern_ibuf->y));
+ IMB_freeImBuf(pattern_ibuf);
+ }
site->co[0] = marker->pos[0] * screenbuf->x;
site->co[1] = marker->pos[1] * screenbuf->y;
diff --git a/source/blender/nodes/composite/nodes/node_composite_math.c b/source/blender/nodes/composite/nodes/node_composite_math.c
index c99e12a95b9..5bc67adf5fb 100644
--- a/source/blender/nodes/composite/nodes/node_composite_math.c
+++ b/source/blender/nodes/composite/nodes/node_composite_math.c
@@ -103,7 +103,8 @@ static void do_math(bNode *node, float *out, float *in, float *in2)
out[0] = pow(in[0], in2[0]);
}
else {
- float y_mod_1 = fmod(in2[0], 1);
+ float y_mod_1 = fabsf(fmodf(in2[0], 1.0f));
+
/* if input value is not nearly an integer, fall back to zero, nicer than straight rounding */
if (y_mod_1 > 0.999f || y_mod_1 < 0.001f) {
out[0] = powf(in[0], floorf(in2[0] + 0.5f));
diff --git a/source/blender/nodes/intern/node_socket.c b/source/blender/nodes/intern/node_socket.c
index 8e49484d1eb..0335d295fba 100644
--- a/source/blender/nodes/intern/node_socket.c
+++ b/source/blender/nodes/intern/node_socket.c
@@ -41,6 +41,7 @@
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
+#include "BLI_string.h"
#include "BKE_DerivedMesh.h"
#include "BKE_node.h"
@@ -157,6 +158,20 @@ static bNodeSocketType node_socket_type_mesh = {
/* buttonfunc */ NULL,
};
+/****************** STRING ******************/
+
+static bNodeSocketType node_socket_type_string = {
+ /* type */ SOCK_STRING,
+ /* ui_name */ "String",
+ /* ui_description */ "String",
+ /* ui_icon */ 0,
+ /* ui_color */ {255, 255, 255, 255},
+
+ /* value_structname */ "bNodeSocketValueString",
+ /* value_structsize */ sizeof(bNodeSocketValueString),
+
+ /* buttonfunc */ NULL,
+};
void node_socket_type_init(bNodeSocketType *types[])
{
@@ -169,6 +184,7 @@ void node_socket_type_init(bNodeSocketType *types[])
INIT_TYPE(boolean);
INIT_TYPE(shader);
INIT_TYPE(mesh);
+ INIT_TYPE(string);
#undef INIT_TYPE
}
@@ -218,6 +234,9 @@ void node_socket_init_default_value(int type, void *default_value)
case SOCK_MESH:
node_socket_set_default_value_mesh(default_value);
break;
+ case SOCK_STRING:
+ node_socket_set_default_value_string(default_value, PROP_NONE, (char *)"");
+ break;
}
}
@@ -265,6 +284,13 @@ void node_socket_set_default_value_rgba(void *default_value, float r, float g, f
val->value[3] = a;
}
+void node_socket_set_default_value_string(void *default_value, PropertySubType subtype, const char *value)
+{
+ bNodeSocketValueString *val = default_value;
+ val->subtype = subtype;
+ BLI_strncpy(val->value, value, 1024);//FILE_MAX
+}
+
void node_socket_set_default_value_shader(void *UNUSED(default_value))
{
}
@@ -282,12 +308,14 @@ void node_socket_copy_default_value(int type, void *to_default_value, void *from
bNodeSocketValueBoolean *frombool= (bNodeSocketValueBoolean*)from_default_value;
bNodeSocketValueVector *fromvector= (bNodeSocketValueVector*)from_default_value;
bNodeSocketValueRGBA *fromrgba= (bNodeSocketValueRGBA*)from_default_value;
+ bNodeSocketValueString *fromstring= (bNodeSocketValueString*)from_default_value;
bNodeSocketValueFloat *tofloat= (bNodeSocketValueFloat*)to_default_value;
bNodeSocketValueInt *toint= (bNodeSocketValueInt*)to_default_value;
bNodeSocketValueBoolean *tobool= (bNodeSocketValueBoolean*)to_default_value;
bNodeSocketValueVector *tovector= (bNodeSocketValueVector*)to_default_value;
bNodeSocketValueRGBA *torgba= (bNodeSocketValueRGBA*)to_default_value;
+ bNodeSocketValueString *tostring= (bNodeSocketValueString*)to_default_value;
switch (type) {
case SOCK_FLOAT:
@@ -305,6 +333,9 @@ void node_socket_copy_default_value(int type, void *to_default_value, void *from
case SOCK_RGBA:
*torgba = *fromrgba;
break;
+ case SOCK_STRING:
+ *tostring = *fromstring;
+ break;
}
}
@@ -470,6 +501,9 @@ struct bNodeSocket *node_add_input_from_template(struct bNodeTree *ntree, struct
case SOCK_MESH:
node_socket_set_default_value_mesh(sock->default_value);
break;
+ case SOCK_STRING:
+ node_socket_set_default_value_string(sock->default_value, stemp->subtype, (char *)"");
+ break;
}
return sock;
diff --git a/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c b/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c
new file mode 100644
index 00000000000..7dfefc9ece0
--- /dev/null
+++ b/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c
@@ -0,0 +1,63 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2005 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "../node_shader_util.h"
+
+/* **************** OUTPUT ******************** */
+
+static bNodeSocketTemplate sh_node_ambient_occlusion_in[] = {
+ { SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
+};
+
+static bNodeSocketTemplate sh_node_ambient_occlusion_out[] = {
+ { SOCK_SHADER, 0, N_("AO")},
+ { -1, 0, "" }
+};
+
+static int node_shader_gpu_ambient_occlusion(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+{
+ return GPU_stack_link(mat, "node_ambient_occlusion", in, out, GPU_builtin(GPU_VIEW_NORMAL));
+}
+
+/* node type definition */
+void register_node_type_sh_ambient_occlusion(bNodeTreeType *ttype)
+{
+ static bNodeType ntype;
+
+ node_type_base(ttype, &ntype, SH_NODE_AMBIENT_OCCLUSION, "Ambient Occlusion", NODE_CLASS_SHADER, 0);
+ node_type_compatibility(&ntype, NODE_NEW_SHADING);
+ node_type_socket_templates(&ntype, sh_node_ambient_occlusion_in, sh_node_ambient_occlusion_out);
+ node_type_size(&ntype, 150, 60, 200);
+ node_type_init(&ntype, NULL);
+ node_type_storage(&ntype, "", NULL, NULL);
+ node_type_exec(&ntype, NULL);
+ node_type_gpu(&ntype, node_shader_gpu_ambient_occlusion);
+
+ nodeRegisterType(ttype, &ntype);
+}
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c
index 7e023ff8547..71780e9316e 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c
@@ -31,8 +31,9 @@
static bNodeSocketTemplate sh_node_bsdf_anisotropic_in[] = {
{ SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
- { SOCK_FLOAT, 1, N_("Roughness U"), 0.2f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_FLOAT, 1, N_("Roughness V"), 0.2f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_FLOAT, 1, N_("Roughness"), 0.2f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_FLOAT, 1, N_("Anisotropy"), 0.5f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f},
+ { SOCK_FLOAT, 1, N_("Rotation"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ SOCK_VECTOR, 1, N_("Tangent"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ -1, 0, "" }
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c
new file mode 100644
index 00000000000..99e66e39002
--- /dev/null
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c
@@ -0,0 +1,68 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2005 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "../node_shader_util.h"
+
+/* **************** OUTPUT ******************** */
+
+static bNodeSocketTemplate sh_node_bsdf_refraction_in[] = {
+ { SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+ { SOCK_FLOAT, 1, N_("Roughness"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_FLOAT, 1, N_("IOR"), 1.45f, 0.0f, 0.0f, 0.0f, 1.0f, 1000.0f},
+ { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
+ { -1, 0, "" }
+};
+
+static bNodeSocketTemplate sh_node_bsdf_refraction_out[] = {
+ { SOCK_SHADER, 0, N_("BSDF")},
+ { -1, 0, "" }
+};
+
+static int node_shader_gpu_bsdf_refraction(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+{
+ if (!in[3].link)
+ in[3].link = GPU_builtin(GPU_VIEW_NORMAL);
+
+ return GPU_stack_link(mat, "node_bsdf_refraction", in, out);
+}
+
+/* node type definition */
+void register_node_type_sh_bsdf_refraction(bNodeTreeType *ttype)
+{
+ static bNodeType ntype;
+
+ node_type_base(ttype, &ntype, SH_NODE_BSDF_REFRACTION, "Refraction BSDF", NODE_CLASS_SHADER, NODE_OPTIONS);
+ node_type_compatibility(&ntype, NODE_NEW_SHADING);
+ node_type_socket_templates(&ntype, sh_node_bsdf_refraction_in, sh_node_bsdf_refraction_out);
+ node_type_size(&ntype, 150, 60, 200);
+ node_type_init(&ntype, NULL);
+ node_type_storage(&ntype, "", NULL, NULL);
+ node_type_exec(&ntype, NULL);
+ node_type_gpu(&ntype, node_shader_gpu_bsdf_refraction);
+
+ nodeRegisterType(ttype, &ntype);
+}
diff --git a/source/blender/nodes/shader/nodes/node_shader_math.c b/source/blender/nodes/shader/nodes/node_shader_math.c
index a70134b2325..0b71a3f13b4 100644
--- a/source/blender/nodes/shader/nodes/node_shader_math.c
+++ b/source/blender/nodes/shader/nodes/node_shader_math.c
@@ -137,11 +137,22 @@ bNodeStack **out)
break;
case 10: /* Power */
{
- /* Don't want any imaginary numbers... */
- if ( in[0]->vec[0] >= 0 )
+ /* Only raise negative numbers by full integers */
+ if ( in[0]->vec[0] >= 0 ) {
out[0]->vec[0] = pow(in[0]->vec[0], in[1]->vec[0]);
- else
- out[0]->vec[0] = 0.0;
+ }
+ else {
+ float y_mod_1 = fabsf(fmodf(in[1]->vec[0], 1.0f));
+
+ /* if input value is not nearly an integer, fall back to zero, nicer than straight rounding */
+ if (y_mod_1 > 0.999f || y_mod_1 < 0.001f) {
+ out[0]->vec[0] = powf(in[0]->vec[0], floorf(in[1]->vec[0] + 0.5f));
+ }
+ else {
+ out[0]->vec[0] = 0.0f;
+ }
+ }
+
}
break;
case 11: /* Logarithm */
@@ -214,8 +225,7 @@ static int gpu_shader_math(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUN
case 13:
case 15:
case 16:
- GPU_stack_link(mat, names[node->custom1], NULL, out,
- GPU_socket(&in[0]), GPU_socket(&in[1]));
+ GPU_stack_link(mat, names[node->custom1], in, out);
break;
case 4:
case 5:
@@ -224,10 +234,20 @@ static int gpu_shader_math(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUN
case 8:
case 9:
case 14:
- if (in[0].hasinput || !in[1].hasinput)
- GPU_stack_link(mat, names[node->custom1], NULL, out, GPU_socket(&in[0]));
- else
- GPU_stack_link(mat, names[node->custom1], NULL, out, GPU_socket(&in[1]));
+ if (in[0].hasinput || !in[1].hasinput) {
+ /* use only first item and terminator */
+ GPUNodeStack tmp_in[2];
+ memcpy(&tmp_in[0], &in[0], sizeof(GPUNodeStack));
+ memcpy(&tmp_in[1], &in[2], sizeof(GPUNodeStack));
+ GPU_stack_link(mat, names[node->custom1], tmp_in, out);
+ }
+ else {
+ /* use only second item and terminator */
+ GPUNodeStack tmp_in[2];
+ memcpy(&tmp_in[0], &in[1], sizeof(GPUNodeStack));
+ memcpy(&tmp_in[1], &in[2], sizeof(GPUNodeStack));
+ GPU_stack_link(mat, names[node->custom1], tmp_in, out);
+ }
break;
default:
return 0;
diff --git a/source/blender/nodes/shader/nodes/node_shader_normal_map.c b/source/blender/nodes/shader/nodes/node_shader_normal_map.c
new file mode 100644
index 00000000000..39fd8a5decc
--- /dev/null
+++ b/source/blender/nodes/shader/nodes/node_shader_normal_map.c
@@ -0,0 +1,69 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2005 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "../node_shader_util.h"
+
+/* **************** OUTPUT ******************** */
+
+static bNodeSocketTemplate sh_node_normal_map_in[] = {
+ { SOCK_RGBA, 0, N_("Color"), 0.5f, 0.5f, 1.0f, 1.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
+};
+
+static bNodeSocketTemplate sh_node_normal_map_out[] = {
+ { SOCK_VECTOR, 0, N_("Normal"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
+};
+
+static void node_shader_init_normal_map(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp))
+{
+ NodeShaderNormalMap *attr = MEM_callocN(sizeof(NodeShaderNormalMap), "NodeShaderNormalMap");
+ node->storage = attr;
+}
+
+static int gpu_shader_normal_map(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+{
+ return GPU_stack_link(mat, "node_normal_map", in, out, GPU_builtin(GPU_VIEW_NORMAL));
+}
+
+/* node type definition */
+void register_node_type_sh_normal_map(bNodeTreeType *ttype)
+{
+ static bNodeType ntype;
+
+ node_type_base(ttype, &ntype, SH_NODE_NORMAL_MAP, "Normal Map", NODE_CLASS_OP_VECTOR, NODE_OPTIONS);
+ node_type_compatibility(&ntype, NODE_NEW_SHADING);
+ node_type_socket_templates(&ntype, sh_node_normal_map_in, sh_node_normal_map_out);
+ node_type_size(&ntype, 250, 60, 250);
+ node_type_init(&ntype, node_shader_init_normal_map);
+ node_type_storage(&ntype, "NodeShaderNormalMap", node_free_standard_storage, node_copy_standard_storage);
+ node_type_exec(&ntype, NULL);
+ node_type_gpu(&ntype, gpu_shader_normal_map);
+
+ nodeRegisterType(ttype, &ntype);
+}
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_script.c b/source/blender/nodes/shader/nodes/node_shader_script.c
index 52d39363de6..b5563658a64 100644
--- a/source/blender/nodes/shader/nodes/node_shader_script.c
+++ b/source/blender/nodes/shader/nodes/node_shader_script.c
@@ -46,15 +46,16 @@ static void node_free_script(bNode *node)
NodeShaderScript *nss = node->storage;
if (nss) {
- if (nss->bytecode)
+ if (nss->bytecode) {
MEM_freeN(nss->bytecode);
+ }
- MEM_freeN(nss);
- }
+ if (nss->prop) {
+ IDP_FreeProperty(nss->prop);
+ MEM_freeN(nss->prop);
+ }
- if (nss->prop) {
- IDP_FreeProperty(nss->prop);
- MEM_freeN(nss->prop);
+ MEM_freeN(nss);
}
}
@@ -63,7 +64,7 @@ static void node_copy_script(bNode *orig_node, bNode *new_node)
NodeShaderScript *orig_nss = orig_node->storage;
NodeShaderScript *new_nss = MEM_dupallocN(orig_nss);
- if(orig_nss->bytecode)
+ if (orig_nss->bytecode)
new_nss->bytecode = MEM_dupallocN(orig_nss->bytecode);
if (orig_nss->prop)
diff --git a/source/blender/nodes/shader/nodes/node_shader_tangent.c b/source/blender/nodes/shader/nodes/node_shader_tangent.c
new file mode 100644
index 00000000000..6c0d6d7cd9f
--- /dev/null
+++ b/source/blender/nodes/shader/nodes/node_shader_tangent.c
@@ -0,0 +1,60 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2005 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "../node_shader_util.h"
+
+/* **************** OUTPUT ******************** */
+
+static bNodeSocketTemplate sh_node_tangent_out[] = {
+ { SOCK_VECTOR, 0, N_("Tangent"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
+};
+
+static void node_shader_init_tangent(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp))
+{
+ NodeShaderTangent *attr = MEM_callocN(sizeof(NodeShaderTangent), "NodeShaderTangent");
+ attr->axis = SHD_TANGENT_AXIS_Z;
+ node->storage = attr;
+}
+
+/* node type definition */
+void register_node_type_sh_tangent(bNodeTreeType *ttype)
+{
+ static bNodeType ntype;
+
+ node_type_base(ttype, &ntype, SH_NODE_TANGENT, "Tangent", NODE_CLASS_INPUT, NODE_OPTIONS);
+ node_type_compatibility(&ntype, NODE_NEW_SHADING);
+ node_type_socket_templates(&ntype, NULL, sh_node_tangent_out);
+ node_type_size(&ntype, 150, 60, 200);
+ node_type_init(&ntype, node_shader_init_tangent);
+ node_type_storage(&ntype, "NodeShaderTangent", node_free_standard_storage, node_copy_standard_storage);
+ node_type_exec(&ntype, NULL);
+ node_type_gpu(&ntype, NULL);
+
+ nodeRegisterType(ttype, &ntype);
+}
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_vectMath.c b/source/blender/nodes/shader/nodes/node_shader_vectMath.c
index 2d9f1903c5b..3e00421ddf0 100644
--- a/source/blender/nodes/shader/nodes/node_shader_vectMath.c
+++ b/source/blender/nodes/shader/nodes/node_shader_vectMath.c
@@ -114,14 +114,23 @@ static int gpu_shader_vect_math(GPUMaterial *mat, bNode *node, GPUNodeStack *in,
case 2:
case 3:
case 4:
- GPU_stack_link(mat, names[node->custom1], NULL, out,
- GPU_socket(&in[0]), GPU_socket(&in[1]));
+ GPU_stack_link(mat, names[node->custom1], in, out);
break;
case 5:
- if (in[0].hasinput || !in[1].hasinput)
- GPU_stack_link(mat, names[node->custom1], NULL, out, GPU_socket(&in[0]));
- else
- GPU_stack_link(mat, names[node->custom1], NULL, out, GPU_socket(&in[1]));
+ if (in[0].hasinput || !in[1].hasinput) {
+ /* use only first item and terminator */
+ GPUNodeStack tmp_in[2];
+ memcpy(&tmp_in[0], &in[0], sizeof(GPUNodeStack));
+ memcpy(&tmp_in[1], &in[2], sizeof(GPUNodeStack));
+ GPU_stack_link(mat, names[node->custom1], tmp_in, out);
+ }
+ else {
+ /* use only second item and terminator */
+ GPUNodeStack tmp_in[2];
+ memcpy(&tmp_in[0], &in[1], sizeof(GPUNodeStack));
+ memcpy(&tmp_in[1], &in[2], sizeof(GPUNodeStack));
+ GPU_stack_link(mat, names[node->custom1], tmp_in, out);
+ }
break;
default:
return 0;
diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c
index 45b767c6eda..a10bfef2a8d 100644
--- a/source/blender/python/generic/bgl.c
+++ b/source/blender/python/generic/bgl.c
@@ -520,7 +520,7 @@ static PyObject *Buffer_subscript(Buffer *self, PyObject *item)
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx((void *)item, self->dimensions[0], &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, self->dimensions[0], &start, &stop, &step, &slicelength) < 0)
return NULL;
if (slicelength <= 0) {
@@ -556,7 +556,7 @@ static int Buffer_ass_subscript(Buffer *self, PyObject *item, PyObject *value)
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx((void *)item, self->dimensions[0], &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, self->dimensions[0], &start, &stop, &step, &slicelength) < 0)
return -1;
if (step == 1)
diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c
index b9ef4b056ad..ad97ceb68d4 100644
--- a/source/blender/python/generic/bpy_internal_import.c
+++ b/source/blender/python/generic/bpy_internal_import.c
@@ -1,4 +1,4 @@
-/*
+/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
@@ -56,6 +56,7 @@ static ListBase bpy_import_main_list;
static PyMethodDef bpy_import_meth;
static PyMethodDef bpy_reload_meth;
+static PyObject *imp_reload_orig = NULL;
/* 'builtins' is most likely PyEval_GetBuiltins() */
void bpy_import_init(PyObject *builtins)
@@ -69,7 +70,13 @@ void bpy_import_init(PyObject *builtins)
* XXX, use import hooks */
mod = PyImport_ImportModuleLevel((char *)"imp", NULL, NULL, NULL, 0);
if (mod) {
- PyDict_SetItemString(PyModule_GetDict(mod), "reload", item = PyCFunction_New(&bpy_reload_meth, NULL)); Py_DECREF(item);
+ PyObject *mod_dict = PyModule_GetDict(mod);
+
+ /* blender owns the function */
+ imp_reload_orig = PyDict_GetItemString(mod_dict, "reload");
+ Py_INCREF(imp_reload_orig);
+
+ PyDict_SetItemString(mod_dict, "reload", item = PyCFunction_New(&bpy_reload_meth, NULL)); Py_DECREF(item);
Py_DECREF(mod);
}
else {
@@ -309,7 +316,12 @@ static PyObject *blender_reload(PyObject *UNUSED(self), PyObject *module)
int found = 0;
/* try reimporting from file */
- newmodule = PyImport_ReloadModule(module);
+
+ /* in Py3.3 this just calls imp.reload() which we overwrite, causing recursive calls */
+ //newmodule = PyImport_ReloadModule(module);
+
+ newmodule = PyObject_CallFunctionObjArgs(imp_reload_orig, module, NULL);
+
if (newmodule)
return newmodule;
diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c
index d2890bc046e..529b2e708ad 100644
--- a/source/blender/python/generic/idprop_py_api.c
+++ b/source/blender/python/generic/idprop_py_api.c
@@ -1187,7 +1187,7 @@ static PyObject *BPy_IDArray_subscript(BPy_IDArray *self, PyObject *item)
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx((void *)item, self->prop->len, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, self->prop->len, &start, &stop, &step, &slicelength) < 0)
return NULL;
if (slicelength <= 0) {
@@ -1222,7 +1222,7 @@ static int BPy_IDArray_ass_subscript(BPy_IDArray *self, PyObject *item, PyObject
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx((void *)item, self->prop->len, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, self->prop->len, &start, &stop, &step, &slicelength) < 0)
return -1;
if (step == 1)
diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c
index 333da6cb017..c57caf0683b 100644
--- a/source/blender/python/intern/bpy.c
+++ b/source/blender/python/intern/bpy.c
@@ -32,6 +32,9 @@
#include <Python.h>
+#include "RNA_types.h"
+#include "RNA_access.h"
+
#include "bpy.h"
#include "bpy_util.h"
#include "bpy_rna.h"
@@ -49,8 +52,6 @@
#include "BKE_global.h" /* XXX, G.main only */
#include "BKE_blender.h"
-#include "RNA_access.h"
-
#include "MEM_guardedalloc.h"
/* external util modules */
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 68b6baadd71..eaaced416fe 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -2612,7 +2612,7 @@ static PyObject *pyrna_prop_array_subscript(BPy_PropertyArrayRNA *self, PyObject
int len = pyrna_prop_array_length(self);
Py_ssize_t start, stop, slicelength;
- if (PySlice_GetIndicesEx((void *)key, len, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(key, len, &start, &stop, &step, &slicelength) < 0)
return NULL;
if (slicelength <= 0) {
@@ -2780,7 +2780,7 @@ static int pyrna_prop_array_ass_subscript(BPy_PropertyArrayRNA *self, PyObject *
int len = RNA_property_array_length(&self->ptr, self->prop);
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx((void *)key, len, &start, &stop, &step, &slicelength) < 0) {
+ if (PySlice_GetIndicesEx(key, len, &start, &stop, &step, &slicelength) < 0) {
ret = -1;
}
else if (slicelength <= 0) {
diff --git a/source/blender/python/intern/bpy_util.h b/source/blender/python/intern/bpy_util.h
index 63660b06813..6aa50cf88de 100644
--- a/source/blender/python/intern/bpy_util.h
+++ b/source/blender/python/intern/bpy_util.h
@@ -24,15 +24,20 @@
* \ingroup pythonintern
*/
-
#ifndef __BPY_UTIL_H__
#define __BPY_UTIL_H__
#if PY_VERSION_HEX < 0x03020000
-#error "Python 3.2 or greater is required, you'll need to update your python."
+# error "Python 3.2 or greater is required, you'll need to update your python."
#endif
-#include "RNA_types.h" /* for EnumPropertyItem only */
+#if PY_VERSION_HEX < 0x03030000
+# ifdef _MSC_VER
+# pragma message("Python 3.2 will be deprecated soon, upgrade to Python 3.3.")
+# else
+# warning "Python 3.2 will be deprecated soon, upgrade to Python 3.3."
+# endif
+#endif
struct EnumPropertyItem;
struct ReportList;
@@ -51,4 +56,5 @@ void BPy_SetContext(struct bContext *C);
extern void bpy_context_set(struct bContext *C, PyGILState_STATE *gilstate);
extern void bpy_context_clear(struct bContext *C, PyGILState_STATE *gilstate);
-#endif
+
+#endif /* __BPY_UTIL_H__ */
diff --git a/source/blender/python/mathutils/mathutils_Color.c b/source/blender/python/mathutils/mathutils_Color.c
index 747a23a719d..f16b488f9d0 100644
--- a/source/blender/python/mathutils/mathutils_Color.c
+++ b/source/blender/python/mathutils/mathutils_Color.c
@@ -306,7 +306,7 @@ static PyObject *Color_subscript(ColorObject *self, PyObject *item)
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx((void *)item, COLOR_SIZE, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, COLOR_SIZE, &start, &stop, &step, &slicelength) < 0)
return NULL;
if (slicelength <= 0) {
@@ -342,7 +342,7 @@ static int Color_ass_subscript(ColorObject *self, PyObject *item, PyObject *valu
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx((void *)item, COLOR_SIZE, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, COLOR_SIZE, &start, &stop, &step, &slicelength) < 0)
return -1;
if (step == 1)
diff --git a/source/blender/python/mathutils/mathutils_Euler.c b/source/blender/python/mathutils/mathutils_Euler.c
index 3592e1084fb..829d3ee27e1 100644
--- a/source/blender/python/mathutils/mathutils_Euler.c
+++ b/source/blender/python/mathutils/mathutils_Euler.c
@@ -497,7 +497,7 @@ static PyObject *Euler_subscript(EulerObject *self, PyObject *item)
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx((void *)item, EULER_SIZE, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, EULER_SIZE, &start, &stop, &step, &slicelength) < 0)
return NULL;
if (slicelength <= 0) {
@@ -534,7 +534,7 @@ static int Euler_ass_subscript(EulerObject *self, PyObject *item, PyObject *valu
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx((void *)item, EULER_SIZE, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, EULER_SIZE, &start, &stop, &step, &slicelength) < 0)
return -1;
if (step == 1)
diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c
index b9f0ce9ad96..64112024dd1 100644
--- a/source/blender/python/mathutils/mathutils_Matrix.c
+++ b/source/blender/python/mathutils/mathutils_Matrix.c
@@ -2087,7 +2087,7 @@ static PyObject *Matrix_subscript(MatrixObject *self, PyObject *item)
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx((void *)item, self->num_row, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, self->num_row, &start, &stop, &step, &slicelength) < 0)
return NULL;
if (slicelength <= 0) {
@@ -2123,7 +2123,7 @@ static int Matrix_ass_subscript(MatrixObject *self, PyObject *item, PyObject *va
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx((void *)item, self->num_row, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, self->num_row, &start, &stop, &step, &slicelength) < 0)
return -1;
if (step == 1)
@@ -2626,7 +2626,7 @@ static PyObject *MatrixAccess_subscript(MatrixAccessObject *self, PyObject *item
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx((void *)item, MatrixAccess_len(self), &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, MatrixAccess_len(self), &start, &stop, &step, &slicelength) < 0)
return NULL;
if (slicelength <= 0) {
diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c
index b9aba995973..cda39932610 100644
--- a/source/blender/python/mathutils/mathutils_Quaternion.c
+++ b/source/blender/python/mathutils/mathutils_Quaternion.c
@@ -670,7 +670,7 @@ static PyObject *Quaternion_subscript(QuaternionObject *self, PyObject *item)
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx((void *)item, QUAT_SIZE, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, QUAT_SIZE, &start, &stop, &step, &slicelength) < 0)
return NULL;
if (slicelength <= 0) {
@@ -707,7 +707,7 @@ static int Quaternion_ass_subscript(QuaternionObject *self, PyObject *item, PyOb
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx((void *)item, QUAT_SIZE, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, QUAT_SIZE, &start, &stop, &step, &slicelength) < 0)
return -1;
if (step == 1)
diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c
index 06d7f3fec51..19be2b6a62e 100644
--- a/source/blender/python/mathutils/mathutils_Vector.c
+++ b/source/blender/python/mathutils/mathutils_Vector.c
@@ -1976,7 +1976,7 @@ static PyObject *Vector_subscript(VectorObject *self, PyObject *item)
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx((void *)item, self->size, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, self->size, &start, &stop, &step, &slicelength) < 0)
return NULL;
if (slicelength <= 0) {
@@ -2012,7 +2012,7 @@ static int Vector_ass_subscript(VectorObject *self, PyObject *item, PyObject *va
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx((void *)item, self->size, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, self->size, &start, &stop, &step, &slicelength) < 0)
return -1;
if (step == 1)
diff --git a/source/blender/quicktime/quicktime_export.h b/source/blender/quicktime/quicktime_export.h
index cef4cb8c2a6..a3469ddafde 100644
--- a/source/blender/quicktime/quicktime_export.h
+++ b/source/blender/quicktime/quicktime_export.h
@@ -87,8 +87,8 @@ void makeqtstring(struct RenderData *rd, char *string); //for playanim.c
-#if (defined(USE_QTKIT) && defined(MAC_OS_X_VERSION_10_6) && __LP64__)
-//Include the quicktime codec types constants that are missing in QTKitDefines.h in 10.6 / 64bit
+#if (defined(USE_QTKIT) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 && __LP64__)
+//Include the quicktime codec types constants that are missing in QTKitDefines.h
enum {
kRawCodecType = 'raw ',
kCinepakCodecType = 'cvid',
diff --git a/source/blender/render/extern/include/RE_engine.h b/source/blender/render/extern/include/RE_engine.h
index 20024eab633..1331c287d7c 100644
--- a/source/blender/render/extern/include/RE_engine.h
+++ b/source/blender/render/extern/include/RE_engine.h
@@ -115,6 +115,7 @@ void RE_engine_end_result(RenderEngine *engine, struct RenderResult *result, int
int RE_engine_test_break(RenderEngine *engine);
void RE_engine_update_stats(RenderEngine *engine, const char *stats, const char *info);
void RE_engine_update_progress(RenderEngine *engine, float progress);
+void RE_engine_update_memory_stats(RenderEngine *engine, float mem_used, float mem_peak);
void RE_engine_report(RenderEngine *engine, int type, const char *msg);
int RE_engine_render(struct Render *re, int do_all);
diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h
index 9525d1dd8f1..f5c77d49c21 100644
--- a/source/blender/render/extern/include/RE_pipeline.h
+++ b/source/blender/render/extern/include/RE_pipeline.h
@@ -148,6 +148,7 @@ typedef struct RenderStats {
double starttime, lastframetime;
const char *infostr, *statstr;
char scene_name[MAX_ID_NAME - 2];
+ float mem_used, mem_peak;
} RenderStats;
/* *********************** API ******************** */
diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h
index 5e4417a3bc6..7f785eb3d8b 100644
--- a/source/blender/render/intern/include/render_types.h
+++ b/source/blender/render/intern/include/render_types.h
@@ -145,8 +145,6 @@ struct Render
/* final picture width and height (within disprect) */
int rectx, recty;
- /* real maximum amount of xparts/yparts after correction for minimum */
- int xparts, yparts;
/* real maximum size of parts after correction for minimum
* partx*xparts can be larger than rectx, in that case last part is smaller */
int partx, party;
diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c
index 6d092f75663..bb7c1bdf94b 100644
--- a/source/blender/render/intern/source/convertblender.c
+++ b/source/blender/render/intern/source/convertblender.c
@@ -4356,7 +4356,7 @@ static void finalize_render_object(Render *re, ObjectRen *obr, int timeoffset)
/* compute average bounding box of strandpoint itself (width) */
if (obr->strandbuf->flag & R_STRAND_B_UNITS)
- obr->strandbuf->maxwidth= MAX2(obr->strandbuf->ma->strand_sta, obr->strandbuf->ma->strand_end);
+ obr->strandbuf->maxwidth = max_ff(obr->strandbuf->ma->strand_sta, obr->strandbuf->ma->strand_end);
else
obr->strandbuf->maxwidth= 0.0f;
diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c
index 558ba8fe062..28f70211a9c 100644
--- a/source/blender/render/intern/source/envmap.c
+++ b/source/blender/render/intern/source/envmap.c
@@ -148,7 +148,8 @@ static Render *envmap_render_copy(Render *re, EnvMap *env)
envre->r.mode &= ~(R_BORDER | R_PANORAMA | R_ORTHO | R_MBLUR);
envre->r.layers.first = envre->r.layers.last = NULL;
envre->r.filtertype = 0;
- envre->r.xparts = envre->r.yparts = 2;
+ envre->r.tilex = envre->r.xsch / 2;
+ envre->r.tiley = envre->r.ysch / 2;
envre->r.size = 100;
envre->r.yasp = envre->r.xasp = 1;
diff --git a/source/blender/render/intern/source/external_engine.c b/source/blender/render/intern/source/external_engine.c
index 076cad05c84..e2f347c05f1 100644
--- a/source/blender/render/intern/source/external_engine.c
+++ b/source/blender/render/intern/source/external_engine.c
@@ -290,13 +290,23 @@ void RE_engine_update_progress(RenderEngine *engine, float progress)
}
}
+void RE_engine_update_memory_stats(RenderEngine *engine, float mem_used, float mem_peak)
+{
+ Render *re = engine->re;
+
+ if (re) {
+ re->i.mem_used = mem_used;
+ re->i.mem_peak = mem_peak;
+ }
+}
+
void RE_engine_report(RenderEngine *engine, int type, const char *msg)
{
Render *re = engine->re;
if (re)
BKE_report(engine->re->reports, type, msg);
- else if(engine->reports)
+ else if (engine->reports)
BKE_report(engine->reports, type, msg);
}
diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c
index 2b564a09024..b2cf8db7995 100644
--- a/source/blender/render/intern/source/initrender.c
+++ b/source/blender/render/intern/source/initrender.c
@@ -555,31 +555,17 @@ void initparts(Render *re, int do_crop)
xmaxb = re->disprect.xmax;
ymaxb = re->disprect.ymax;
- xparts = re->r.xparts;
- yparts = re->r.yparts;
-
- /* minimum part size */
- if (re->r.mode & R_PANORAMA) {
- if (ceil(re->rectx / (float)xparts) < 8)
- xparts = 1 + re->rectx / 8;
- }
- else {
- if (ceil(re->rectx / (float)xparts) < 64)
- xparts = 1 + re->rectx / 64;
- }
-
- if (ceil(re->recty / (float)yparts) < 64)
- yparts = 1 + re->recty / 64;
-
/* part size */
- partx = ceil(re->rectx / (float)xparts);
- party = ceil(re->recty / (float)yparts);
+ partx = min_ii(re->r.tilex, re->rectx);
+ party = min_ii(re->r.tiley, re->recty);
- re->xparts = xparts;
- re->yparts = yparts;
re->partx = partx;
re->party = party;
+ /* part count */
+ xparts = (re->rectx + partx - 1) / partx;
+ yparts = (re->recty + party - 1) / party;
+
/* calculate rotation factor of 1 pixel */
if (re->r.mode & R_PANORAMA)
re->panophi = panorama_pixel_rot(re);
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index 8f1037ec051..9dab18b3c2c 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -680,6 +680,7 @@ float panorama_pixel_rot(Render *re)
{
float psize, phi, xfac;
float borderfac = (float)BLI_rcti_size_x(&re->disprect) / (float)re->winx;
+ int xparts = (re->rectx + re->partx - 1) / re->partx;
/* size of 1 pixel mapped to viewplane coords */
psize = BLI_rctf_size_x(&re->viewplane) / (float)re->winx;
@@ -687,7 +688,7 @@ float panorama_pixel_rot(Render *re)
phi = atan(psize / re->clipsta);
/* correction factor for viewplane shifting, first calculate how much the viewplane angle is */
- xfac = borderfac * BLI_rctf_size_x(&re->viewplane) / (float)re->xparts;
+ xfac = borderfac * BLI_rctf_size_x(&re->viewplane) / (float)xparts;
xfac = atan(0.5f * xfac / re->clipsta);
/* and how much the same viewplane angle is wrapped */
psize = 0.5f * phi * ((float)re->partx);
@@ -2596,8 +2597,8 @@ int RE_WriteEnvmapResult(struct ReportList *reports, Scene *scene, EnvMap *env,
if (env->type == ENV_CUBE) {
for (i = 0; i < 12; i += 2) {
- maxX = MAX2(maxX, layout[i] + 1);
- maxY = MAX2(maxY, layout[i + 1] + 1);
+ maxX = max_ii(maxX, (int)layout[i] + 1);
+ maxY = max_ii(maxY, (int)layout[i + 1] + 1);
}
ibuf = IMB_allocImBuf(maxX * dx, maxY * dx, 24, IB_rectfloat);
diff --git a/source/blender/render/intern/source/renderdatabase.c b/source/blender/render/intern/source/renderdatabase.c
index 886f266b22f..7a7602dcce2 100644
--- a/source/blender/render/intern/source/renderdatabase.c
+++ b/source/blender/render/intern/source/renderdatabase.c
@@ -1184,6 +1184,7 @@ static int panotestclip(Render *re, int do_pano, float *v)
/* to be used for halos en infos */
float abs4;
short c=0;
+ int xparts = (re->rectx + re->partx - 1) / re->partx;
if (do_pano == FALSE) {
return testclip(v);
@@ -1197,7 +1198,7 @@ static int panotestclip(Render *re, int do_pano, float *v)
if ( v[1]>abs4) c+=4;
else if ( v[1]< -abs4) c+=8;
- abs4*= re->xparts;
+ abs4*= xparts;
if ( v[0]>abs4) c+=2;
else if ( v[0]< -abs4) c+=1;
diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c
index c37f48bc329..a7f6b40981d 100644
--- a/source/blender/render/intern/source/shadbuf.c
+++ b/source/blender/render/intern/source/shadbuf.c
@@ -637,7 +637,7 @@ static void shadowbuf_autoclip(Render *re, LampRen *lar)
maxtotvert= 0;
for (obr=re->objecttable.first; obr; obr=obr->next)
- maxtotvert= MAX2(obr->totvert, maxtotvert);
+ maxtotvert = max_ii(obr->totvert, maxtotvert);
clipflag= MEM_callocN(sizeof(char)*maxtotvert, "autoclipflag");
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index b9a4e720230..c53c4dca74c 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -106,7 +106,7 @@ int WM_homefile_read_exec(struct bContext *C, struct wmOperator *op);
int WM_homefile_read(struct bContext *C, struct ReportList *reports, short from_memory);
int WM_homefile_write_exec(struct bContext *C, struct wmOperator *op);
void WM_file_read(struct bContext *C, const char *filepath, struct ReportList *reports);
-int WM_file_write(struct bContext *C, const char *target, int fileflags, struct ReportList *reports, int copy);
+int WM_file_write(struct bContext *C, const char *target, int fileflags, struct ReportList *reports);
void WM_autosave_init(struct wmWindowManager *wm);
/* mouse cursors */
@@ -320,9 +320,9 @@ enum {
WM_JOB_SUSPEND = (1 << 3)
};
-/* identifying jobs by owner alone is unreliable, this isnt saved, order can change */
+/* identifying jobs by owner alone is unreliable, this isnt saved, order can change (keep 0 for 'any') */
enum {
- WM_JOB_TYPE_ANY = -1,
+ WM_JOB_TYPE_ANY = 0,
WM_JOB_TYPE_COMPOSITE,
WM_JOB_TYPE_RENDER,
WM_JOB_TYPE_RENDER_PREVIEW, /* UI preview */
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c
index 66bb321e832..d7285ec4380 100644
--- a/source/blender/windowmanager/intern/wm_draw.c
+++ b/source/blender/windowmanager/intern/wm_draw.c
@@ -84,7 +84,7 @@ static void wm_paintcursor_draw(bContext *C, ARegion *ar)
bScreen *screen = win->screen;
wmPaintCursor *pc;
- if (screen->subwinactive == ar->swinid) {
+ if (ar->swinid && screen->subwinactive == ar->swinid) {
for (pc = wm->paintcursors.first; pc; pc = pc->next) {
if (pc->poll == NULL || pc->poll(C)) {
ARegion *ar_other = CTX_wm_region(C);
@@ -631,7 +631,7 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win)
if (paintcursor && wm->paintcursors.first) {
for (sa = screen->areabase.first; sa; sa = sa->next) {
for (ar = sa->regionbase.first; ar; ar = ar->next) {
- if (ar->swinid == screen->subwinactive) {
+ if (ar->swinid && ar->swinid == screen->subwinactive) {
CTX_wm_area_set(C, sa);
CTX_wm_region_set(C, ar);
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index fee94b95a6a..7cfa3ce9396 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -2731,47 +2731,45 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
event = *evt;
switch (type) {
- /* mouse move */
+ /* mouse move, also to inactive window (X11 does this) */
case GHOST_kEventCursorMove:
{
- if (win->active) {
- GHOST_TEventCursorData *cd = customdata;
- wmEvent *lastevent = win->queue.last;
- int cx, cy;
-
- GHOST_ScreenToClient(win->ghostwin, cd->x, cd->y, &cx, &cy);
- evt->x = cx;
- evt->y = (win->sizey - 1) - cy;
-
- event.x = evt->x;
- event.y = evt->y;
+ GHOST_TEventCursorData *cd = customdata;
+ wmEvent *lastevent = win->queue.last;
+ int cx, cy;
+
+ GHOST_ScreenToClient(win->ghostwin, cd->x, cd->y, &cx, &cy);
+ evt->x = cx;
+ evt->y = (win->sizey - 1) - cy;
+
+ event.x = evt->x;
+ event.y = evt->y;
- event.type = MOUSEMOVE;
+ event.type = MOUSEMOVE;
- /* some painting operators want accurate mouse events, they can
- * handle in between mouse move moves, others can happily ignore
- * them for better performance */
- if (lastevent && lastevent->type == MOUSEMOVE)
- lastevent->type = INBETWEEN_MOUSEMOVE;
+ /* some painting operators want accurate mouse events, they can
+ * handle in between mouse move moves, others can happily ignore
+ * them for better performance */
+ if (lastevent && lastevent->type == MOUSEMOVE)
+ lastevent->type = INBETWEEN_MOUSEMOVE;
- update_tablet_data(win, &event);
- wm_event_add(win, &event);
+ update_tablet_data(win, &event);
+ wm_event_add(win, &event);
+
+ /* also add to other window if event is there, this makes overdraws disappear nicely */
+ /* it remaps mousecoord to other window in event */
+ owin = wm_event_cursor_other_windows(wm, win, &event);
+ if (owin) {
+ wmEvent oevent = *(owin->eventstate);
- /* also add to other window if event is there, this makes overdraws disappear nicely */
- /* it remaps mousecoord to other window in event */
- owin = wm_event_cursor_other_windows(wm, win, &event);
- if (owin) {
- wmEvent oevent = *(owin->eventstate);
-
- oevent.x = owin->eventstate->x = event.x;
- oevent.y = owin->eventstate->y = event.y;
- oevent.type = MOUSEMOVE;
-
- update_tablet_data(owin, &oevent);
- wm_event_add(owin, &oevent);
- }
+ oevent.x = owin->eventstate->x = event.x;
+ oevent.y = owin->eventstate->y = event.y;
+ oevent.type = MOUSEMOVE;
+ update_tablet_data(owin, &oevent);
+ wm_event_add(owin, &oevent);
}
+
break;
}
case GHOST_kEventTrackpad:
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 780117c73aa..1c168bc5ac5 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -765,7 +765,7 @@ int write_crash_blend(void)
}
}
-int WM_file_write(bContext *C, const char *target, int fileflags, ReportList *reports, int copy)
+int WM_file_write(bContext *C, const char *target, int fileflags, ReportList *reports)
{
Library *li;
int len;
@@ -821,7 +821,7 @@ int WM_file_write(bContext *C, const char *target, int fileflags, ReportList *re
fileflags |= G_FILE_HISTORY; /* write file history */
if (BLO_write_file(CTX_data_main(C), filepath, fileflags, reports, thumb)) {
- if (!copy) {
+ if (!(fileflags & G_FILE_SAVE_COPY)) {
G.relbase_valid = 1;
BLI_strncpy(G.main->name, filepath, sizeof(G.main->name)); /* is guaranteed current file */
diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c
index 42d721327b6..f5c83d48cb9 100644
--- a/source/blender/windowmanager/intern/wm_jobs.c
+++ b/source/blender/windowmanager/intern/wm_jobs.c
@@ -131,31 +131,34 @@ struct wmJob {
};
/* finds:
- * 1st priority: job with same owner and name
- * 2nd priority: job with same owner
+ * if type, compare for it, otherwise any matching job
*/
-static wmJob *wm_job_find(wmWindowManager *wm, void *owner, const char *name)
+static wmJob *wm_job_find(wmWindowManager *wm, void *owner, const int job_type)
{
- wmJob *wm_job, *found = NULL;
+ wmJob *wm_job;
for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next)
if (wm_job->owner == owner) {
- found = wm_job;
- if (name && strcmp(wm_job->name, name) == 0)
+
+ if (job_type) {
+ if ( wm_job->job_type == job_type)
+ return wm_job;
+ }
+ else
return wm_job;
}
- return found;
+ return NULL;
}
/* ******************* public API ***************** */
/* returns current or adds new job, but doesnt run it */
-/* every owner only gets a single job, adding a new one will stop running stop and
+/* every owner only gets a single job, adding a new one will stop running job and
* when stopped it starts the new one */
wmJob *WM_jobs_get(wmWindowManager *wm, wmWindow *win, void *owner, const char *name, int flag, int job_type)
{
- wmJob *wm_job = wm_job_find(wm, owner, name);
+ wmJob *wm_job = wm_job_find(wm, owner, job_type);
if (wm_job == NULL) {
wm_job = MEM_callocN(sizeof(wmJob), "new job");
@@ -167,7 +170,11 @@ wmJob *WM_jobs_get(wmWindowManager *wm, wmWindow *win, void *owner, const char *
wm_job->job_type = job_type;
BLI_strncpy(wm_job->name, name, sizeof(wm_job->name));
}
+ /* else: a running job, be careful */
+ /* prevent creating a job with an invalid type */
+ BLI_assert(wm_job->job_type != WM_JOB_TYPE_ANY);
+
return wm_job;
}
@@ -192,7 +199,7 @@ int WM_jobs_test(wmWindowManager *wm, void *owner, int job_type)
float WM_jobs_progress(wmWindowManager *wm, void *owner)
{
- wmJob *wm_job = wm_job_find(wm, owner, NULL);
+ wmJob *wm_job = wm_job_find(wm, owner, WM_JOB_TYPE_ANY);
if (wm_job && wm_job->flag & WM_JOB_PROGRESS)
return wm_job->progress;
@@ -202,7 +209,7 @@ float WM_jobs_progress(wmWindowManager *wm, void *owner)
char *WM_jobs_name(wmWindowManager *wm, void *owner)
{
- wmJob *wm_job = wm_job_find(wm, owner, NULL);
+ wmJob *wm_job = wm_job_find(wm, owner, WM_JOB_TYPE_ANY);
if (wm_job)
return wm_job->name;
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 2ef33aa5964..054e48f0bfb 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -72,6 +72,7 @@
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_screen.h" /* BKE_ST_MAXNAME */
+#include "BKE_utildefines.h"
#include "BKE_idcode.h"
@@ -903,6 +904,8 @@ void WM_operator_properties_filesel(wmOperatorType *ot, int filter, short type,
prop = RNA_def_boolean(ot->srna, "filter_blender", (filter & BLENDERFILE), "Filter .blend files", "");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
+ prop = RNA_def_boolean(ot->srna, "filter_backup", (filter & BLENDERFILE_BACKUP), "Filter .blend files", "");
+ RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
prop = RNA_def_boolean(ot->srna, "filter_image", (filter & IMAGEFILE), "Filter image files", "");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
prop = RNA_def_boolean(ot->srna, "filter_movie", (filter & MOVIEFILE), "Filter movie files", "");
@@ -1332,6 +1335,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
int i;
MenuType *mt = WM_menutype_find("USERPREF_MT_splash", TRUE);
char url[96];
+ char file [FILE_MAX];
#ifndef WITH_HEADLESS
extern char datatoc_splash_png[];
@@ -1419,7 +1423,11 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
uiItemL(col, IFACE_("Recent"), ICON_NONE);
for (recent = G.recent_files.first, i = 0; (i < 5) && (recent); recent = recent->next, i++) {
- uiItemStringO(col, BLI_path_basename(recent->filepath), ICON_FILE_BLEND, "WM_OT_open_mainfile", "filepath", recent->filepath);
+ BLI_split_file_part(recent->filepath, file, sizeof(file));
+ if (BLO_has_bfile_extension(file))
+ uiItemStringO(col, BLI_path_basename(recent->filepath), ICON_FILE_BLEND, "WM_OT_open_mainfile", "filepath", recent->filepath);
+ else
+ uiItemStringO(col, BLI_path_basename(recent->filepath), ICON_FILE_BACKUP, "WM_OT_open_mainfile", "filepath", recent->filepath);
}
uiItemS(col);
@@ -2070,7 +2078,6 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op)
{
char path[FILE_MAX];
int fileflags;
- int copy = 0;
save_set_compress(op);
@@ -2080,29 +2087,27 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op)
BLI_strncpy(path, G.main->name, FILE_MAX);
untitled(path);
}
-
- if (RNA_struct_property_is_set(op->ptr, "copy"))
- copy = RNA_boolean_get(op->ptr, "copy");
fileflags = G.fileflags;
/* set compression flag */
- if (RNA_boolean_get(op->ptr, "compress")) fileflags |= G_FILE_COMPRESS;
- else fileflags &= ~G_FILE_COMPRESS;
- if (RNA_boolean_get(op->ptr, "relative_remap")) fileflags |= G_FILE_RELATIVE_REMAP;
- else fileflags &= ~G_FILE_RELATIVE_REMAP;
+ BKE_BIT_TEST_SET(fileflags, RNA_boolean_get(op->ptr, "compress"),
+ G_FILE_COMPRESS);
+ BKE_BIT_TEST_SET(fileflags, RNA_boolean_get(op->ptr, "relative_remap"),
+ G_FILE_RELATIVE_REMAP);
+ BKE_BIT_TEST_SET(fileflags,
+ (RNA_struct_property_is_set(op->ptr, "copy") &&
+ RNA_boolean_get(op->ptr, "copy")),
+ G_FILE_SAVE_COPY);
+
#ifdef USE_BMESH_SAVE_AS_COMPAT
- /* property only exists for 'Save As' */
- if (RNA_struct_find_property(op->ptr, "use_mesh_compat")) {
- if (RNA_boolean_get(op->ptr, "use_mesh_compat")) fileflags |= G_FILE_MESH_COMPAT;
- else fileflags &= ~G_FILE_MESH_COMPAT;
- }
- else {
- fileflags &= ~G_FILE_MESH_COMPAT;
- }
+ BKE_BIT_TEST_SET(fileflags,
+ (RNA_struct_find_property(op->ptr, "use_mesh_compat") &&
+ RNA_boolean_get(op->ptr, "use_mesh_compat")),
+ G_FILE_MESH_COMPAT);
#endif
- if (WM_file_write(C, path, fileflags, op->reports, copy) != 0)
+ if (WM_file_write(C, path, fileflags, op->reports) != 0)
return OPERATOR_CANCELLED;
WM_event_add_notifier(C, NC_WM | ND_FILESAVE, NULL);
diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c
index 41741dd9a5b..2d37b0e1401 100644
--- a/source/blenderplayer/bad_level_call_stubs/stubs.c
+++ b/source/blenderplayer/bad_level_call_stubs/stubs.c
@@ -463,6 +463,7 @@ void RE_engine_report(struct RenderEngine *engine, int type, const char *msg) {}
ListBase R_engines = {NULL, NULL};
void RE_engine_free(struct RenderEngine *engine) {}
struct RenderEngineType *RE_engines_find(const char *idname) { return NULL; }
+void RE_engine_update_memory_stats(struct RenderEngine *engine, float mem_used, float mem_peak) {};
/* python */
struct wmOperatorType *WM_operatortype_find(const char *idname, int quiet) {return (struct wmOperatorType *) NULL;}
diff --git a/source/gameengine/BlenderRoutines/CMakeLists.txt b/source/gameengine/BlenderRoutines/CMakeLists.txt
index a053e069153..9a47d223f76 100644
--- a/source/gameengine/BlenderRoutines/CMakeLists.txt
+++ b/source/gameengine/BlenderRoutines/CMakeLists.txt
@@ -33,6 +33,7 @@ set(INC_SYS
../../../extern/bullet2/src
${PTHREADS_INCLUDE_DIRS}
${GLEW_INCLUDE_PATH}
+ ${BOOST_INCLUDE_DIR}
)
set(SRC
diff --git a/source/gameengine/BlenderRoutines/SConscript b/source/gameengine/BlenderRoutines/SConscript
index 998396aba7c..04dbe27337f 100644
--- a/source/gameengine/BlenderRoutines/SConscript
+++ b/source/gameengine/BlenderRoutines/SConscript
@@ -34,6 +34,7 @@ if env['WITH_BF_CXX_GUARDEDALLOC']:
incs += ' ' + env['BF_BULLET_INC']
incs += ' ' + env['BF_OPENGL_INC']
+incs += ' ' + env['BF_BOOST_INC']
if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'):
incs += ' ' + env['BF_PTHREADS_INC']
diff --git a/source/gameengine/Converter/CMakeLists.txt b/source/gameengine/Converter/CMakeLists.txt
index 7b801fd4ffb..e9dd97f3821 100644
--- a/source/gameengine/Converter/CMakeLists.txt
+++ b/source/gameengine/Converter/CMakeLists.txt
@@ -59,7 +59,7 @@ set(INC_SYS
../../../extern/recastnavigation/Detour/Include
../../../extern/Eigen3
${PTHREADS_INCLUDE_DIRS}
-
+ ${BOOST_INCLUDE_DIR}
)
set(SRC
diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp
index 24d321730eb..06399642edd 100644
--- a/source/gameengine/Converter/KX_ConvertActuators.cpp
+++ b/source/gameengine/Converter/KX_ConvertActuators.cpp
@@ -387,7 +387,7 @@ void BL_ConvertActuators(const char* maggiename,
{
bSound* sound = soundact->sound;
bool is3d = soundact->flag & ACT_SND_3D_SOUND ? true : false;
- AUD_Reference<AUD_IFactory> snd_sound;
+ boost::shared_ptr<AUD_IFactory> snd_sound;
KX_3DSoundSettings settings;
settings.cone_inner_angle = soundact->sound3D.cone_inner_angle;
settings.cone_outer_angle = soundact->sound3D.cone_outer_angle;
@@ -406,21 +406,21 @@ void BL_ConvertActuators(const char* maggiename,
}
else
{
- snd_sound = *reinterpret_cast<AUD_Reference<AUD_IFactory>*>(sound->playback_handle);
+ snd_sound = *reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(sound->playback_handle);
// if sound shall be 3D but isn't mono, we have to make it mono!
if (is3d)
{
try
{
- AUD_Reference<AUD_IReader> reader = snd_sound->createReader();
+ boost::shared_ptr<AUD_IReader> reader = snd_sound->createReader();
if (reader->getSpecs().channels != AUD_CHANNELS_MONO)
{
AUD_DeviceSpecs specs;
specs.channels = AUD_CHANNELS_MONO;
specs.rate = AUD_RATE_INVALID;
specs.format = AUD_FORMAT_INVALID;
- snd_sound = new AUD_ChannelMapperFactory(snd_sound, specs);
+ snd_sound = boost::shared_ptr<AUD_IFactory>(new AUD_ChannelMapperFactory(snd_sound, specs));
}
}
catch(AUD_Exception&)
diff --git a/source/gameengine/Converter/SConscript b/source/gameengine/Converter/SConscript
index e95ae5448fb..bfd44dc90fc 100644
--- a/source/gameengine/Converter/SConscript
+++ b/source/gameengine/Converter/SConscript
@@ -24,6 +24,7 @@ incs += ' #extern/recastnavigation/Detour/Include'
incs += ' #extern/Eigen3'
incs += ' ' + env['BF_BULLET_INC']
+incs += ' ' + env['BF_BOOST_INC']
if env['BF_DEBUG']:
if env['OURPLATFORM'] in ('win32-mingw', 'win32-vc', 'win64-vc', 'win64-mingw'):
diff --git a/source/gameengine/Ketsji/CMakeLists.txt b/source/gameengine/Ketsji/CMakeLists.txt
index b42c2c27075..2eada3e5071 100644
--- a/source/gameengine/Ketsji/CMakeLists.txt
+++ b/source/gameengine/Ketsji/CMakeLists.txt
@@ -57,6 +57,7 @@ set(INC
set(INC_SYS
${PTHREADS_INCLUDE_DIRS}
${GLEW_INCLUDE_PATH}
+ ${BOOST_INCLUDE_DIR}
../../../extern/recastnavigation/Recast/Include
../../../extern/recastnavigation/Detour/Include
)
@@ -74,6 +75,7 @@ set(SRC
KX_Camera.cpp
KX_CameraActuator.cpp
KX_CameraIpoSGController.cpp
+ KX_CharacterWrapper.cpp
KX_ConstraintActuator.cpp
KX_ConstraintWrapper.cpp
KX_ConvertPhysicsObjects.cpp
@@ -149,6 +151,7 @@ set(SRC
KX_Camera.h
KX_CameraActuator.h
KX_CameraIpoSGController.h
+ KX_CharacterWrapper.h
KX_ClientObjectInfo.h
KX_ConstraintActuator.h
KX_ConstraintWrapper.h
diff --git a/source/gameengine/Ketsji/KX_CharacterWrapper.cpp b/source/gameengine/Ketsji/KX_CharacterWrapper.cpp
new file mode 100644
index 00000000000..ce208f3a75f
--- /dev/null
+++ b/source/gameengine/Ketsji/KX_CharacterWrapper.cpp
@@ -0,0 +1,94 @@
+/** \file gameengine/Ketsji/KX_CharacterWrapper.cpp
+ * \ingroup ketsji
+ */
+
+
+#include "KX_CharacterWrapper.h"
+#include "PHY_ICharacter.h"
+
+KX_CharacterWrapper::KX_CharacterWrapper(PHY_ICharacter* character) :
+ PyObjectPlus(),
+ m_character(character)
+{
+}
+
+KX_CharacterWrapper::~KX_CharacterWrapper()
+{
+ if (m_character)
+ delete m_character; // We're responsible for the character object!
+}
+
+#ifdef WITH_PYTHON
+
+PyTypeObject KX_CharacterWrapper::Type = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ "KX_CharacterWrapper",
+ sizeof(PyObjectPlus_Proxy),
+ 0,
+ py_base_dealloc,
+ 0,
+ 0,
+ 0,
+ 0,
+ py_base_repr,
+ 0,0,0,0,0,0,0,0,0,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
+ &PyObjectPlus::Type,
+ 0,0,0,0,0,0,
+ py_base_new
+};
+
+PyAttributeDef KX_CharacterWrapper::Attributes[] = {
+ KX_PYATTRIBUTE_RO_FUNCTION("onGround", KX_CharacterWrapper, pyattr_get_onground),
+ KX_PYATTRIBUTE_RW_FUNCTION("gravity", KX_CharacterWrapper, pyattr_get_gravity, pyattr_set_gravity),
+ { NULL } //Sentinel
+};
+
+PyObject *KX_CharacterWrapper::pyattr_get_onground(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ KX_CharacterWrapper* self = static_cast<KX_CharacterWrapper*>(self_v);
+
+ return PyBool_FromLong(self->m_character->OnGround());
+}
+
+PyObject *KX_CharacterWrapper::pyattr_get_gravity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ KX_CharacterWrapper* self = static_cast<KX_CharacterWrapper*>(self_v);
+
+ return PyFloat_FromDouble(self->m_character->GetGravity());
+}
+
+int KX_CharacterWrapper::pyattr_set_gravity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
+{
+ KX_CharacterWrapper* self = static_cast<KX_CharacterWrapper*>(self_v);
+ double param = PyFloat_AsDouble(value);
+
+ if (param == -1)
+ {
+ PyErr_SetString(PyExc_ValueError, "KX_CharacterWrapper.gravity: expected a float");
+ return PY_SET_ATTR_FAIL;
+ }
+
+ self->m_character->SetGravity((float)param);
+ return PY_SET_ATTR_SUCCESS;
+}
+
+PyMethodDef KX_CharacterWrapper::Methods[] = {
+ KX_PYMETHODTABLE_NOARGS(KX_CharacterWrapper, jump),
+ {NULL,NULL} //Sentinel
+};
+
+KX_PYMETHODDEF_DOC_NOARGS(KX_CharacterWrapper, jump,
+ "jump()\n"
+ "makes the character jump.\n")
+{
+ m_character->Jump();
+
+ Py_RETURN_NONE;
+}
+
+#endif // WITH_PYTHON
diff --git a/source/gameengine/Ketsji/KX_CharacterWrapper.h b/source/gameengine/Ketsji/KX_CharacterWrapper.h
new file mode 100644
index 00000000000..cc99aba99f6
--- /dev/null
+++ b/source/gameengine/Ketsji/KX_CharacterWrapper.h
@@ -0,0 +1,35 @@
+
+/** \file KX_CharacterWrapper.h
+ * \ingroup ketsji
+ */
+
+#ifndef __KX_CHARACTERWRAPPER_H__
+#define __KX_CHARACTERWRAPPER_H__
+
+#include "Value.h"
+#include "PHY_DynamicTypes.h"
+class PHY_ICharacter;
+
+
+///Python interface to character physics
+class KX_CharacterWrapper : public PyObjectPlus
+{
+ Py_Header
+
+public:
+ KX_CharacterWrapper(PHY_ICharacter* character);
+ virtual ~KX_CharacterWrapper();
+#ifdef WITH_PYTHON
+ KX_PYMETHOD_DOC_NOARGS(KX_CharacterWrapper, jump);
+
+ static PyObject* pyattr_get_onground(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+
+ static PyObject* pyattr_get_gravity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static int pyattr_set_gravity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
+#endif // WITH_PYTHON
+
+private:
+ PHY_ICharacter* m_character;
+};
+
+#endif //__KX_CHARACTERWRAPPER_H__
diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp
index 2999550fb8f..e5f7ea22b36 100644
--- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp
+++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp
@@ -117,7 +117,7 @@ bool KX_ObjectActuator::Update()
}
// Explicitly stop the movement if we're using a character (apply movement is a little different for characters)
- if (parent->GetPhysicsController()->IsCharacter()) {
+ if (parent->GetPhysicsController() && parent->GetPhysicsController()->IsCharacter()) {
MT_Vector3 vec(0.0, 0.0, 0.0);
parent->ApplyMovement(vec, true);
}
diff --git a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
index 5f3a4879150..4475ac8ec96 100644
--- a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
+++ b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
@@ -33,12 +33,15 @@
#include "PHY_IPhysicsEnvironment.h"
#include "KX_ConstraintWrapper.h"
#include "KX_VehicleWrapper.h"
+#include "KX_CharacterWrapper.h"
#include "KX_PhysicsObjectWrapper.h"
#include "PHY_IPhysicsController.h"
#include "PHY_IVehicle.h"
#include "PHY_DynamicTypes.h"
#include "MT_Matrix3x3.h"
+#include "KX_GameObject.h" // ConvertPythonToGameObject()
+
#include "PyObjectPlus.h"
#ifdef USE_BULLET
@@ -81,6 +84,7 @@ static char gPySetSolverType__doc__[] = "setSolverType(int solverType) Very expe
static char gPyCreateConstraint__doc__[] = "createConstraint(ob1,ob2,float restLength,float restitution,float damping)";
static char gPyGetVehicleConstraint__doc__[] = "getVehicleConstraint(int constraintId)";
+static char gPyGetCharacter__doc__[] = "getCharacter(KX_GameObject obj)";
static char gPyRemoveConstraint__doc__[] = "removeConstraint(int constraintId)";
static char gPyGetAppliedImpulse__doc__[] = "getAppliedImpulse(int constraintId)";
@@ -402,6 +406,33 @@ static PyObject *gPyGetVehicleConstraint(PyObject *self,
Py_RETURN_NONE;
}
+static PyObject* gPyGetCharacter(PyObject* self,
+ PyObject* args,
+ PyObject* kwds)
+{
+ PyObject* pyob;
+ KX_GameObject *ob;
+
+ if (!PyArg_ParseTuple(args,"O", &pyob))
+ return NULL;
+
+ if (!ConvertPythonToGameObject(pyob, &ob, false, "bge.constraints.getCharacter(value)"))
+ return NULL;
+
+ if (PHY_GetActiveEnvironment())
+ {
+
+ PHY_ICharacter* character= PHY_GetActiveEnvironment()->getCharacterController(ob);
+ if (character)
+ {
+ KX_CharacterWrapper* pyWrapper = new KX_CharacterWrapper(character);
+ return pyWrapper->NewProxy(true);
+ }
+
+ }
+
+ Py_RETURN_NONE;
+}
static PyObject *gPyCreateConstraint(PyObject *self,
PyObject *args,
@@ -631,6 +662,9 @@ static struct PyMethodDef physicsconstraints_methods[] = {
{"getVehicleConstraint",(PyCFunction) gPyGetVehicleConstraint,
METH_VARARGS, (const char *)gPyGetVehicleConstraint__doc__},
+ {"getCharacter",(PyCFunction) gPyGetCharacter,
+ METH_VARARGS, (const char *)gPyGetCharacter__doc__},
+
{"removeConstraint",(PyCFunction) gPyRemoveConstraint,
METH_VARARGS, (const char *)gPyRemoveConstraint__doc__},
{"getAppliedImpulse",(PyCFunction) gPyGetAppliedImpulse,
diff --git a/source/gameengine/Ketsji/KX_PythonInitTypes.cpp b/source/gameengine/Ketsji/KX_PythonInitTypes.cpp
index d0e3d26f61b..805b9ce2fc2 100644
--- a/source/gameengine/Ketsji/KX_PythonInitTypes.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInitTypes.cpp
@@ -42,6 +42,7 @@
#include "BL_ArmatureChannel.h"
#include "KX_BlenderMaterial.h"
#include "KX_CameraActuator.h"
+#include "KX_CharacterWrapper.h"
#include "KX_ConstraintActuator.h"
#include "KX_ConstraintWrapper.h"
#include "KX_GameActuator.h"
@@ -189,6 +190,7 @@ void initPyTypes(void)
PyType_Ready_Attr(dict, KX_BlenderMaterial, init_getset);
PyType_Ready_Attr(dict, KX_Camera, init_getset);
PyType_Ready_Attr(dict, KX_CameraActuator, init_getset);
+ PyType_Ready_Attr(dict, KX_CharacterWrapper, init_getset);
PyType_Ready_Attr(dict, KX_ConstraintActuator, init_getset);
PyType_Ready_Attr(dict, KX_ConstraintWrapper, init_getset);
PyType_Ready_Attr(dict, KX_GameActuator, init_getset);
diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp
index f76f94aa81d..2a4f2b3e7d9 100644
--- a/source/gameengine/Ketsji/KX_SoundActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp
@@ -53,7 +53,7 @@
/* Native functions */
/* ------------------------------------------------------------------------- */
KX_SoundActuator::KX_SoundActuator(SCA_IObject* gameobj,
- AUD_Reference<AUD_IFactory> sound,
+ boost::shared_ptr<AUD_IFactory> sound,
float volume,
float pitch,
bool is3d,
@@ -74,20 +74,20 @@ KX_SoundActuator::KX_SoundActuator(SCA_IObject* gameobj,
KX_SoundActuator::~KX_SoundActuator()
{
- if (!m_handle.isNull())
+ if (m_handle.get())
m_handle->stop();
}
void KX_SoundActuator::play()
{
- if (!m_handle.isNull())
+ if (m_handle.get())
m_handle->stop();
- if (m_sound.isNull())
+ if (!m_sound.get())
return;
// this is the sound that will be played and not deleted afterwards
- AUD_Reference<AUD_IFactory> sound = m_sound;
+ boost::shared_ptr<AUD_IFactory> sound = m_sound;
bool loop = false;
@@ -95,7 +95,7 @@ void KX_SoundActuator::play()
{
case KX_SOUNDACT_LOOPBIDIRECTIONAL:
case KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP:
- sound = new AUD_PingPongFactory(sound);
+ sound = boost::shared_ptr<AUD_IFactory>(new AUD_PingPongFactory(sound));
// fall through
case KX_SOUNDACT_LOOPEND:
case KX_SOUNDACT_LOOPSTOP:
@@ -117,9 +117,9 @@ void KX_SoundActuator::play()
return;
}
- AUD_Reference<AUD_I3DHandle> handle3d = AUD_Reference<AUD_I3DHandle>(m_handle);
+ boost::shared_ptr<AUD_I3DHandle> handle3d = boost::dynamic_pointer_cast<AUD_I3DHandle>(m_handle);
- if (m_is3d && !handle3d.isNull())
+ if (m_is3d && handle3d.get())
{
handle3d->setRelative(true);
handle3d->setVolumeMaximum(m_3d.max_gain);
@@ -149,7 +149,7 @@ CValue* KX_SoundActuator::GetReplica()
void KX_SoundActuator::ProcessReplica()
{
SCA_IActuator::ProcessReplica();
- m_handle = AUD_Reference<AUD_IHandle>();
+ m_handle = boost::shared_ptr<AUD_IHandle>();
}
bool KX_SoundActuator::Update(double curtime, bool frame)
@@ -164,11 +164,11 @@ bool KX_SoundActuator::Update(double curtime, bool frame)
RemoveAllEvents();
- if (m_sound.isNull())
+ if (!m_sound.get())
return false;
// actual audio device playing state
- bool isplaying = m_handle.isNull() ? false : (m_handle->getStatus() == AUD_STATUS_PLAYING);
+ bool isplaying = m_handle.get() ? (m_handle->getStatus() == AUD_STATUS_PLAYING) : false;
if (bNegativeEvent)
{
@@ -182,9 +182,9 @@ bool KX_SoundActuator::Update(double curtime, bool frame)
case KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP:
{
// stop immediately
- if (!m_handle.isNull())
+ if (m_handle.get())
m_handle->stop();
- m_handle = AUD_Reference<AUD_IHandle>();
+ m_handle = boost::shared_ptr<AUD_IHandle>();
break;
}
case KX_SOUNDACT_PLAYEND:
@@ -196,7 +196,7 @@ bool KX_SoundActuator::Update(double curtime, bool frame)
case KX_SOUNDACT_LOOPBIDIRECTIONAL:
{
// stop the looping so that the sound stops when it finished
- if (!m_handle.isNull())
+ if (m_handle.get())
m_handle->setLoopCount(0);
break;
}
@@ -223,13 +223,13 @@ bool KX_SoundActuator::Update(double curtime, bool frame)
play();
}
// verify that the sound is still playing
- isplaying = m_handle.isNull() ? false : (m_handle->getStatus() == AUD_STATUS_PLAYING);
+ isplaying = m_handle.get() ? (m_handle->getStatus() == AUD_STATUS_PLAYING) : false;
if (isplaying)
{
- AUD_Reference<AUD_I3DHandle> handle3d = AUD_Reference<AUD_I3DHandle>(m_handle);
+ boost::shared_ptr<AUD_I3DHandle> handle3d = boost::dynamic_pointer_cast<AUD_I3DHandle>(m_handle);
- if (m_is3d && !handle3d.isNull())
+ if (m_is3d && handle3d.get())
{
KX_Camera* cam = KX_GetActiveScene()->GetActiveCamera();
if (cam)
@@ -325,7 +325,7 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, startSound,
"startSound()\n"
"\tStarts the sound.\n")
{
- switch (m_handle.isNull() ? AUD_STATUS_INVALID : m_handle->getStatus()) {
+ switch (m_handle.get() ? m_handle->getStatus() : AUD_STATUS_INVALID) {
case AUD_STATUS_PLAYING:
break;
case AUD_STATUS_PAUSED:
@@ -341,7 +341,7 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, pauseSound,
"pauseSound()\n"
"\tPauses the sound.\n")
{
- if (!m_handle.isNull())
+ if (m_handle.get())
m_handle->pause();
Py_RETURN_NONE;
}
@@ -350,9 +350,9 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, stopSound,
"stopSound()\n"
"\tStops the sound.\n")
{
- if (!m_handle.isNull())
+ if (m_handle.get())
m_handle->stop();
- m_handle = AUD_Reference<AUD_IHandle>();
+ m_handle = boost::shared_ptr<AUD_IHandle>();
Py_RETURN_NONE;
}
@@ -400,7 +400,7 @@ PyObject *KX_SoundActuator::pyattr_get_audposition(void *self, const struct KX_P
KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
float position = 0.0;
- if (!actuator->m_handle.isNull())
+ if (actuator->m_handle.get())
position = actuator->m_handle->getPosition();
PyObject *result = PyFloat_FromDouble(position);
@@ -431,7 +431,7 @@ PyObject *KX_SoundActuator::pyattr_get_pitch(void *self, const struct KX_PYATTRI
PyObject *KX_SoundActuator::pyattr_get_sound(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
{
KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
- if (!actuator->m_sound.isNull())
+ if (actuator->m_sound.get())
return (PyObject *)AUD_getPythonFactory(&actuator->m_sound);
else
Py_RETURN_NONE;
@@ -446,49 +446,49 @@ int KX_SoundActuator::pyattr_set_3d_property(void *self, const struct KX_PYATTRI
if (!PyArg_Parse(value, "f", &prop_value))
return PY_SET_ATTR_FAIL;
- AUD_Reference<AUD_I3DHandle> handle3d = AUD_Reference<AUD_I3DHandle>(actuator->m_handle);
+ boost::shared_ptr<AUD_I3DHandle> handle3d = boost::dynamic_pointer_cast<AUD_I3DHandle>(actuator->m_handle);
// if sound is working and 3D, set the new setting
if (!actuator->m_is3d)
return PY_SET_ATTR_FAIL;
if (!strcmp(prop, "volume_maximum")) {
actuator->m_3d.max_gain = prop_value;
- if (!handle3d.isNull())
+ if (handle3d.get())
handle3d->setVolumeMaximum(prop_value);
} else if (!strcmp(prop, "volume_minimum")) {
actuator->m_3d.min_gain = prop_value;
- if (!handle3d.isNull())
+ if (handle3d.get())
handle3d->setVolumeMinimum(prop_value);
} else if (!strcmp(prop, "distance_reference")) {
actuator->m_3d.reference_distance = prop_value;
- if (!handle3d.isNull())
+ if (handle3d.get())
handle3d->setDistanceReference(prop_value);
} else if (!strcmp(prop, "distance_maximum")) {
actuator->m_3d.max_distance = prop_value;
- if (!handle3d.isNull())
+ if (handle3d.get())
handle3d->setDistanceMaximum(prop_value);
} else if (!strcmp(prop, "attenuation")) {
actuator->m_3d.rolloff_factor = prop_value;
- if (!handle3d.isNull())
+ if (handle3d.get())
handle3d->setAttenuation(prop_value);
} else if (!!strcmp(prop, "cone_angle_inner")) {
actuator->m_3d.cone_inner_angle = prop_value;
- if (!handle3d.isNull())
+ if (handle3d.get())
handle3d->setConeAngleInner(prop_value);
} else if (!strcmp(prop, "cone_angle_outer")) {
actuator->m_3d.cone_outer_angle = prop_value;
- if (!handle3d.isNull())
+ if (handle3d.get())
handle3d->setConeAngleOuter(prop_value);
} else if (!strcmp(prop, "cone_volume_outer")) {
actuator->m_3d.cone_outer_gain = prop_value;
- if (!handle3d.isNull())
+ if (handle3d.get())
handle3d->setConeVolumeOuter(prop_value);
} else {
@@ -506,7 +506,7 @@ int KX_SoundActuator::pyattr_set_audposition(void *self, const struct KX_PYATTRI
if (!PyArg_Parse(value, "f", &position))
return PY_SET_ATTR_FAIL;
- if (!actuator->m_handle.isNull())
+ if (actuator->m_handle.get())
actuator->m_handle->seek(position);
return PY_SET_ATTR_SUCCESS;
}
@@ -519,7 +519,7 @@ int KX_SoundActuator::pyattr_set_gain(void *self, const struct KX_PYATTRIBUTE_DE
return PY_SET_ATTR_FAIL;
actuator->m_volume = gain;
- if (!actuator->m_handle.isNull())
+ if (actuator->m_handle.get())
actuator->m_handle->setVolume(gain);
return PY_SET_ATTR_SUCCESS;
@@ -533,7 +533,7 @@ int KX_SoundActuator::pyattr_set_pitch(void *self, const struct KX_PYATTRIBUTE_D
return PY_SET_ATTR_FAIL;
actuator->m_pitch = pitch;
- if (!actuator->m_handle.isNull())
+ if (actuator->m_handle.get())
actuator->m_handle->setPitch(pitch);
return PY_SET_ATTR_SUCCESS;
@@ -546,7 +546,7 @@ int KX_SoundActuator::pyattr_set_sound(void *self, const struct KX_PYATTRIBUTE_D
if (!PyArg_Parse(value, "O", &sound))
return PY_SET_ATTR_FAIL;
- AUD_Reference<AUD_IFactory>* snd = reinterpret_cast<AUD_Reference<AUD_IFactory>*>(AUD_getPythonSound((void *)sound));
+ boost::shared_ptr<AUD_IFactory>* snd = reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(AUD_getPythonSound((void *)sound));
if (snd)
{
actuator->m_sound = *snd;
diff --git a/source/gameengine/Ketsji/KX_SoundActuator.h b/source/gameengine/Ketsji/KX_SoundActuator.h
index 1ce44e942e8..68eff56797b 100644
--- a/source/gameengine/Ketsji/KX_SoundActuator.h
+++ b/source/gameengine/Ketsji/KX_SoundActuator.h
@@ -36,9 +36,9 @@
#ifdef WITH_AUDASPACE
# include "AUD_C-API.h"
-# include "AUD_Reference.h"
# include "AUD_IFactory.h"
# include "AUD_IHandle.h"
+# include <boost/shared_ptr.hpp>
#endif
#include "BKE_sound.h"
@@ -58,12 +58,12 @@ class KX_SoundActuator : public SCA_IActuator
{
Py_Header
bool m_isplaying;
- AUD_Reference<AUD_IFactory> m_sound;
+ boost::shared_ptr<AUD_IFactory> m_sound;
float m_volume;
float m_pitch;
bool m_is3d;
KX_3DSoundSettings m_3d;
- AUD_Reference<AUD_IHandle> m_handle;
+ boost::shared_ptr<AUD_IHandle> m_handle;
void play();
@@ -84,7 +84,7 @@ public:
KX_SOUNDACT_TYPE m_type;
KX_SoundActuator(SCA_IObject* gameobj,
- AUD_Reference<AUD_IFactory> sound,
+ boost::shared_ptr<AUD_IFactory> sound,
float volume,
float pitch,
bool is3d,
diff --git a/source/gameengine/Ketsji/SConscript b/source/gameengine/Ketsji/SConscript
index 5fdf250006f..88689a5a736 100644
--- a/source/gameengine/Ketsji/SConscript
+++ b/source/gameengine/Ketsji/SConscript
@@ -24,6 +24,7 @@ incs += ' #extern/recastnavigation/Recast/Include #extern/recastnavigation/Detou
incs += ' ' + env['BF_BULLET_INC']
incs += ' ' + env['BF_OPENGL_INC']
+incs += ' ' + env['BF_BOOST_INC']
if env['WITH_BF_SDL']:
incs += ' ' + env['BF_SDL_INC']
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
index 687fc116234..486411d7e35 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
@@ -37,6 +37,7 @@ subject to the following restrictions:
#include "PHY_IMotionState.h"
+#include "PHY_ICharacter.h"
#include "KX_GameObject.h"
#include "RAS_MeshObject.h"
#include "RAS_Polygon.h"
@@ -266,6 +267,36 @@ public:
};
#endif //NEW_BULLET_VEHICLE_SUPPORT
+class CharacterWrapper : public PHY_ICharacter
+{
+private:
+ btKinematicCharacterController* m_controller;
+
+public:
+ CharacterWrapper(btKinematicCharacterController* cont)
+ : m_controller(cont)
+ {}
+
+ virtual void Jump()
+ {
+ m_controller->jump();
+ }
+
+ virtual bool OnGround()
+ {
+ return m_controller->onGround();
+ }
+
+ virtual float GetGravity()
+ {
+ return m_controller->getGravity();
+ }
+ virtual void SetGravity(float gravity)
+ {
+ m_controller->setGravity(gravity);
+ }
+};
+
class CcdOverlapFilterCallBack : public btOverlapFilterCallback
{
private:
@@ -2285,6 +2316,15 @@ PHY_IVehicle* CcdPhysicsEnvironment::getVehicleConstraint(int constraintId)
#endif //NEW_BULLET_VEHICLE_SUPPORT
+PHY_ICharacter* CcdPhysicsEnvironment::getCharacterController(KX_GameObject *ob)
+{
+ CcdPhysicsController* controller = (CcdPhysicsController*)ob->GetPhysicsController()->GetUserData();
+ if (controller->GetCharacterController())
+ return new CharacterWrapper(controller->GetCharacterController());
+
+ return NULL;
+}
+
int currentController = 0;
int numController = 0;
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
index 350ecd2588a..18ce0550498 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
@@ -184,6 +184,8 @@ protected:
return 0;
}
#endif /* NEW_BULLET_VEHICLE_SUPPORT */
+ // Character physics wrapper
+ virtual PHY_ICharacter* getCharacterController(class KX_GameObject* ob);
btTypedConstraint* getConstraintById(int constraintId);
diff --git a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
index 70de9c25553..233c4412d9e 100644
--- a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
+++ b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
@@ -72,6 +72,12 @@ public:
return 0;
}
+ // Character physics wrapper
+ virtual PHY_ICharacter* getCharacterController(class KX_GameObject* ob)
+ {
+ return 0;
+ }
+
virtual PHY_IPhysicsController* rayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ);
virtual bool cullingTest(PHY_CullingCallback callback, void* userData, PHY__Vector4* planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16]) { return false; }
diff --git a/source/gameengine/Physics/common/CMakeLists.txt b/source/gameengine/Physics/common/CMakeLists.txt
index ceb7a8ba548..400e475f8a2 100644
--- a/source/gameengine/Physics/common/CMakeLists.txt
+++ b/source/gameengine/Physics/common/CMakeLists.txt
@@ -41,6 +41,7 @@ set(SRC
PHY_IVehicle.cpp
PHY_DynamicTypes.h
+ PHY_ICharacter.h
PHY_IController.h
PHY_IGraphicController.h
PHY_IMotionState.h
diff --git a/source/gameengine/Physics/common/PHY_ICharacter.h b/source/gameengine/Physics/common/PHY_ICharacter.h
new file mode 100644
index 00000000000..e2fc5e45125
--- /dev/null
+++ b/source/gameengine/Physics/common/PHY_ICharacter.h
@@ -0,0 +1,30 @@
+
+/** \file PHY_ICharacter.h
+ * \ingroup phys
+ */
+
+#ifndef __PHY_ICHARACTER_H__
+#define __PHY_ICHARACTER_H__
+
+//PHY_ICharacter provides a generic interface for "character" controllers
+
+#ifdef WITH_CXX_GUARDEDALLOC
+#include "MEM_guardedalloc.h"
+#endif
+
+class PHY_ICharacter
+{
+public:
+
+ virtual void Jump()= 0;
+ virtual bool OnGround()= 0;
+
+ virtual float GetGravity()= 0;
+ virtual void SetGravity(float gravity)= 0;
+
+#ifdef WITH_CXX_GUARDEDALLOC
+ MEM_CXX_CLASS_ALLOC_FUNCS("GE:PHY_ICharacter")
+#endif
+};
+
+#endif //__PHY_ICHARACTER_H__
diff --git a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
index 66ca037aa47..077d225903c 100644
--- a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
+++ b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
@@ -40,6 +40,7 @@
#endif
class PHY_IVehicle;
+class PHY_ICharacter;
class RAS_MeshObject;
class PHY_IPhysicsController;
@@ -156,6 +157,9 @@ class PHY_IPhysicsEnvironment
//complex constraint for vehicles
virtual PHY_IVehicle* getVehicleConstraint(int constraintId) =0;
+ // Character physics wrapper
+ virtual PHY_ICharacter* getCharacterController(class KX_GameObject* ob) =0;
+
virtual PHY_IPhysicsController* rayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ)=0;
//culling based on physical broad phase